babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966
  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. }
  5247. }
  5248. declare module "babylonjs/Meshes/dataBuffer" {
  5249. /**
  5250. * Class used to store gfx data (like WebGLBuffer)
  5251. */
  5252. export class DataBuffer {
  5253. /**
  5254. * Gets or sets the number of objects referencing this buffer
  5255. */
  5256. references: number;
  5257. /** Gets or sets the size of the underlying buffer */
  5258. capacity: number;
  5259. /**
  5260. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5261. */
  5262. is32Bits: boolean;
  5263. /**
  5264. * Gets the underlying buffer
  5265. */
  5266. readonly underlyingResource: any;
  5267. }
  5268. }
  5269. declare module "babylonjs/Misc/performanceMonitor" {
  5270. /**
  5271. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5272. */
  5273. export class PerformanceMonitor {
  5274. private _enabled;
  5275. private _rollingFrameTime;
  5276. private _lastFrameTimeMs;
  5277. /**
  5278. * constructor
  5279. * @param frameSampleSize The number of samples required to saturate the sliding window
  5280. */
  5281. constructor(frameSampleSize?: number);
  5282. /**
  5283. * Samples current frame
  5284. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5285. */
  5286. sampleFrame(timeMs?: number): void;
  5287. /**
  5288. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5289. */
  5290. readonly averageFrameTime: number;
  5291. /**
  5292. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5293. */
  5294. readonly averageFrameTimeVariance: number;
  5295. /**
  5296. * Returns the frame time of the most recent frame
  5297. */
  5298. readonly instantaneousFrameTime: number;
  5299. /**
  5300. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5301. */
  5302. readonly averageFPS: number;
  5303. /**
  5304. * Returns the average framerate in frames per second using the most recent frame time
  5305. */
  5306. readonly instantaneousFPS: number;
  5307. /**
  5308. * Returns true if enough samples have been taken to completely fill the sliding window
  5309. */
  5310. readonly isSaturated: boolean;
  5311. /**
  5312. * Enables contributions to the sliding window sample set
  5313. */
  5314. enable(): void;
  5315. /**
  5316. * Disables contributions to the sliding window sample set
  5317. * Samples will not be interpolated over the disabled period
  5318. */
  5319. disable(): void;
  5320. /**
  5321. * Returns true if sampling is enabled
  5322. */
  5323. readonly isEnabled: boolean;
  5324. /**
  5325. * Resets performance monitor
  5326. */
  5327. reset(): void;
  5328. }
  5329. /**
  5330. * RollingAverage
  5331. *
  5332. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5333. */
  5334. export class RollingAverage {
  5335. /**
  5336. * Current average
  5337. */
  5338. average: number;
  5339. /**
  5340. * Current variance
  5341. */
  5342. variance: number;
  5343. protected _samples: Array<number>;
  5344. protected _sampleCount: number;
  5345. protected _pos: number;
  5346. protected _m2: number;
  5347. /**
  5348. * constructor
  5349. * @param length The number of samples required to saturate the sliding window
  5350. */
  5351. constructor(length: number);
  5352. /**
  5353. * Adds a sample to the sample set
  5354. * @param v The sample value
  5355. */
  5356. add(v: number): void;
  5357. /**
  5358. * Returns previously added values or null if outside of history or outside the sliding window domain
  5359. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5360. * @return Value previously recorded with add() or null if outside of range
  5361. */
  5362. history(i: number): number;
  5363. /**
  5364. * Returns true if enough samples have been taken to completely fill the sliding window
  5365. * @return true if sample-set saturated
  5366. */
  5367. isSaturated(): boolean;
  5368. /**
  5369. * Resets the rolling average (equivalent to 0 samples taken so far)
  5370. */
  5371. reset(): void;
  5372. /**
  5373. * Wraps a value around the sample range boundaries
  5374. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5375. * @return Wrapped position in sample range
  5376. */
  5377. protected _wrapPosition(i: number): number;
  5378. }
  5379. }
  5380. declare module "babylonjs/Misc/stringDictionary" {
  5381. import { Nullable } from "babylonjs/types";
  5382. /**
  5383. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5384. * The underlying implementation relies on an associative array to ensure the best performances.
  5385. * The value can be anything including 'null' but except 'undefined'
  5386. */
  5387. export class StringDictionary<T> {
  5388. /**
  5389. * This will clear this dictionary and copy the content from the 'source' one.
  5390. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5391. * @param source the dictionary to take the content from and copy to this dictionary
  5392. */
  5393. copyFrom(source: StringDictionary<T>): void;
  5394. /**
  5395. * Get a value based from its key
  5396. * @param key the given key to get the matching value from
  5397. * @return the value if found, otherwise undefined is returned
  5398. */
  5399. get(key: string): T | undefined;
  5400. /**
  5401. * Get a value from its key or add it if it doesn't exist.
  5402. * This method will ensure you that a given key/data will be present in the dictionary.
  5403. * @param key the given key to get the matching value from
  5404. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5405. * The factory will only be invoked if there's no data for the given key.
  5406. * @return the value corresponding to the key.
  5407. */
  5408. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5409. /**
  5410. * Get a value from its key if present in the dictionary otherwise add it
  5411. * @param key the key to get the value from
  5412. * @param val if there's no such key/value pair in the dictionary add it with this value
  5413. * @return the value corresponding to the key
  5414. */
  5415. getOrAdd(key: string, val: T): T;
  5416. /**
  5417. * Check if there's a given key in the dictionary
  5418. * @param key the key to check for
  5419. * @return true if the key is present, false otherwise
  5420. */
  5421. contains(key: string): boolean;
  5422. /**
  5423. * Add a new key and its corresponding value
  5424. * @param key the key to add
  5425. * @param value the value corresponding to the key
  5426. * @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
  5427. */
  5428. add(key: string, value: T): boolean;
  5429. /**
  5430. * Update a specific value associated to a key
  5431. * @param key defines the key to use
  5432. * @param value defines the value to store
  5433. * @returns true if the value was updated (or false if the key was not found)
  5434. */
  5435. set(key: string, value: T): boolean;
  5436. /**
  5437. * Get the element of the given key and remove it from the dictionary
  5438. * @param key defines the key to search
  5439. * @returns the value associated with the key or null if not found
  5440. */
  5441. getAndRemove(key: string): Nullable<T>;
  5442. /**
  5443. * Remove a key/value from the dictionary.
  5444. * @param key the key to remove
  5445. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5446. */
  5447. remove(key: string): boolean;
  5448. /**
  5449. * Clear the whole content of the dictionary
  5450. */
  5451. clear(): void;
  5452. /**
  5453. * Gets the current count
  5454. */
  5455. readonly count: number;
  5456. /**
  5457. * Execute a callback on each key/val of the dictionary.
  5458. * Note that you can remove any element in this dictionary in the callback implementation
  5459. * @param callback the callback to execute on a given key/value pair
  5460. */
  5461. forEach(callback: (key: string, val: T) => void): void;
  5462. /**
  5463. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5464. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5465. * Note that you can remove any element in this dictionary in the callback implementation
  5466. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5467. * @returns the first item
  5468. */
  5469. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5470. private _count;
  5471. private _data;
  5472. }
  5473. }
  5474. declare module "babylonjs/Misc/promise" {
  5475. /**
  5476. * Helper class that provides a small promise polyfill
  5477. */
  5478. export class PromisePolyfill {
  5479. /**
  5480. * Static function used to check if the polyfill is required
  5481. * If this is the case then the function will inject the polyfill to window.Promise
  5482. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5483. */
  5484. static Apply(force?: boolean): void;
  5485. }
  5486. }
  5487. declare module "babylonjs/Meshes/buffer" {
  5488. import { Nullable, DataArray } from "babylonjs/types";
  5489. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5490. /**
  5491. * Class used to store data that will be store in GPU memory
  5492. */
  5493. export class Buffer {
  5494. private _engine;
  5495. private _buffer;
  5496. /** @hidden */
  5497. _data: Nullable<DataArray>;
  5498. private _updatable;
  5499. private _instanced;
  5500. /**
  5501. * Gets the byte stride.
  5502. */
  5503. readonly byteStride: number;
  5504. /**
  5505. * Constructor
  5506. * @param engine the engine
  5507. * @param data the data to use for this buffer
  5508. * @param updatable whether the data is updatable
  5509. * @param stride the stride (optional)
  5510. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5511. * @param instanced whether the buffer is instanced (optional)
  5512. * @param useBytes set to true if the stride in in bytes (optional)
  5513. */
  5514. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5515. /**
  5516. * Create a new VertexBuffer based on the current buffer
  5517. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5518. * @param offset defines offset in the buffer (0 by default)
  5519. * @param size defines the size in floats of attributes (position is 3 for instance)
  5520. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5521. * @param instanced defines if the vertex buffer contains indexed data
  5522. * @param useBytes defines if the offset and stride are in bytes
  5523. * @returns the new vertex buffer
  5524. */
  5525. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5526. /**
  5527. * Gets a boolean indicating if the Buffer is updatable?
  5528. * @returns true if the buffer is updatable
  5529. */
  5530. isUpdatable(): boolean;
  5531. /**
  5532. * Gets current buffer's data
  5533. * @returns a DataArray or null
  5534. */
  5535. getData(): Nullable<DataArray>;
  5536. /**
  5537. * Gets underlying native buffer
  5538. * @returns underlying native buffer
  5539. */
  5540. getBuffer(): Nullable<DataBuffer>;
  5541. /**
  5542. * Gets the stride in float32 units (i.e. byte stride / 4).
  5543. * May not be an integer if the byte stride is not divisible by 4.
  5544. * DEPRECATED. Use byteStride instead.
  5545. * @returns the stride in float32 units
  5546. */
  5547. getStrideSize(): number;
  5548. /**
  5549. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5550. * @param data defines the data to store
  5551. */
  5552. create(data?: Nullable<DataArray>): void;
  5553. /** @hidden */
  5554. _rebuild(): void;
  5555. /**
  5556. * Update current buffer data
  5557. * @param data defines the data to store
  5558. */
  5559. update(data: DataArray): void;
  5560. /**
  5561. * Updates the data directly.
  5562. * @param data the new data
  5563. * @param offset the new offset
  5564. * @param vertexCount the vertex count (optional)
  5565. * @param useBytes set to true if the offset is in bytes
  5566. */
  5567. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5568. /**
  5569. * Release all resources
  5570. */
  5571. dispose(): void;
  5572. }
  5573. /**
  5574. * Specialized buffer used to store vertex data
  5575. */
  5576. export class VertexBuffer {
  5577. /** @hidden */
  5578. _buffer: Buffer;
  5579. private _kind;
  5580. private _size;
  5581. private _ownsBuffer;
  5582. private _instanced;
  5583. private _instanceDivisor;
  5584. /**
  5585. * The byte type.
  5586. */
  5587. static readonly BYTE: number;
  5588. /**
  5589. * The unsigned byte type.
  5590. */
  5591. static readonly UNSIGNED_BYTE: number;
  5592. /**
  5593. * The short type.
  5594. */
  5595. static readonly SHORT: number;
  5596. /**
  5597. * The unsigned short type.
  5598. */
  5599. static readonly UNSIGNED_SHORT: number;
  5600. /**
  5601. * The integer type.
  5602. */
  5603. static readonly INT: number;
  5604. /**
  5605. * The unsigned integer type.
  5606. */
  5607. static readonly UNSIGNED_INT: number;
  5608. /**
  5609. * The float type.
  5610. */
  5611. static readonly FLOAT: number;
  5612. /**
  5613. * Gets or sets the instance divisor when in instanced mode
  5614. */
  5615. instanceDivisor: number;
  5616. /**
  5617. * Gets the byte stride.
  5618. */
  5619. readonly byteStride: number;
  5620. /**
  5621. * Gets the byte offset.
  5622. */
  5623. readonly byteOffset: number;
  5624. /**
  5625. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5626. */
  5627. readonly normalized: boolean;
  5628. /**
  5629. * Gets the data type of each component in the array.
  5630. */
  5631. readonly type: number;
  5632. /**
  5633. * Constructor
  5634. * @param engine the engine
  5635. * @param data the data to use for this vertex buffer
  5636. * @param kind the vertex buffer kind
  5637. * @param updatable whether the data is updatable
  5638. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5639. * @param stride the stride (optional)
  5640. * @param instanced whether the buffer is instanced (optional)
  5641. * @param offset the offset of the data (optional)
  5642. * @param size the number of components (optional)
  5643. * @param type the type of the component (optional)
  5644. * @param normalized whether the data contains normalized data (optional)
  5645. * @param useBytes set to true if stride and offset are in bytes (optional)
  5646. */
  5647. 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);
  5648. /** @hidden */
  5649. _rebuild(): void;
  5650. /**
  5651. * Returns the kind of the VertexBuffer (string)
  5652. * @returns a string
  5653. */
  5654. getKind(): string;
  5655. /**
  5656. * Gets a boolean indicating if the VertexBuffer is updatable?
  5657. * @returns true if the buffer is updatable
  5658. */
  5659. isUpdatable(): boolean;
  5660. /**
  5661. * Gets current buffer's data
  5662. * @returns a DataArray or null
  5663. */
  5664. getData(): Nullable<DataArray>;
  5665. /**
  5666. * Gets underlying native buffer
  5667. * @returns underlying native buffer
  5668. */
  5669. getBuffer(): Nullable<DataBuffer>;
  5670. /**
  5671. * Gets the stride in float32 units (i.e. byte stride / 4).
  5672. * May not be an integer if the byte stride is not divisible by 4.
  5673. * DEPRECATED. Use byteStride instead.
  5674. * @returns the stride in float32 units
  5675. */
  5676. getStrideSize(): number;
  5677. /**
  5678. * Returns the offset as a multiple of the type byte length.
  5679. * DEPRECATED. Use byteOffset instead.
  5680. * @returns the offset in bytes
  5681. */
  5682. getOffset(): number;
  5683. /**
  5684. * Returns the number of components per vertex attribute (integer)
  5685. * @returns the size in float
  5686. */
  5687. getSize(): number;
  5688. /**
  5689. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5690. * @returns true if this buffer is instanced
  5691. */
  5692. getIsInstanced(): boolean;
  5693. /**
  5694. * Returns the instancing divisor, zero for non-instanced (integer).
  5695. * @returns a number
  5696. */
  5697. getInstanceDivisor(): number;
  5698. /**
  5699. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5700. * @param data defines the data to store
  5701. */
  5702. create(data?: DataArray): void;
  5703. /**
  5704. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5705. * This function will create a new buffer if the current one is not updatable
  5706. * @param data defines the data to store
  5707. */
  5708. update(data: DataArray): void;
  5709. /**
  5710. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5711. * Returns the directly updated WebGLBuffer.
  5712. * @param data the new data
  5713. * @param offset the new offset
  5714. * @param useBytes set to true if the offset is in bytes
  5715. */
  5716. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5717. /**
  5718. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5719. */
  5720. dispose(): void;
  5721. /**
  5722. * Enumerates each value of this vertex buffer as numbers.
  5723. * @param count the number of values to enumerate
  5724. * @param callback the callback function called for each value
  5725. */
  5726. forEach(count: number, callback: (value: number, index: number) => void): void;
  5727. /**
  5728. * Positions
  5729. */
  5730. static readonly PositionKind: string;
  5731. /**
  5732. * Normals
  5733. */
  5734. static readonly NormalKind: string;
  5735. /**
  5736. * Tangents
  5737. */
  5738. static readonly TangentKind: string;
  5739. /**
  5740. * Texture coordinates
  5741. */
  5742. static readonly UVKind: string;
  5743. /**
  5744. * Texture coordinates 2
  5745. */
  5746. static readonly UV2Kind: string;
  5747. /**
  5748. * Texture coordinates 3
  5749. */
  5750. static readonly UV3Kind: string;
  5751. /**
  5752. * Texture coordinates 4
  5753. */
  5754. static readonly UV4Kind: string;
  5755. /**
  5756. * Texture coordinates 5
  5757. */
  5758. static readonly UV5Kind: string;
  5759. /**
  5760. * Texture coordinates 6
  5761. */
  5762. static readonly UV6Kind: string;
  5763. /**
  5764. * Colors
  5765. */
  5766. static readonly ColorKind: string;
  5767. /**
  5768. * Matrix indices (for bones)
  5769. */
  5770. static readonly MatricesIndicesKind: string;
  5771. /**
  5772. * Matrix weights (for bones)
  5773. */
  5774. static readonly MatricesWeightsKind: string;
  5775. /**
  5776. * Additional matrix indices (for bones)
  5777. */
  5778. static readonly MatricesIndicesExtraKind: string;
  5779. /**
  5780. * Additional matrix weights (for bones)
  5781. */
  5782. static readonly MatricesWeightsExtraKind: string;
  5783. /**
  5784. * Deduces the stride given a kind.
  5785. * @param kind The kind string to deduce
  5786. * @returns The deduced stride
  5787. */
  5788. static DeduceStride(kind: string): number;
  5789. /**
  5790. * Gets the byte length of the given type.
  5791. * @param type the type
  5792. * @returns the number of bytes
  5793. */
  5794. static GetTypeByteLength(type: number): number;
  5795. /**
  5796. * Enumerates each value of the given parameters as numbers.
  5797. * @param data the data to enumerate
  5798. * @param byteOffset the byte offset of the data
  5799. * @param byteStride the byte stride of the data
  5800. * @param componentCount the number of components per element
  5801. * @param componentType the type of the component
  5802. * @param count the total number of components
  5803. * @param normalized whether the data is normalized
  5804. * @param callback the callback function called for each value
  5805. */
  5806. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5807. private static _GetFloatValue;
  5808. }
  5809. }
  5810. declare module "babylonjs/Maths/sphericalPolynomial" {
  5811. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5812. /**
  5813. * Class representing spherical polynomial coefficients to the 3rd degree
  5814. */
  5815. export class SphericalPolynomial {
  5816. /**
  5817. * The x coefficients of the spherical polynomial
  5818. */
  5819. x: Vector3;
  5820. /**
  5821. * The y coefficients of the spherical polynomial
  5822. */
  5823. y: Vector3;
  5824. /**
  5825. * The z coefficients of the spherical polynomial
  5826. */
  5827. z: Vector3;
  5828. /**
  5829. * The xx coefficients of the spherical polynomial
  5830. */
  5831. xx: Vector3;
  5832. /**
  5833. * The yy coefficients of the spherical polynomial
  5834. */
  5835. yy: Vector3;
  5836. /**
  5837. * The zz coefficients of the spherical polynomial
  5838. */
  5839. zz: Vector3;
  5840. /**
  5841. * The xy coefficients of the spherical polynomial
  5842. */
  5843. xy: Vector3;
  5844. /**
  5845. * The yz coefficients of the spherical polynomial
  5846. */
  5847. yz: Vector3;
  5848. /**
  5849. * The zx coefficients of the spherical polynomial
  5850. */
  5851. zx: Vector3;
  5852. /**
  5853. * Adds an ambient color to the spherical polynomial
  5854. * @param color the color to add
  5855. */
  5856. addAmbient(color: Color3): void;
  5857. /**
  5858. * Scales the spherical polynomial by the given amount
  5859. * @param scale the amount to scale
  5860. */
  5861. scale(scale: number): void;
  5862. /**
  5863. * Gets the spherical polynomial from harmonics
  5864. * @param harmonics the spherical harmonics
  5865. * @returns the spherical polynomial
  5866. */
  5867. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5868. /**
  5869. * Constructs a spherical polynomial from an array.
  5870. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5871. * @returns the spherical polynomial
  5872. */
  5873. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5874. }
  5875. /**
  5876. * Class representing spherical harmonics coefficients to the 3rd degree
  5877. */
  5878. export class SphericalHarmonics {
  5879. /**
  5880. * The l0,0 coefficients of the spherical harmonics
  5881. */
  5882. l00: Vector3;
  5883. /**
  5884. * The l1,-1 coefficients of the spherical harmonics
  5885. */
  5886. l1_1: Vector3;
  5887. /**
  5888. * The l1,0 coefficients of the spherical harmonics
  5889. */
  5890. l10: Vector3;
  5891. /**
  5892. * The l1,1 coefficients of the spherical harmonics
  5893. */
  5894. l11: Vector3;
  5895. /**
  5896. * The l2,-2 coefficients of the spherical harmonics
  5897. */
  5898. l2_2: Vector3;
  5899. /**
  5900. * The l2,-1 coefficients of the spherical harmonics
  5901. */
  5902. l2_1: Vector3;
  5903. /**
  5904. * The l2,0 coefficients of the spherical harmonics
  5905. */
  5906. l20: Vector3;
  5907. /**
  5908. * The l2,1 coefficients of the spherical harmonics
  5909. */
  5910. l21: Vector3;
  5911. /**
  5912. * The l2,2 coefficients of the spherical harmonics
  5913. */
  5914. lL22: Vector3;
  5915. /**
  5916. * Adds a light to the spherical harmonics
  5917. * @param direction the direction of the light
  5918. * @param color the color of the light
  5919. * @param deltaSolidAngle the delta solid angle of the light
  5920. */
  5921. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5922. /**
  5923. * Scales the spherical harmonics by the given amount
  5924. * @param scale the amount to scale
  5925. */
  5926. scale(scale: number): void;
  5927. /**
  5928. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5929. *
  5930. * ```
  5931. * E_lm = A_l * L_lm
  5932. * ```
  5933. *
  5934. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5935. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5936. * the scaling factors are given in equation 9.
  5937. */
  5938. convertIncidentRadianceToIrradiance(): void;
  5939. /**
  5940. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5941. *
  5942. * ```
  5943. * L = (1/pi) * E * rho
  5944. * ```
  5945. *
  5946. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5947. */
  5948. convertIrradianceToLambertianRadiance(): void;
  5949. /**
  5950. * Gets the spherical harmonics from polynomial
  5951. * @param polynomial the spherical polynomial
  5952. * @returns the spherical harmonics
  5953. */
  5954. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5955. /**
  5956. * Constructs a spherical harmonics from an array.
  5957. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5958. * @returns the spherical harmonics
  5959. */
  5960. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5961. }
  5962. }
  5963. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5964. import { Nullable } from "babylonjs/types";
  5965. /**
  5966. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5967. */
  5968. export interface CubeMapInfo {
  5969. /**
  5970. * The pixel array for the front face.
  5971. * This is stored in format, left to right, up to down format.
  5972. */
  5973. front: Nullable<ArrayBufferView>;
  5974. /**
  5975. * The pixel array for the back face.
  5976. * This is stored in format, left to right, up to down format.
  5977. */
  5978. back: Nullable<ArrayBufferView>;
  5979. /**
  5980. * The pixel array for the left face.
  5981. * This is stored in format, left to right, up to down format.
  5982. */
  5983. left: Nullable<ArrayBufferView>;
  5984. /**
  5985. * The pixel array for the right face.
  5986. * This is stored in format, left to right, up to down format.
  5987. */
  5988. right: Nullable<ArrayBufferView>;
  5989. /**
  5990. * The pixel array for the up face.
  5991. * This is stored in format, left to right, up to down format.
  5992. */
  5993. up: Nullable<ArrayBufferView>;
  5994. /**
  5995. * The pixel array for the down face.
  5996. * This is stored in format, left to right, up to down format.
  5997. */
  5998. down: Nullable<ArrayBufferView>;
  5999. /**
  6000. * The size of the cubemap stored.
  6001. *
  6002. * Each faces will be size * size pixels.
  6003. */
  6004. size: number;
  6005. /**
  6006. * The format of the texture.
  6007. *
  6008. * RGBA, RGB.
  6009. */
  6010. format: number;
  6011. /**
  6012. * The type of the texture data.
  6013. *
  6014. * UNSIGNED_INT, FLOAT.
  6015. */
  6016. type: number;
  6017. /**
  6018. * Specifies whether the texture is in gamma space.
  6019. */
  6020. gammaSpace: boolean;
  6021. }
  6022. /**
  6023. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6024. */
  6025. export class PanoramaToCubeMapTools {
  6026. private static FACE_FRONT;
  6027. private static FACE_BACK;
  6028. private static FACE_RIGHT;
  6029. private static FACE_LEFT;
  6030. private static FACE_DOWN;
  6031. private static FACE_UP;
  6032. /**
  6033. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6034. *
  6035. * @param float32Array The source data.
  6036. * @param inputWidth The width of the input panorama.
  6037. * @param inputHeight The height of the input panorama.
  6038. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6039. * @return The cubemap data
  6040. */
  6041. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6042. private static CreateCubemapTexture;
  6043. private static CalcProjectionSpherical;
  6044. }
  6045. }
  6046. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6047. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6049. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6050. /**
  6051. * Helper class dealing with the extraction of spherical polynomial dataArray
  6052. * from a cube map.
  6053. */
  6054. export class CubeMapToSphericalPolynomialTools {
  6055. private static FileFaces;
  6056. /**
  6057. * Converts a texture to the according Spherical Polynomial data.
  6058. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6059. *
  6060. * @param texture The texture to extract the information from.
  6061. * @return The Spherical Polynomial data.
  6062. */
  6063. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6064. /**
  6065. * Converts a cubemap to the according Spherical Polynomial data.
  6066. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6067. *
  6068. * @param cubeInfo The Cube map to extract the information from.
  6069. * @return The Spherical Polynomial data.
  6070. */
  6071. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6072. }
  6073. }
  6074. declare module "babylonjs/Engines/engineStore" {
  6075. import { Nullable } from "babylonjs/types";
  6076. import { Engine } from "babylonjs/Engines/engine";
  6077. import { Scene } from "babylonjs/scene";
  6078. /**
  6079. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6080. * during the life time of the application.
  6081. */
  6082. export class EngineStore {
  6083. /** Gets the list of created engines */
  6084. static Instances: import("babylonjs/Engines/engine").Engine[];
  6085. /**
  6086. * Gets the latest created engine
  6087. */
  6088. static readonly LastCreatedEngine: Nullable<Engine>;
  6089. /**
  6090. * Gets the latest created scene
  6091. */
  6092. static readonly LastCreatedScene: Nullable<Scene>;
  6093. }
  6094. }
  6095. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6096. /**
  6097. * Define options used to create a render target texture
  6098. */
  6099. export class RenderTargetCreationOptions {
  6100. /**
  6101. * Specifies is mipmaps must be generated
  6102. */
  6103. generateMipMaps?: boolean;
  6104. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6105. generateDepthBuffer?: boolean;
  6106. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6107. generateStencilBuffer?: boolean;
  6108. /** Defines texture type (int by default) */
  6109. type?: number;
  6110. /** Defines sampling mode (trilinear by default) */
  6111. samplingMode?: number;
  6112. /** Defines format (RGBA by default) */
  6113. format?: number;
  6114. }
  6115. }
  6116. declare module "babylonjs/States/alphaCullingState" {
  6117. /**
  6118. * @hidden
  6119. **/
  6120. export class _AlphaState {
  6121. private _isAlphaBlendDirty;
  6122. private _isBlendFunctionParametersDirty;
  6123. private _isBlendEquationParametersDirty;
  6124. private _isBlendConstantsDirty;
  6125. private _alphaBlend;
  6126. private _blendFunctionParameters;
  6127. private _blendEquationParameters;
  6128. private _blendConstants;
  6129. /**
  6130. * Initializes the state.
  6131. */
  6132. constructor();
  6133. readonly isDirty: boolean;
  6134. alphaBlend: boolean;
  6135. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6136. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6137. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6138. reset(): void;
  6139. apply(gl: WebGLRenderingContext): void;
  6140. }
  6141. }
  6142. declare module "babylonjs/States/depthCullingState" {
  6143. import { Nullable } from "babylonjs/types";
  6144. /**
  6145. * @hidden
  6146. **/
  6147. export class _DepthCullingState {
  6148. private _isDepthTestDirty;
  6149. private _isDepthMaskDirty;
  6150. private _isDepthFuncDirty;
  6151. private _isCullFaceDirty;
  6152. private _isCullDirty;
  6153. private _isZOffsetDirty;
  6154. private _isFrontFaceDirty;
  6155. private _depthTest;
  6156. private _depthMask;
  6157. private _depthFunc;
  6158. private _cull;
  6159. private _cullFace;
  6160. private _zOffset;
  6161. private _frontFace;
  6162. /**
  6163. * Initializes the state.
  6164. */
  6165. constructor();
  6166. readonly isDirty: boolean;
  6167. zOffset: number;
  6168. cullFace: Nullable<number>;
  6169. cull: Nullable<boolean>;
  6170. depthFunc: Nullable<number>;
  6171. depthMask: boolean;
  6172. depthTest: boolean;
  6173. frontFace: Nullable<number>;
  6174. reset(): void;
  6175. apply(gl: WebGLRenderingContext): void;
  6176. }
  6177. }
  6178. declare module "babylonjs/States/stencilState" {
  6179. /**
  6180. * @hidden
  6181. **/
  6182. export class _StencilState {
  6183. /** 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 */
  6184. static readonly ALWAYS: number;
  6185. /** Passed to stencilOperation to specify that stencil value must be kept */
  6186. static readonly KEEP: number;
  6187. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6188. static readonly REPLACE: number;
  6189. private _isStencilTestDirty;
  6190. private _isStencilMaskDirty;
  6191. private _isStencilFuncDirty;
  6192. private _isStencilOpDirty;
  6193. private _stencilTest;
  6194. private _stencilMask;
  6195. private _stencilFunc;
  6196. private _stencilFuncRef;
  6197. private _stencilFuncMask;
  6198. private _stencilOpStencilFail;
  6199. private _stencilOpDepthFail;
  6200. private _stencilOpStencilDepthPass;
  6201. readonly isDirty: boolean;
  6202. stencilFunc: number;
  6203. stencilFuncRef: number;
  6204. stencilFuncMask: number;
  6205. stencilOpStencilFail: number;
  6206. stencilOpDepthFail: number;
  6207. stencilOpStencilDepthPass: number;
  6208. stencilMask: number;
  6209. stencilTest: boolean;
  6210. constructor();
  6211. reset(): void;
  6212. apply(gl: WebGLRenderingContext): void;
  6213. }
  6214. }
  6215. declare module "babylonjs/States/index" {
  6216. export * from "babylonjs/States/alphaCullingState";
  6217. export * from "babylonjs/States/depthCullingState";
  6218. export * from "babylonjs/States/stencilState";
  6219. }
  6220. declare module "babylonjs/Instrumentation/timeToken" {
  6221. import { Nullable } from "babylonjs/types";
  6222. /**
  6223. * @hidden
  6224. **/
  6225. export class _TimeToken {
  6226. _startTimeQuery: Nullable<WebGLQuery>;
  6227. _endTimeQuery: Nullable<WebGLQuery>;
  6228. _timeElapsedQuery: Nullable<WebGLQuery>;
  6229. _timeElapsedQueryEnded: boolean;
  6230. }
  6231. }
  6232. declare module "babylonjs/Materials/Textures/internalTexture" {
  6233. import { Observable } from "babylonjs/Misc/observable";
  6234. import { Nullable, int } from "babylonjs/types";
  6235. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6236. import { Engine } from "babylonjs/Engines/engine";
  6237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6238. /**
  6239. * Class used to store data associated with WebGL texture data for the engine
  6240. * This class should not be used directly
  6241. */
  6242. export class InternalTexture {
  6243. /** hidden */
  6244. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6245. /**
  6246. * The source of the texture data is unknown
  6247. */
  6248. static DATASOURCE_UNKNOWN: number;
  6249. /**
  6250. * Texture data comes from an URL
  6251. */
  6252. static DATASOURCE_URL: number;
  6253. /**
  6254. * Texture data is only used for temporary storage
  6255. */
  6256. static DATASOURCE_TEMP: number;
  6257. /**
  6258. * Texture data comes from raw data (ArrayBuffer)
  6259. */
  6260. static DATASOURCE_RAW: number;
  6261. /**
  6262. * Texture content is dynamic (video or dynamic texture)
  6263. */
  6264. static DATASOURCE_DYNAMIC: number;
  6265. /**
  6266. * Texture content is generated by rendering to it
  6267. */
  6268. static DATASOURCE_RENDERTARGET: number;
  6269. /**
  6270. * Texture content is part of a multi render target process
  6271. */
  6272. static DATASOURCE_MULTIRENDERTARGET: number;
  6273. /**
  6274. * Texture data comes from a cube data file
  6275. */
  6276. static DATASOURCE_CUBE: number;
  6277. /**
  6278. * Texture data comes from a raw cube data
  6279. */
  6280. static DATASOURCE_CUBERAW: number;
  6281. /**
  6282. * Texture data come from a prefiltered cube data file
  6283. */
  6284. static DATASOURCE_CUBEPREFILTERED: number;
  6285. /**
  6286. * Texture content is raw 3D data
  6287. */
  6288. static DATASOURCE_RAW3D: number;
  6289. /**
  6290. * Texture content is a depth texture
  6291. */
  6292. static DATASOURCE_DEPTHTEXTURE: number;
  6293. /**
  6294. * Texture data comes from a raw cube data encoded with RGBD
  6295. */
  6296. static DATASOURCE_CUBERAW_RGBD: number;
  6297. /**
  6298. * Defines if the texture is ready
  6299. */
  6300. isReady: boolean;
  6301. /**
  6302. * Defines if the texture is a cube texture
  6303. */
  6304. isCube: boolean;
  6305. /**
  6306. * Defines if the texture contains 3D data
  6307. */
  6308. is3D: boolean;
  6309. /**
  6310. * Defines if the texture contains multiview data
  6311. */
  6312. isMultiview: boolean;
  6313. /**
  6314. * Gets the URL used to load this texture
  6315. */
  6316. url: string;
  6317. /**
  6318. * Gets the sampling mode of the texture
  6319. */
  6320. samplingMode: number;
  6321. /**
  6322. * Gets a boolean indicating if the texture needs mipmaps generation
  6323. */
  6324. generateMipMaps: boolean;
  6325. /**
  6326. * Gets the number of samples used by the texture (WebGL2+ only)
  6327. */
  6328. samples: number;
  6329. /**
  6330. * Gets the type of the texture (int, float...)
  6331. */
  6332. type: number;
  6333. /**
  6334. * Gets the format of the texture (RGB, RGBA...)
  6335. */
  6336. format: number;
  6337. /**
  6338. * Observable called when the texture is loaded
  6339. */
  6340. onLoadedObservable: Observable<InternalTexture>;
  6341. /**
  6342. * Gets the width of the texture
  6343. */
  6344. width: number;
  6345. /**
  6346. * Gets the height of the texture
  6347. */
  6348. height: number;
  6349. /**
  6350. * Gets the depth of the texture
  6351. */
  6352. depth: number;
  6353. /**
  6354. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6355. */
  6356. baseWidth: number;
  6357. /**
  6358. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6359. */
  6360. baseHeight: number;
  6361. /**
  6362. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6363. */
  6364. baseDepth: number;
  6365. /**
  6366. * Gets a boolean indicating if the texture is inverted on Y axis
  6367. */
  6368. invertY: boolean;
  6369. /** @hidden */
  6370. _invertVScale: boolean;
  6371. /** @hidden */
  6372. _associatedChannel: number;
  6373. /** @hidden */
  6374. _dataSource: number;
  6375. /** @hidden */
  6376. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6377. /** @hidden */
  6378. _bufferView: Nullable<ArrayBufferView>;
  6379. /** @hidden */
  6380. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6381. /** @hidden */
  6382. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6383. /** @hidden */
  6384. _size: number;
  6385. /** @hidden */
  6386. _extension: string;
  6387. /** @hidden */
  6388. _files: Nullable<string[]>;
  6389. /** @hidden */
  6390. _workingCanvas: Nullable<HTMLCanvasElement>;
  6391. /** @hidden */
  6392. _workingContext: Nullable<CanvasRenderingContext2D>;
  6393. /** @hidden */
  6394. _framebuffer: Nullable<WebGLFramebuffer>;
  6395. /** @hidden */
  6396. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6397. /** @hidden */
  6398. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6399. /** @hidden */
  6400. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6401. /** @hidden */
  6402. _attachments: Nullable<number[]>;
  6403. /** @hidden */
  6404. _cachedCoordinatesMode: Nullable<number>;
  6405. /** @hidden */
  6406. _cachedWrapU: Nullable<number>;
  6407. /** @hidden */
  6408. _cachedWrapV: Nullable<number>;
  6409. /** @hidden */
  6410. _cachedWrapR: Nullable<number>;
  6411. /** @hidden */
  6412. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6413. /** @hidden */
  6414. _isDisabled: boolean;
  6415. /** @hidden */
  6416. _compression: Nullable<string>;
  6417. /** @hidden */
  6418. _generateStencilBuffer: boolean;
  6419. /** @hidden */
  6420. _generateDepthBuffer: boolean;
  6421. /** @hidden */
  6422. _comparisonFunction: number;
  6423. /** @hidden */
  6424. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6425. /** @hidden */
  6426. _lodGenerationScale: number;
  6427. /** @hidden */
  6428. _lodGenerationOffset: number;
  6429. /** @hidden */
  6430. _colorTextureArray: Nullable<WebGLTexture>;
  6431. /** @hidden */
  6432. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6433. /** @hidden */
  6434. _lodTextureHigh: Nullable<BaseTexture>;
  6435. /** @hidden */
  6436. _lodTextureMid: Nullable<BaseTexture>;
  6437. /** @hidden */
  6438. _lodTextureLow: Nullable<BaseTexture>;
  6439. /** @hidden */
  6440. _isRGBD: boolean;
  6441. /** @hidden */
  6442. _webGLTexture: Nullable<WebGLTexture>;
  6443. /** @hidden */
  6444. _references: number;
  6445. private _engine;
  6446. /**
  6447. * Gets the Engine the texture belongs to.
  6448. * @returns The babylon engine
  6449. */
  6450. getEngine(): Engine;
  6451. /**
  6452. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6453. */
  6454. readonly dataSource: number;
  6455. /**
  6456. * Creates a new InternalTexture
  6457. * @param engine defines the engine to use
  6458. * @param dataSource defines the type of data that will be used
  6459. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6460. */
  6461. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6462. /**
  6463. * Increments the number of references (ie. the number of Texture that point to it)
  6464. */
  6465. incrementReferences(): void;
  6466. /**
  6467. * Change the size of the texture (not the size of the content)
  6468. * @param width defines the new width
  6469. * @param height defines the new height
  6470. * @param depth defines the new depth (1 by default)
  6471. */
  6472. updateSize(width: int, height: int, depth?: int): void;
  6473. /** @hidden */
  6474. _rebuild(): void;
  6475. /** @hidden */
  6476. _swapAndDie(target: InternalTexture): void;
  6477. /**
  6478. * Dispose the current allocated resources
  6479. */
  6480. dispose(): void;
  6481. }
  6482. }
  6483. declare module "babylonjs/Animations/easing" {
  6484. /**
  6485. * This represents the main contract an easing function should follow.
  6486. * Easing functions are used throughout the animation system.
  6487. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6488. */
  6489. export interface IEasingFunction {
  6490. /**
  6491. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6492. * of the easing function.
  6493. * The link below provides some of the most common examples of easing functions.
  6494. * @see https://easings.net/
  6495. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6496. * @returns the corresponding value on the curve defined by the easing function
  6497. */
  6498. ease(gradient: number): number;
  6499. }
  6500. /**
  6501. * Base class used for every default easing function.
  6502. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6503. */
  6504. export class EasingFunction implements IEasingFunction {
  6505. /**
  6506. * Interpolation follows the mathematical formula associated with the easing function.
  6507. */
  6508. static readonly EASINGMODE_EASEIN: number;
  6509. /**
  6510. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6511. */
  6512. static readonly EASINGMODE_EASEOUT: number;
  6513. /**
  6514. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6515. */
  6516. static readonly EASINGMODE_EASEINOUT: number;
  6517. private _easingMode;
  6518. /**
  6519. * Sets the easing mode of the current function.
  6520. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6521. */
  6522. setEasingMode(easingMode: number): void;
  6523. /**
  6524. * Gets the current easing mode.
  6525. * @returns the easing mode
  6526. */
  6527. getEasingMode(): number;
  6528. /**
  6529. * @hidden
  6530. */
  6531. easeInCore(gradient: number): number;
  6532. /**
  6533. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6534. * of the easing function.
  6535. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6536. * @returns the corresponding value on the curve defined by the easing function
  6537. */
  6538. ease(gradient: number): number;
  6539. }
  6540. /**
  6541. * Easing function with a circle shape (see link below).
  6542. * @see https://easings.net/#easeInCirc
  6543. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6544. */
  6545. export class CircleEase extends EasingFunction implements IEasingFunction {
  6546. /** @hidden */
  6547. easeInCore(gradient: number): number;
  6548. }
  6549. /**
  6550. * Easing function with a ease back shape (see link below).
  6551. * @see https://easings.net/#easeInBack
  6552. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6553. */
  6554. export class BackEase extends EasingFunction implements IEasingFunction {
  6555. /** Defines the amplitude of the function */
  6556. amplitude: number;
  6557. /**
  6558. * Instantiates a back ease easing
  6559. * @see https://easings.net/#easeInBack
  6560. * @param amplitude Defines the amplitude of the function
  6561. */
  6562. constructor(
  6563. /** Defines the amplitude of the function */
  6564. amplitude?: number);
  6565. /** @hidden */
  6566. easeInCore(gradient: number): number;
  6567. }
  6568. /**
  6569. * Easing function with a bouncing shape (see link below).
  6570. * @see https://easings.net/#easeInBounce
  6571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6572. */
  6573. export class BounceEase extends EasingFunction implements IEasingFunction {
  6574. /** Defines the number of bounces */
  6575. bounces: number;
  6576. /** Defines the amplitude of the bounce */
  6577. bounciness: number;
  6578. /**
  6579. * Instantiates a bounce easing
  6580. * @see https://easings.net/#easeInBounce
  6581. * @param bounces Defines the number of bounces
  6582. * @param bounciness Defines the amplitude of the bounce
  6583. */
  6584. constructor(
  6585. /** Defines the number of bounces */
  6586. bounces?: number,
  6587. /** Defines the amplitude of the bounce */
  6588. bounciness?: number);
  6589. /** @hidden */
  6590. easeInCore(gradient: number): number;
  6591. }
  6592. /**
  6593. * Easing function with a power of 3 shape (see link below).
  6594. * @see https://easings.net/#easeInCubic
  6595. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6596. */
  6597. export class CubicEase extends EasingFunction implements IEasingFunction {
  6598. /** @hidden */
  6599. easeInCore(gradient: number): number;
  6600. }
  6601. /**
  6602. * Easing function with an elastic shape (see link below).
  6603. * @see https://easings.net/#easeInElastic
  6604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6605. */
  6606. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6607. /** Defines the number of oscillations*/
  6608. oscillations: number;
  6609. /** Defines the amplitude of the oscillations*/
  6610. springiness: number;
  6611. /**
  6612. * Instantiates an elastic easing function
  6613. * @see https://easings.net/#easeInElastic
  6614. * @param oscillations Defines the number of oscillations
  6615. * @param springiness Defines the amplitude of the oscillations
  6616. */
  6617. constructor(
  6618. /** Defines the number of oscillations*/
  6619. oscillations?: number,
  6620. /** Defines the amplitude of the oscillations*/
  6621. springiness?: number);
  6622. /** @hidden */
  6623. easeInCore(gradient: number): number;
  6624. }
  6625. /**
  6626. * Easing function with an exponential shape (see link below).
  6627. * @see https://easings.net/#easeInExpo
  6628. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6629. */
  6630. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6631. /** Defines the exponent of the function */
  6632. exponent: number;
  6633. /**
  6634. * Instantiates an exponential easing function
  6635. * @see https://easings.net/#easeInExpo
  6636. * @param exponent Defines the exponent of the function
  6637. */
  6638. constructor(
  6639. /** Defines the exponent of the function */
  6640. exponent?: number);
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a power shape (see link below).
  6646. * @see https://easings.net/#easeInQuad
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class PowerEase extends EasingFunction implements IEasingFunction {
  6650. /** Defines the power of the function */
  6651. power: number;
  6652. /**
  6653. * Instantiates an power base easing function
  6654. * @see https://easings.net/#easeInQuad
  6655. * @param power Defines the power of the function
  6656. */
  6657. constructor(
  6658. /** Defines the power of the function */
  6659. power?: number);
  6660. /** @hidden */
  6661. easeInCore(gradient: number): number;
  6662. }
  6663. /**
  6664. * Easing function with a power of 2 shape (see link below).
  6665. * @see https://easings.net/#easeInQuad
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6669. /** @hidden */
  6670. easeInCore(gradient: number): number;
  6671. }
  6672. /**
  6673. * Easing function with a power of 4 shape (see link below).
  6674. * @see https://easings.net/#easeInQuart
  6675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6676. */
  6677. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6678. /** @hidden */
  6679. easeInCore(gradient: number): number;
  6680. }
  6681. /**
  6682. * Easing function with a power of 5 shape (see link below).
  6683. * @see https://easings.net/#easeInQuint
  6684. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6685. */
  6686. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6687. /** @hidden */
  6688. easeInCore(gradient: number): number;
  6689. }
  6690. /**
  6691. * Easing function with a sin shape (see link below).
  6692. * @see https://easings.net/#easeInSine
  6693. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6694. */
  6695. export class SineEase extends EasingFunction implements IEasingFunction {
  6696. /** @hidden */
  6697. easeInCore(gradient: number): number;
  6698. }
  6699. /**
  6700. * Easing function with a bezier shape (see link below).
  6701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6702. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6703. */
  6704. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6705. /** Defines the x component of the start tangent in the bezier curve */
  6706. x1: number;
  6707. /** Defines the y component of the start tangent in the bezier curve */
  6708. y1: number;
  6709. /** Defines the x component of the end tangent in the bezier curve */
  6710. x2: number;
  6711. /** Defines the y component of the end tangent in the bezier curve */
  6712. y2: number;
  6713. /**
  6714. * Instantiates a bezier function
  6715. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6716. * @param x1 Defines the x component of the start tangent in the bezier curve
  6717. * @param y1 Defines the y component of the start tangent in the bezier curve
  6718. * @param x2 Defines the x component of the end tangent in the bezier curve
  6719. * @param y2 Defines the y component of the end tangent in the bezier curve
  6720. */
  6721. constructor(
  6722. /** Defines the x component of the start tangent in the bezier curve */
  6723. x1?: number,
  6724. /** Defines the y component of the start tangent in the bezier curve */
  6725. y1?: number,
  6726. /** Defines the x component of the end tangent in the bezier curve */
  6727. x2?: number,
  6728. /** Defines the y component of the end tangent in the bezier curve */
  6729. y2?: number);
  6730. /** @hidden */
  6731. easeInCore(gradient: number): number;
  6732. }
  6733. }
  6734. declare module "babylonjs/Animations/animationKey" {
  6735. /**
  6736. * Defines an interface which represents an animation key frame
  6737. */
  6738. export interface IAnimationKey {
  6739. /**
  6740. * Frame of the key frame
  6741. */
  6742. frame: number;
  6743. /**
  6744. * Value at the specifies key frame
  6745. */
  6746. value: any;
  6747. /**
  6748. * The input tangent for the cubic hermite spline
  6749. */
  6750. inTangent?: any;
  6751. /**
  6752. * The output tangent for the cubic hermite spline
  6753. */
  6754. outTangent?: any;
  6755. /**
  6756. * The animation interpolation type
  6757. */
  6758. interpolation?: AnimationKeyInterpolation;
  6759. }
  6760. /**
  6761. * Enum for the animation key frame interpolation type
  6762. */
  6763. export enum AnimationKeyInterpolation {
  6764. /**
  6765. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6766. */
  6767. STEP = 1
  6768. }
  6769. }
  6770. declare module "babylonjs/Animations/animationRange" {
  6771. /**
  6772. * Represents the range of an animation
  6773. */
  6774. export class AnimationRange {
  6775. /**The name of the animation range**/
  6776. name: string;
  6777. /**The starting frame of the animation */
  6778. from: number;
  6779. /**The ending frame of the animation*/
  6780. to: number;
  6781. /**
  6782. * Initializes the range of an animation
  6783. * @param name The name of the animation range
  6784. * @param from The starting frame of the animation
  6785. * @param to The ending frame of the animation
  6786. */
  6787. constructor(
  6788. /**The name of the animation range**/
  6789. name: string,
  6790. /**The starting frame of the animation */
  6791. from: number,
  6792. /**The ending frame of the animation*/
  6793. to: number);
  6794. /**
  6795. * Makes a copy of the animation range
  6796. * @returns A copy of the animation range
  6797. */
  6798. clone(): AnimationRange;
  6799. }
  6800. }
  6801. declare module "babylonjs/Animations/animationEvent" {
  6802. /**
  6803. * Composed of a frame, and an action function
  6804. */
  6805. export class AnimationEvent {
  6806. /** The frame for which the event is triggered **/
  6807. frame: number;
  6808. /** The event to perform when triggered **/
  6809. action: (currentFrame: number) => void;
  6810. /** Specifies if the event should be triggered only once**/
  6811. onlyOnce?: boolean | undefined;
  6812. /**
  6813. * Specifies if the animation event is done
  6814. */
  6815. isDone: boolean;
  6816. /**
  6817. * Initializes the animation event
  6818. * @param frame The frame for which the event is triggered
  6819. * @param action The event to perform when triggered
  6820. * @param onlyOnce Specifies if the event should be triggered only once
  6821. */
  6822. constructor(
  6823. /** The frame for which the event is triggered **/
  6824. frame: number,
  6825. /** The event to perform when triggered **/
  6826. action: (currentFrame: number) => void,
  6827. /** Specifies if the event should be triggered only once**/
  6828. onlyOnce?: boolean | undefined);
  6829. /** @hidden */
  6830. _clone(): AnimationEvent;
  6831. }
  6832. }
  6833. declare module "babylonjs/Behaviors/behavior" {
  6834. import { Nullable } from "babylonjs/types";
  6835. /**
  6836. * Interface used to define a behavior
  6837. */
  6838. export interface Behavior<T> {
  6839. /** gets or sets behavior's name */
  6840. name: string;
  6841. /**
  6842. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6843. */
  6844. init(): void;
  6845. /**
  6846. * Called when the behavior is attached to a target
  6847. * @param target defines the target where the behavior is attached to
  6848. */
  6849. attach(target: T): void;
  6850. /**
  6851. * Called when the behavior is detached from its target
  6852. */
  6853. detach(): void;
  6854. }
  6855. /**
  6856. * Interface implemented by classes supporting behaviors
  6857. */
  6858. export interface IBehaviorAware<T> {
  6859. /**
  6860. * Attach a behavior
  6861. * @param behavior defines the behavior to attach
  6862. * @returns the current host
  6863. */
  6864. addBehavior(behavior: Behavior<T>): T;
  6865. /**
  6866. * Remove a behavior from the current object
  6867. * @param behavior defines the behavior to detach
  6868. * @returns the current host
  6869. */
  6870. removeBehavior(behavior: Behavior<T>): T;
  6871. /**
  6872. * Gets a behavior using its name to search
  6873. * @param name defines the name to search
  6874. * @returns the behavior or null if not found
  6875. */
  6876. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6877. }
  6878. }
  6879. declare module "babylonjs/Collisions/intersectionInfo" {
  6880. import { Nullable } from "babylonjs/types";
  6881. /**
  6882. * @hidden
  6883. */
  6884. export class IntersectionInfo {
  6885. bu: Nullable<number>;
  6886. bv: Nullable<number>;
  6887. distance: number;
  6888. faceId: number;
  6889. subMeshId: number;
  6890. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6891. }
  6892. }
  6893. declare module "babylonjs/Culling/boundingSphere" {
  6894. import { DeepImmutable } from "babylonjs/types";
  6895. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6896. /**
  6897. * Class used to store bounding sphere information
  6898. */
  6899. export class BoundingSphere {
  6900. /**
  6901. * Gets the center of the bounding sphere in local space
  6902. */
  6903. readonly center: Vector3;
  6904. /**
  6905. * Radius of the bounding sphere in local space
  6906. */
  6907. radius: number;
  6908. /**
  6909. * Gets the center of the bounding sphere in world space
  6910. */
  6911. readonly centerWorld: Vector3;
  6912. /**
  6913. * Radius of the bounding sphere in world space
  6914. */
  6915. radiusWorld: number;
  6916. /**
  6917. * Gets the minimum vector in local space
  6918. */
  6919. readonly minimum: Vector3;
  6920. /**
  6921. * Gets the maximum vector in local space
  6922. */
  6923. readonly maximum: Vector3;
  6924. private _worldMatrix;
  6925. private static readonly TmpVector3;
  6926. /**
  6927. * Creates a new bounding sphere
  6928. * @param min defines the minimum vector (in local space)
  6929. * @param max defines the maximum vector (in local space)
  6930. * @param worldMatrix defines the new world matrix
  6931. */
  6932. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6933. /**
  6934. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6935. * @param min defines the new minimum vector (in local space)
  6936. * @param max defines the new maximum vector (in local space)
  6937. * @param worldMatrix defines the new world matrix
  6938. */
  6939. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6940. /**
  6941. * Scale the current bounding sphere by applying a scale factor
  6942. * @param factor defines the scale factor to apply
  6943. * @returns the current bounding box
  6944. */
  6945. scale(factor: number): BoundingSphere;
  6946. /**
  6947. * Gets the world matrix of the bounding box
  6948. * @returns a matrix
  6949. */
  6950. getWorldMatrix(): DeepImmutable<Matrix>;
  6951. /** @hidden */
  6952. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Tests if the bounding sphere is intersecting the frustum planes
  6955. * @param frustumPlanes defines the frustum planes to test
  6956. * @returns true if there is an intersection
  6957. */
  6958. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6959. /**
  6960. * Tests if the bounding sphere center is in between the frustum planes.
  6961. * Used for optimistic fast inclusion.
  6962. * @param frustumPlanes defines the frustum planes to test
  6963. * @returns true if the sphere center is in between the frustum planes
  6964. */
  6965. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6966. /**
  6967. * Tests if a point is inside the bounding sphere
  6968. * @param point defines the point to test
  6969. * @returns true if the point is inside the bounding sphere
  6970. */
  6971. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6972. /**
  6973. * Checks if two sphere intersct
  6974. * @param sphere0 sphere 0
  6975. * @param sphere1 sphere 1
  6976. * @returns true if the speres intersect
  6977. */
  6978. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6979. }
  6980. }
  6981. declare module "babylonjs/Culling/boundingBox" {
  6982. import { DeepImmutable } from "babylonjs/types";
  6983. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6984. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6985. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6986. /**
  6987. * Class used to store bounding box information
  6988. */
  6989. export class BoundingBox implements ICullable {
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in local space
  6992. */
  6993. readonly vectors: Vector3[];
  6994. /**
  6995. * Gets the center of the bounding box in local space
  6996. */
  6997. readonly center: Vector3;
  6998. /**
  6999. * Gets the center of the bounding box in world space
  7000. */
  7001. readonly centerWorld: Vector3;
  7002. /**
  7003. * Gets the extend size in local space
  7004. */
  7005. readonly extendSize: Vector3;
  7006. /**
  7007. * Gets the extend size in world space
  7008. */
  7009. readonly extendSizeWorld: Vector3;
  7010. /**
  7011. * Gets the OBB (object bounding box) directions
  7012. */
  7013. readonly directions: Vector3[];
  7014. /**
  7015. * Gets the 8 vectors representing the bounding box in world space
  7016. */
  7017. readonly vectorsWorld: Vector3[];
  7018. /**
  7019. * Gets the minimum vector in world space
  7020. */
  7021. readonly minimumWorld: Vector3;
  7022. /**
  7023. * Gets the maximum vector in world space
  7024. */
  7025. readonly maximumWorld: Vector3;
  7026. /**
  7027. * Gets the minimum vector in local space
  7028. */
  7029. readonly minimum: Vector3;
  7030. /**
  7031. * Gets the maximum vector in local space
  7032. */
  7033. readonly maximum: Vector3;
  7034. private _worldMatrix;
  7035. private static readonly TmpVector3;
  7036. /**
  7037. * @hidden
  7038. */
  7039. _tag: number;
  7040. /**
  7041. * Creates a new bounding box
  7042. * @param min defines the minimum vector (in local space)
  7043. * @param max defines the maximum vector (in local space)
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * Scale the current bounding box by applying a scale factor
  7056. * @param factor defines the scale factor to apply
  7057. * @returns the current bounding box
  7058. */
  7059. scale(factor: number): BoundingBox;
  7060. /**
  7061. * Gets the world matrix of the bounding box
  7062. * @returns a matrix
  7063. */
  7064. getWorldMatrix(): DeepImmutable<Matrix>;
  7065. /** @hidden */
  7066. _update(world: DeepImmutable<Matrix>): void;
  7067. /**
  7068. * Tests if the bounding box is intersecting the frustum planes
  7069. * @param frustumPlanes defines the frustum planes to test
  7070. * @returns true if there is an intersection
  7071. */
  7072. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7073. /**
  7074. * Tests if the bounding box is entirely inside the frustum planes
  7075. * @param frustumPlanes defines the frustum planes to test
  7076. * @returns true if there is an inclusion
  7077. */
  7078. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7079. /**
  7080. * Tests if a point is inside the bounding box
  7081. * @param point defines the point to test
  7082. * @returns true if the point is inside the bounding box
  7083. */
  7084. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7085. /**
  7086. * Tests if the bounding box intersects with a bounding sphere
  7087. * @param sphere defines the sphere to test
  7088. * @returns true if there is an intersection
  7089. */
  7090. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7091. /**
  7092. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7093. * @param min defines the min vector to use
  7094. * @param max defines the max vector to use
  7095. * @returns true if there is an intersection
  7096. */
  7097. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7098. /**
  7099. * Tests if two bounding boxes are intersections
  7100. * @param box0 defines the first box to test
  7101. * @param box1 defines the second box to test
  7102. * @returns true if there is an intersection
  7103. */
  7104. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7105. /**
  7106. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7107. * @param minPoint defines the minimum vector of the bounding box
  7108. * @param maxPoint defines the maximum vector of the bounding box
  7109. * @param sphereCenter defines the sphere center
  7110. * @param sphereRadius defines the sphere radius
  7111. * @returns true if there is an intersection
  7112. */
  7113. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7114. /**
  7115. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7116. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @return true if there is an inclusion
  7119. */
  7120. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /**
  7122. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7123. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7124. * @param frustumPlanes defines the frustum planes to test
  7125. * @return true if there is an intersection
  7126. */
  7127. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Collisions/collider" {
  7131. import { Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector3, Plane } from "babylonjs/Maths/math";
  7133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7134. /** @hidden */
  7135. export class Collider {
  7136. /** Define if a collision was found */
  7137. collisionFound: boolean;
  7138. /**
  7139. * Define last intersection point in local space
  7140. */
  7141. intersectionPoint: Vector3;
  7142. /**
  7143. * Define last collided mesh
  7144. */
  7145. collidedMesh: Nullable<AbstractMesh>;
  7146. private _collisionPoint;
  7147. private _planeIntersectionPoint;
  7148. private _tempVector;
  7149. private _tempVector2;
  7150. private _tempVector3;
  7151. private _tempVector4;
  7152. private _edge;
  7153. private _baseToVertex;
  7154. private _destinationPoint;
  7155. private _slidePlaneNormal;
  7156. private _displacementVector;
  7157. /** @hidden */
  7158. _radius: Vector3;
  7159. /** @hidden */
  7160. _retry: number;
  7161. private _velocity;
  7162. private _basePoint;
  7163. private _epsilon;
  7164. /** @hidden */
  7165. _velocityWorldLength: number;
  7166. /** @hidden */
  7167. _basePointWorld: Vector3;
  7168. private _velocityWorld;
  7169. private _normalizedVelocity;
  7170. /** @hidden */
  7171. _initialVelocity: Vector3;
  7172. /** @hidden */
  7173. _initialPosition: Vector3;
  7174. private _nearestDistance;
  7175. private _collisionMask;
  7176. collisionMask: number;
  7177. /**
  7178. * Gets the plane normal used to compute the sliding response (in local space)
  7179. */
  7180. readonly slidePlaneNormal: Vector3;
  7181. /** @hidden */
  7182. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7183. /** @hidden */
  7184. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7185. /** @hidden */
  7186. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7187. /** @hidden */
  7188. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7189. /** @hidden */
  7190. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7191. /** @hidden */
  7192. _getResponse(pos: Vector3, vel: Vector3): void;
  7193. }
  7194. }
  7195. declare module "babylonjs/Culling/boundingInfo" {
  7196. import { DeepImmutable } from "babylonjs/types";
  7197. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7198. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7199. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7200. import { Collider } from "babylonjs/Collisions/collider";
  7201. /**
  7202. * Interface for cullable objects
  7203. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7204. */
  7205. export interface ICullable {
  7206. /**
  7207. * Checks if the object or part of the object is in the frustum
  7208. * @param frustumPlanes Camera near/planes
  7209. * @returns true if the object is in frustum otherwise false
  7210. */
  7211. isInFrustum(frustumPlanes: Plane[]): boolean;
  7212. /**
  7213. * Checks if a cullable object (mesh...) is in the camera frustum
  7214. * Unlike isInFrustum this cheks the full bounding box
  7215. * @param frustumPlanes Camera near/planes
  7216. * @returns true if the object is in frustum otherwise false
  7217. */
  7218. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7219. }
  7220. /**
  7221. * Info for a bounding data of a mesh
  7222. */
  7223. export class BoundingInfo implements ICullable {
  7224. /**
  7225. * Bounding box for the mesh
  7226. */
  7227. readonly boundingBox: BoundingBox;
  7228. /**
  7229. * Bounding sphere for the mesh
  7230. */
  7231. readonly boundingSphere: BoundingSphere;
  7232. private _isLocked;
  7233. private static readonly TmpVector3;
  7234. /**
  7235. * Constructs bounding info
  7236. * @param minimum min vector of the bounding box/sphere
  7237. * @param maximum max vector of the bounding box/sphere
  7238. * @param worldMatrix defines the new world matrix
  7239. */
  7240. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7241. /**
  7242. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7243. * @param min defines the new minimum vector (in local space)
  7244. * @param max defines the new maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7248. /**
  7249. * min vector of the bounding box/sphere
  7250. */
  7251. readonly minimum: Vector3;
  7252. /**
  7253. * max vector of the bounding box/sphere
  7254. */
  7255. readonly maximum: Vector3;
  7256. /**
  7257. * If the info is locked and won't be updated to avoid perf overhead
  7258. */
  7259. isLocked: boolean;
  7260. /**
  7261. * Updates the bounding sphere and box
  7262. * @param world world matrix to be used to update
  7263. */
  7264. update(world: DeepImmutable<Matrix>): void;
  7265. /**
  7266. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7267. * @param center New center of the bounding info
  7268. * @param extend New extend of the bounding info
  7269. * @returns the current bounding info
  7270. */
  7271. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7272. /**
  7273. * Scale the current bounding info by applying a scale factor
  7274. * @param factor defines the scale factor to apply
  7275. * @returns the current bounding info
  7276. */
  7277. scale(factor: number): BoundingInfo;
  7278. /**
  7279. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7280. * @param frustumPlanes defines the frustum to test
  7281. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7282. * @returns true if the bounding info is in the frustum planes
  7283. */
  7284. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7285. /**
  7286. * Gets the world distance between the min and max points of the bounding box
  7287. */
  7288. readonly diagonalLength: number;
  7289. /**
  7290. * Checks if a cullable object (mesh...) is in the camera frustum
  7291. * Unlike isInFrustum this cheks the full bounding box
  7292. * @param frustumPlanes Camera near/planes
  7293. * @returns true if the object is in frustum otherwise false
  7294. */
  7295. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7296. /** @hidden */
  7297. _checkCollision(collider: Collider): boolean;
  7298. /**
  7299. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7300. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7301. * @param point the point to check intersection with
  7302. * @returns if the point intersects
  7303. */
  7304. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7305. /**
  7306. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7307. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7308. * @param boundingInfo the bounding info to check intersection with
  7309. * @param precise if the intersection should be done using OBB
  7310. * @returns if the bounding info intersects
  7311. */
  7312. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7313. }
  7314. }
  7315. declare module "babylonjs/Misc/smartArray" {
  7316. /**
  7317. * Defines an array and its length.
  7318. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7319. */
  7320. export interface ISmartArrayLike<T> {
  7321. /**
  7322. * The data of the array.
  7323. */
  7324. data: Array<T>;
  7325. /**
  7326. * The active length of the array.
  7327. */
  7328. length: number;
  7329. }
  7330. /**
  7331. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7332. */
  7333. export class SmartArray<T> implements ISmartArrayLike<T> {
  7334. /**
  7335. * The full set of data from the array.
  7336. */
  7337. data: Array<T>;
  7338. /**
  7339. * The active length of the array.
  7340. */
  7341. length: number;
  7342. protected _id: number;
  7343. /**
  7344. * Instantiates a Smart Array.
  7345. * @param capacity defines the default capacity of the array.
  7346. */
  7347. constructor(capacity: number);
  7348. /**
  7349. * Pushes a value at the end of the active data.
  7350. * @param value defines the object to push in the array.
  7351. */
  7352. push(value: T): void;
  7353. /**
  7354. * Iterates over the active data and apply the lambda to them.
  7355. * @param func defines the action to apply on each value.
  7356. */
  7357. forEach(func: (content: T) => void): void;
  7358. /**
  7359. * Sorts the full sets of data.
  7360. * @param compareFn defines the comparison function to apply.
  7361. */
  7362. sort(compareFn: (a: T, b: T) => number): void;
  7363. /**
  7364. * Resets the active data to an empty array.
  7365. */
  7366. reset(): void;
  7367. /**
  7368. * Releases all the data from the array as well as the array.
  7369. */
  7370. dispose(): void;
  7371. /**
  7372. * Concats the active data with a given array.
  7373. * @param array defines the data to concatenate with.
  7374. */
  7375. concat(array: any): void;
  7376. /**
  7377. * Returns the position of a value in the active data.
  7378. * @param value defines the value to find the index for
  7379. * @returns the index if found in the active data otherwise -1
  7380. */
  7381. indexOf(value: T): number;
  7382. /**
  7383. * Returns whether an element is part of the active data.
  7384. * @param value defines the value to look for
  7385. * @returns true if found in the active data otherwise false
  7386. */
  7387. contains(value: T): boolean;
  7388. private static _GlobalId;
  7389. }
  7390. /**
  7391. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7392. * The data in this array can only be present once
  7393. */
  7394. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7395. private _duplicateId;
  7396. /**
  7397. * Pushes a value at the end of the active data.
  7398. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7399. * @param value defines the object to push in the array.
  7400. */
  7401. push(value: T): void;
  7402. /**
  7403. * Pushes a value at the end of the active data.
  7404. * If the data is already present, it won t be added again
  7405. * @param value defines the object to push in the array.
  7406. * @returns true if added false if it was already present
  7407. */
  7408. pushNoDuplicate(value: T): boolean;
  7409. /**
  7410. * Resets the active data to an empty array.
  7411. */
  7412. reset(): void;
  7413. /**
  7414. * Concats the active data with a given array.
  7415. * This ensures no dupplicate will be present in the result.
  7416. * @param array defines the data to concatenate with.
  7417. */
  7418. concatWithNoDuplicate(array: any): void;
  7419. }
  7420. }
  7421. declare module "babylonjs/Materials/multiMaterial" {
  7422. import { Nullable } from "babylonjs/types";
  7423. import { Scene } from "babylonjs/scene";
  7424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7425. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7427. import { Material } from "babylonjs/Materials/material";
  7428. /**
  7429. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7430. * separate meshes. This can be use to improve performances.
  7431. * @see http://doc.babylonjs.com/how_to/multi_materials
  7432. */
  7433. export class MultiMaterial extends Material {
  7434. private _subMaterials;
  7435. /**
  7436. * Gets or Sets the list of Materials used within the multi material.
  7437. * They need to be ordered according to the submeshes order in the associated mesh
  7438. */
  7439. subMaterials: Nullable<Material>[];
  7440. /**
  7441. * Function used to align with Node.getChildren()
  7442. * @returns the list of Materials used within the multi material
  7443. */
  7444. getChildren(): Nullable<Material>[];
  7445. /**
  7446. * Instantiates a new Multi Material
  7447. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7448. * separate meshes. This can be use to improve performances.
  7449. * @see http://doc.babylonjs.com/how_to/multi_materials
  7450. * @param name Define the name in the scene
  7451. * @param scene Define the scene the material belongs to
  7452. */
  7453. constructor(name: string, scene: Scene);
  7454. private _hookArray;
  7455. /**
  7456. * Get one of the submaterial by its index in the submaterials array
  7457. * @param index The index to look the sub material at
  7458. * @returns The Material if the index has been defined
  7459. */
  7460. getSubMaterial(index: number): Nullable<Material>;
  7461. /**
  7462. * Get the list of active textures for the whole sub materials list.
  7463. * @returns All the textures that will be used during the rendering
  7464. */
  7465. getActiveTextures(): BaseTexture[];
  7466. /**
  7467. * Gets the current class name of the material e.g. "MultiMaterial"
  7468. * Mainly use in serialization.
  7469. * @returns the class name
  7470. */
  7471. getClassName(): string;
  7472. /**
  7473. * Checks if the material is ready to render the requested sub mesh
  7474. * @param mesh Define the mesh the submesh belongs to
  7475. * @param subMesh Define the sub mesh to look readyness for
  7476. * @param useInstances Define whether or not the material is used with instances
  7477. * @returns true if ready, otherwise false
  7478. */
  7479. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7480. /**
  7481. * Clones the current material and its related sub materials
  7482. * @param name Define the name of the newly cloned material
  7483. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7484. * @returns the cloned material
  7485. */
  7486. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7487. /**
  7488. * Serializes the materials into a JSON representation.
  7489. * @returns the JSON representation
  7490. */
  7491. serialize(): any;
  7492. /**
  7493. * Dispose the material and release its associated resources
  7494. * @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)
  7495. * @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)
  7496. * @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)
  7497. */
  7498. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7499. /**
  7500. * Creates a MultiMaterial from parsed MultiMaterial data.
  7501. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7502. * @param scene defines the hosting scene
  7503. * @returns a new MultiMaterial
  7504. */
  7505. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7506. }
  7507. }
  7508. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7509. /**
  7510. * Class used to represent data loading progression
  7511. */
  7512. export class SceneLoaderFlags {
  7513. private static _ForceFullSceneLoadingForIncremental;
  7514. private static _ShowLoadingScreen;
  7515. private static _CleanBoneMatrixWeights;
  7516. private static _loggingLevel;
  7517. /**
  7518. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7519. */
  7520. static ForceFullSceneLoadingForIncremental: boolean;
  7521. /**
  7522. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7523. */
  7524. static ShowLoadingScreen: boolean;
  7525. /**
  7526. * Defines the current logging level (while loading the scene)
  7527. * @ignorenaming
  7528. */
  7529. static loggingLevel: number;
  7530. /**
  7531. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7532. */
  7533. static CleanBoneMatrixWeights: boolean;
  7534. }
  7535. }
  7536. declare module "babylonjs/Meshes/transformNode" {
  7537. import { DeepImmutable } from "babylonjs/types";
  7538. import { Observable } from "babylonjs/Misc/observable";
  7539. import { Nullable } from "babylonjs/types";
  7540. import { Camera } from "babylonjs/Cameras/camera";
  7541. import { Scene } from "babylonjs/scene";
  7542. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7543. import { Node } from "babylonjs/node";
  7544. import { Bone } from "babylonjs/Bones/bone";
  7545. /**
  7546. * 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.
  7547. * @see https://doc.babylonjs.com/how_to/transformnode
  7548. */
  7549. export class TransformNode extends Node {
  7550. /**
  7551. * Object will not rotate to face the camera
  7552. */
  7553. static BILLBOARDMODE_NONE: number;
  7554. /**
  7555. * Object will rotate to face the camera but only on the x axis
  7556. */
  7557. static BILLBOARDMODE_X: number;
  7558. /**
  7559. * Object will rotate to face the camera but only on the y axis
  7560. */
  7561. static BILLBOARDMODE_Y: number;
  7562. /**
  7563. * Object will rotate to face the camera but only on the z axis
  7564. */
  7565. static BILLBOARDMODE_Z: number;
  7566. /**
  7567. * Object will rotate to face the camera
  7568. */
  7569. static BILLBOARDMODE_ALL: number;
  7570. private _forward;
  7571. private _forwardInverted;
  7572. private _up;
  7573. private _right;
  7574. private _rightInverted;
  7575. private _position;
  7576. private _rotation;
  7577. private _rotationQuaternion;
  7578. protected _scaling: Vector3;
  7579. protected _isDirty: boolean;
  7580. private _transformToBoneReferal;
  7581. private _billboardMode;
  7582. /**
  7583. * Gets or sets the billboard mode. Default is 0.
  7584. *
  7585. * | Value | Type | Description |
  7586. * | --- | --- | --- |
  7587. * | 0 | BILLBOARDMODE_NONE | |
  7588. * | 1 | BILLBOARDMODE_X | |
  7589. * | 2 | BILLBOARDMODE_Y | |
  7590. * | 4 | BILLBOARDMODE_Z | |
  7591. * | 7 | BILLBOARDMODE_ALL | |
  7592. *
  7593. */
  7594. billboardMode: number;
  7595. private _preserveParentRotationForBillboard;
  7596. /**
  7597. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7598. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7599. */
  7600. preserveParentRotationForBillboard: boolean;
  7601. /**
  7602. * 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
  7603. */
  7604. scalingDeterminant: number;
  7605. private _infiniteDistance;
  7606. /**
  7607. * Gets or sets the distance of the object to max, often used by skybox
  7608. */
  7609. infiniteDistance: boolean;
  7610. /**
  7611. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7612. * By default the system will update normals to compensate
  7613. */
  7614. ignoreNonUniformScaling: boolean;
  7615. /**
  7616. * 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
  7617. */
  7618. reIntegrateRotationIntoRotationQuaternion: boolean;
  7619. /** @hidden */
  7620. _poseMatrix: Nullable<Matrix>;
  7621. /** @hidden */
  7622. _localMatrix: Matrix;
  7623. private _usePivotMatrix;
  7624. private _absolutePosition;
  7625. private _pivotMatrix;
  7626. private _pivotMatrixInverse;
  7627. protected _postMultiplyPivotMatrix: boolean;
  7628. protected _isWorldMatrixFrozen: boolean;
  7629. /** @hidden */
  7630. _indexInSceneTransformNodesArray: number;
  7631. /**
  7632. * An event triggered after the world matrix is updated
  7633. */
  7634. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7635. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7636. /**
  7637. * Gets a string identifying the name of the class
  7638. * @returns "TransformNode" string
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7643. */
  7644. position: Vector3;
  7645. /**
  7646. * 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)).
  7647. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7648. */
  7649. rotation: Vector3;
  7650. /**
  7651. * 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)).
  7652. */
  7653. scaling: Vector3;
  7654. /**
  7655. * 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).
  7656. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7657. */
  7658. rotationQuaternion: Nullable<Quaternion>;
  7659. /**
  7660. * The forward direction of that transform in world space.
  7661. */
  7662. readonly forward: Vector3;
  7663. /**
  7664. * The up direction of that transform in world space.
  7665. */
  7666. readonly up: Vector3;
  7667. /**
  7668. * The right direction of that transform in world space.
  7669. */
  7670. readonly right: Vector3;
  7671. /**
  7672. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7673. * @param matrix the matrix to copy the pose from
  7674. * @returns this TransformNode.
  7675. */
  7676. updatePoseMatrix(matrix: Matrix): TransformNode;
  7677. /**
  7678. * Returns the mesh Pose matrix.
  7679. * @returns the pose matrix
  7680. */
  7681. getPoseMatrix(): Matrix;
  7682. /** @hidden */
  7683. _isSynchronized(): boolean;
  7684. /** @hidden */
  7685. _initCache(): void;
  7686. /**
  7687. * Flag the transform node as dirty (Forcing it to update everything)
  7688. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7689. * @returns this transform node
  7690. */
  7691. markAsDirty(property: string): TransformNode;
  7692. /**
  7693. * Returns the current mesh absolute position.
  7694. * Returns a Vector3.
  7695. */
  7696. readonly absolutePosition: Vector3;
  7697. /**
  7698. * Sets a new matrix to apply before all other transformation
  7699. * @param matrix defines the transform matrix
  7700. * @returns the current TransformNode
  7701. */
  7702. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7703. /**
  7704. * Sets a new pivot matrix to the current node
  7705. * @param matrix defines the new pivot matrix to use
  7706. * @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
  7707. * @returns the current TransformNode
  7708. */
  7709. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7710. /**
  7711. * Returns the mesh pivot matrix.
  7712. * Default : Identity.
  7713. * @returns the matrix
  7714. */
  7715. getPivotMatrix(): Matrix;
  7716. /**
  7717. * Prevents the World matrix to be computed any longer.
  7718. * @returns the TransformNode.
  7719. */
  7720. freezeWorldMatrix(): TransformNode;
  7721. /**
  7722. * Allows back the World matrix computation.
  7723. * @returns the TransformNode.
  7724. */
  7725. unfreezeWorldMatrix(): this;
  7726. /**
  7727. * True if the World matrix has been frozen.
  7728. */
  7729. readonly isWorldMatrixFrozen: boolean;
  7730. /**
  7731. * Retuns the mesh absolute position in the World.
  7732. * @returns a Vector3.
  7733. */
  7734. getAbsolutePosition(): Vector3;
  7735. /**
  7736. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7737. * @param absolutePosition the absolute position to set
  7738. * @returns the TransformNode.
  7739. */
  7740. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7741. /**
  7742. * Sets the mesh position in its local space.
  7743. * @param vector3 the position to set in localspace
  7744. * @returns the TransformNode.
  7745. */
  7746. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7747. /**
  7748. * Returns the mesh position in the local space from the current World matrix values.
  7749. * @returns a new Vector3.
  7750. */
  7751. getPositionExpressedInLocalSpace(): Vector3;
  7752. /**
  7753. * Translates the mesh along the passed Vector3 in its local space.
  7754. * @param vector3 the distance to translate in localspace
  7755. * @returns the TransformNode.
  7756. */
  7757. locallyTranslate(vector3: Vector3): TransformNode;
  7758. private static _lookAtVectorCache;
  7759. /**
  7760. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7761. * @param targetPoint the position (must be in same space as current mesh) to look at
  7762. * @param yawCor optional yaw (y-axis) correction in radians
  7763. * @param pitchCor optional pitch (x-axis) correction in radians
  7764. * @param rollCor optional roll (z-axis) correction in radians
  7765. * @param space the choosen space of the target
  7766. * @returns the TransformNode.
  7767. */
  7768. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7769. /**
  7770. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7771. * This Vector3 is expressed in the World space.
  7772. * @param localAxis axis to rotate
  7773. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7774. */
  7775. getDirection(localAxis: Vector3): Vector3;
  7776. /**
  7777. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7778. * localAxis is expressed in the mesh local space.
  7779. * result is computed in the Wordl space from the mesh World matrix.
  7780. * @param localAxis axis to rotate
  7781. * @param result the resulting transformnode
  7782. * @returns this TransformNode.
  7783. */
  7784. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7785. /**
  7786. * Sets this transform node rotation to the given local axis.
  7787. * @param localAxis the axis in local space
  7788. * @param yawCor optional yaw (y-axis) correction in radians
  7789. * @param pitchCor optional pitch (x-axis) correction in radians
  7790. * @param rollCor optional roll (z-axis) correction in radians
  7791. * @returns this TransformNode
  7792. */
  7793. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7794. /**
  7795. * Sets a new pivot point to the current node
  7796. * @param point defines the new pivot point to use
  7797. * @param space defines if the point is in world or local space (local by default)
  7798. * @returns the current TransformNode
  7799. */
  7800. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7801. /**
  7802. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7803. * @returns the pivot point
  7804. */
  7805. getPivotPoint(): Vector3;
  7806. /**
  7807. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7808. * @param result the vector3 to store the result
  7809. * @returns this TransformNode.
  7810. */
  7811. getPivotPointToRef(result: Vector3): TransformNode;
  7812. /**
  7813. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7814. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7815. */
  7816. getAbsolutePivotPoint(): Vector3;
  7817. /**
  7818. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7819. * @param result vector3 to store the result
  7820. * @returns this TransformNode.
  7821. */
  7822. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7823. /**
  7824. * Defines the passed node as the parent of the current node.
  7825. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7826. * @see https://doc.babylonjs.com/how_to/parenting
  7827. * @param node the node ot set as the parent
  7828. * @returns this TransformNode.
  7829. */
  7830. setParent(node: Nullable<Node>): TransformNode;
  7831. private _nonUniformScaling;
  7832. /**
  7833. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7834. */
  7835. readonly nonUniformScaling: boolean;
  7836. /** @hidden */
  7837. _updateNonUniformScalingState(value: boolean): boolean;
  7838. /**
  7839. * Attach the current TransformNode to another TransformNode associated with a bone
  7840. * @param bone Bone affecting the TransformNode
  7841. * @param affectedTransformNode TransformNode associated with the bone
  7842. * @returns this object
  7843. */
  7844. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7845. /**
  7846. * Detach the transform node if its associated with a bone
  7847. * @returns this object
  7848. */
  7849. detachFromBone(): TransformNode;
  7850. private static _rotationAxisCache;
  7851. /**
  7852. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7853. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7854. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7855. * The passed axis is also normalized.
  7856. * @param axis the axis to rotate around
  7857. * @param amount the amount to rotate in radians
  7858. * @param space Space to rotate in (Default: local)
  7859. * @returns the TransformNode.
  7860. */
  7861. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7862. /**
  7863. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7864. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7865. * The passed axis is also normalized. .
  7866. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7867. * @param point the point to rotate around
  7868. * @param axis the axis to rotate around
  7869. * @param amount the amount to rotate in radians
  7870. * @returns the TransformNode
  7871. */
  7872. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7873. /**
  7874. * Translates the mesh along the axis vector for the passed distance in the given space.
  7875. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7876. * @param axis the axis to translate in
  7877. * @param distance the distance to translate
  7878. * @param space Space to rotate in (Default: local)
  7879. * @returns the TransformNode.
  7880. */
  7881. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7882. /**
  7883. * Adds a rotation step to the mesh current rotation.
  7884. * x, y, z are Euler angles expressed in radians.
  7885. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7886. * This means this rotation is made in the mesh local space only.
  7887. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7888. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7889. * ```javascript
  7890. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7891. * ```
  7892. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7893. * 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.
  7894. * @param x Rotation to add
  7895. * @param y Rotation to add
  7896. * @param z Rotation to add
  7897. * @returns the TransformNode.
  7898. */
  7899. addRotation(x: number, y: number, z: number): TransformNode;
  7900. /**
  7901. * @hidden
  7902. */
  7903. protected _getEffectiveParent(): Nullable<Node>;
  7904. /**
  7905. * Computes the world matrix of the node
  7906. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7907. * @returns the world matrix
  7908. */
  7909. computeWorldMatrix(force?: boolean): Matrix;
  7910. protected _afterComputeWorldMatrix(): void;
  7911. /**
  7912. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7913. * @param func callback function to add
  7914. *
  7915. * @returns the TransformNode.
  7916. */
  7917. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7918. /**
  7919. * Removes a registered callback function.
  7920. * @param func callback function to remove
  7921. * @returns the TransformNode.
  7922. */
  7923. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7924. /**
  7925. * Gets the position of the current mesh in camera space
  7926. * @param camera defines the camera to use
  7927. * @returns a position
  7928. */
  7929. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7930. /**
  7931. * Returns the distance from the mesh to the active camera
  7932. * @param camera defines the camera to use
  7933. * @returns the distance
  7934. */
  7935. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7936. /**
  7937. * Clone the current transform node
  7938. * @param name Name of the new clone
  7939. * @param newParent New parent for the clone
  7940. * @param doNotCloneChildren Do not clone children hierarchy
  7941. * @returns the new transform node
  7942. */
  7943. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7944. /**
  7945. * Serializes the objects information.
  7946. * @param currentSerializationObject defines the object to serialize in
  7947. * @returns the serialized object
  7948. */
  7949. serialize(currentSerializationObject?: any): any;
  7950. /**
  7951. * Returns a new TransformNode object parsed from the source provided.
  7952. * @param parsedTransformNode is the source.
  7953. * @param scene the scne the object belongs to
  7954. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7955. * @returns a new TransformNode object parsed from the source provided.
  7956. */
  7957. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7958. /**
  7959. * Get all child-transformNodes of this node
  7960. * @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
  7961. * @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
  7962. * @returns an array of TransformNode
  7963. */
  7964. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7965. /**
  7966. * Releases resources associated with this transform node.
  7967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7969. */
  7970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7971. }
  7972. }
  7973. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7974. /**
  7975. * Class used to override all child animations of a given target
  7976. */
  7977. export class AnimationPropertiesOverride {
  7978. /**
  7979. * Gets or sets a value indicating if animation blending must be used
  7980. */
  7981. enableBlending: boolean;
  7982. /**
  7983. * Gets or sets the blending speed to use when enableBlending is true
  7984. */
  7985. blendingSpeed: number;
  7986. /**
  7987. * Gets or sets the default loop mode to use
  7988. */
  7989. loopMode: number;
  7990. }
  7991. }
  7992. declare module "babylonjs/Bones/bone" {
  7993. import { Skeleton } from "babylonjs/Bones/skeleton";
  7994. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7995. import { Nullable } from "babylonjs/types";
  7996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7997. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7998. import { Node } from "babylonjs/node";
  7999. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8000. /**
  8001. * Class used to store bone information
  8002. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8003. */
  8004. export class Bone extends Node {
  8005. /**
  8006. * defines the bone name
  8007. */
  8008. name: string;
  8009. private static _tmpVecs;
  8010. private static _tmpQuat;
  8011. private static _tmpMats;
  8012. /**
  8013. * Gets the list of child bones
  8014. */
  8015. children: Bone[];
  8016. /** Gets the animations associated with this bone */
  8017. animations: import("babylonjs/Animations/animation").Animation[];
  8018. /**
  8019. * Gets or sets bone length
  8020. */
  8021. length: number;
  8022. /**
  8023. * @hidden Internal only
  8024. * Set this value to map this bone to a different index in the transform matrices
  8025. * Set this value to -1 to exclude the bone from the transform matrices
  8026. */
  8027. _index: Nullable<number>;
  8028. private _skeleton;
  8029. private _localMatrix;
  8030. private _restPose;
  8031. private _baseMatrix;
  8032. private _absoluteTransform;
  8033. private _invertedAbsoluteTransform;
  8034. private _parent;
  8035. private _scalingDeterminant;
  8036. private _worldTransform;
  8037. private _localScaling;
  8038. private _localRotation;
  8039. private _localPosition;
  8040. private _needToDecompose;
  8041. private _needToCompose;
  8042. /** @hidden */
  8043. _linkedTransformNode: Nullable<TransformNode>;
  8044. /** @hidden */
  8045. /** @hidden */
  8046. _matrix: Matrix;
  8047. /**
  8048. * Create a new bone
  8049. * @param name defines the bone name
  8050. * @param skeleton defines the parent skeleton
  8051. * @param parentBone defines the parent (can be null if the bone is the root)
  8052. * @param localMatrix defines the local matrix
  8053. * @param restPose defines the rest pose matrix
  8054. * @param baseMatrix defines the base matrix
  8055. * @param index defines index of the bone in the hiearchy
  8056. */
  8057. constructor(
  8058. /**
  8059. * defines the bone name
  8060. */
  8061. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8062. /**
  8063. * Gets the current object class name.
  8064. * @return the class name
  8065. */
  8066. getClassName(): string;
  8067. /**
  8068. * Gets the parent skeleton
  8069. * @returns a skeleton
  8070. */
  8071. getSkeleton(): Skeleton;
  8072. /**
  8073. * Gets parent bone
  8074. * @returns a bone or null if the bone is the root of the bone hierarchy
  8075. */
  8076. getParent(): Nullable<Bone>;
  8077. /**
  8078. * Returns an array containing the root bones
  8079. * @returns an array containing the root bones
  8080. */
  8081. getChildren(): Array<Bone>;
  8082. /**
  8083. * Sets the parent bone
  8084. * @param parent defines the parent (can be null if the bone is the root)
  8085. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8086. */
  8087. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8088. /**
  8089. * Gets the local matrix
  8090. * @returns a matrix
  8091. */
  8092. getLocalMatrix(): Matrix;
  8093. /**
  8094. * Gets the base matrix (initial matrix which remains unchanged)
  8095. * @returns a matrix
  8096. */
  8097. getBaseMatrix(): Matrix;
  8098. /**
  8099. * Gets the rest pose matrix
  8100. * @returns a matrix
  8101. */
  8102. getRestPose(): Matrix;
  8103. /**
  8104. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8105. */
  8106. getWorldMatrix(): Matrix;
  8107. /**
  8108. * Sets the local matrix to rest pose matrix
  8109. */
  8110. returnToRest(): void;
  8111. /**
  8112. * Gets the inverse of the absolute transform matrix.
  8113. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8114. * @returns a matrix
  8115. */
  8116. getInvertedAbsoluteTransform(): Matrix;
  8117. /**
  8118. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8119. * @returns a matrix
  8120. */
  8121. getAbsoluteTransform(): Matrix;
  8122. /**
  8123. * Links with the given transform node.
  8124. * The local matrix of this bone is copied from the transform node every frame.
  8125. * @param transformNode defines the transform node to link to
  8126. */
  8127. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8128. /** Gets or sets current position (in local space) */
  8129. position: Vector3;
  8130. /** Gets or sets current rotation (in local space) */
  8131. rotation: Vector3;
  8132. /** Gets or sets current rotation quaternion (in local space) */
  8133. rotationQuaternion: Quaternion;
  8134. /** Gets or sets current scaling (in local space) */
  8135. scaling: Vector3;
  8136. /**
  8137. * Gets the animation properties override
  8138. */
  8139. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8140. private _decompose;
  8141. private _compose;
  8142. /**
  8143. * Update the base and local matrices
  8144. * @param matrix defines the new base or local matrix
  8145. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8146. * @param updateLocalMatrix defines if the local matrix should be updated
  8147. */
  8148. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8149. /** @hidden */
  8150. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8151. /**
  8152. * Flag the bone as dirty (Forcing it to update everything)
  8153. */
  8154. markAsDirty(): void;
  8155. private _markAsDirtyAndCompose;
  8156. private _markAsDirtyAndDecompose;
  8157. /**
  8158. * Translate the bone in local or world space
  8159. * @param vec The amount to translate the bone
  8160. * @param space The space that the translation is in
  8161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8162. */
  8163. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8164. /**
  8165. * Set the postion of the bone in local or world space
  8166. * @param position The position to set the bone
  8167. * @param space The space that the position is in
  8168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8169. */
  8170. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8171. /**
  8172. * Set the absolute position of the bone (world space)
  8173. * @param position The position to set the bone
  8174. * @param mesh The mesh that this bone is attached to
  8175. */
  8176. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Scale the bone on the x, y and z axes (in local space)
  8179. * @param x The amount to scale the bone on the x axis
  8180. * @param y The amount to scale the bone on the y axis
  8181. * @param z The amount to scale the bone on the z axis
  8182. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8183. */
  8184. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8185. /**
  8186. * Set the bone scaling in local space
  8187. * @param scale defines the scaling vector
  8188. */
  8189. setScale(scale: Vector3): void;
  8190. /**
  8191. * Gets the current scaling in local space
  8192. * @returns the current scaling vector
  8193. */
  8194. getScale(): Vector3;
  8195. /**
  8196. * Gets the current scaling in local space and stores it in a target vector
  8197. * @param result defines the target vector
  8198. */
  8199. getScaleToRef(result: Vector3): void;
  8200. /**
  8201. * Set the yaw, pitch, and roll of the bone in local or world space
  8202. * @param yaw The rotation of the bone on the y axis
  8203. * @param pitch The rotation of the bone on the x axis
  8204. * @param roll The rotation of the bone on the z axis
  8205. * @param space The space that the axes of rotation are in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. */
  8208. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8209. /**
  8210. * Add a rotation to the bone on an axis in local or world space
  8211. * @param axis The axis to rotate the bone on
  8212. * @param amount The amount to rotate the bone
  8213. * @param space The space that the axis is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8217. /**
  8218. * Set the rotation of the bone to a particular axis angle in local or world space
  8219. * @param axis The axis to rotate the bone on
  8220. * @param angle The angle that the bone should be rotated to
  8221. * @param space The space that the axis is in
  8222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8223. */
  8224. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8225. /**
  8226. * Set the euler rotation of the bone in local of world space
  8227. * @param rotation The euler rotation that the bone should be set to
  8228. * @param space The space that the rotation is in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. */
  8231. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8232. /**
  8233. * Set the quaternion rotation of the bone in local of world space
  8234. * @param quat The quaternion rotation that the bone should be set to
  8235. * @param space The space that the rotation is in
  8236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8237. */
  8238. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8239. /**
  8240. * Set the rotation matrix of the bone in local of world space
  8241. * @param rotMat The rotation matrix that the bone should be set to
  8242. * @param space The space that the rotation is in
  8243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8244. */
  8245. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8246. private _rotateWithMatrix;
  8247. private _getNegativeRotationToRef;
  8248. /**
  8249. * Get the position of the bone in local or world space
  8250. * @param space The space that the returned position is in
  8251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8252. * @returns The position of the bone
  8253. */
  8254. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8255. /**
  8256. * Copy the position of the bone to a vector3 in local or world space
  8257. * @param space The space that the returned position is in
  8258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8259. * @param result The vector3 to copy the position to
  8260. */
  8261. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8262. /**
  8263. * Get the absolute position of the bone (world space)
  8264. * @param mesh The mesh that this bone is attached to
  8265. * @returns The absolute position of the bone
  8266. */
  8267. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8268. /**
  8269. * Copy the absolute position of the bone (world space) to the result param
  8270. * @param mesh The mesh that this bone is attached to
  8271. * @param result The vector3 to copy the absolute position to
  8272. */
  8273. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8274. /**
  8275. * Compute the absolute transforms of this bone and its children
  8276. */
  8277. computeAbsoluteTransforms(): void;
  8278. /**
  8279. * Get the world direction from an axis that is in the local space of the bone
  8280. * @param localAxis The local direction that is used to compute the world direction
  8281. * @param mesh The mesh that this bone is attached to
  8282. * @returns The world direction
  8283. */
  8284. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8285. /**
  8286. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8287. * @param localAxis The local direction that is used to compute the world direction
  8288. * @param mesh The mesh that this bone is attached to
  8289. * @param result The vector3 that the world direction will be copied to
  8290. */
  8291. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8292. /**
  8293. * Get the euler rotation of the bone in local or world space
  8294. * @param space The space that the rotation should be in
  8295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8296. * @returns The euler rotation
  8297. */
  8298. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8299. /**
  8300. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8301. * @param space The space that the rotation should be in
  8302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8303. * @param result The vector3 that the rotation should be copied to
  8304. */
  8305. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8306. /**
  8307. * Get the quaternion rotation of the bone in either local or world space
  8308. * @param space The space that the rotation should be in
  8309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8310. * @returns The quaternion rotation
  8311. */
  8312. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8313. /**
  8314. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8315. * @param space The space that the rotation should be in
  8316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8317. * @param result The quaternion that the rotation should be copied to
  8318. */
  8319. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8320. /**
  8321. * Get the rotation matrix of the bone in local or world space
  8322. * @param space The space that the rotation should be in
  8323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8324. * @returns The rotation matrix
  8325. */
  8326. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8327. /**
  8328. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8329. * @param space The space that the rotation should be in
  8330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8331. * @param result The quaternion that the rotation should be copied to
  8332. */
  8333. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8334. /**
  8335. * Get the world position of a point that is in the local space of the bone
  8336. * @param position The local position
  8337. * @param mesh The mesh that this bone is attached to
  8338. * @returns The world position
  8339. */
  8340. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8341. /**
  8342. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8343. * @param position The local position
  8344. * @param mesh The mesh that this bone is attached to
  8345. * @param result The vector3 that the world position should be copied to
  8346. */
  8347. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8348. /**
  8349. * Get the local position of a point that is in world space
  8350. * @param position The world position
  8351. * @param mesh The mesh that this bone is attached to
  8352. * @returns The local position
  8353. */
  8354. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8355. /**
  8356. * Get the local position of a point that is in world space and copy it to the result param
  8357. * @param position The world position
  8358. * @param mesh The mesh that this bone is attached to
  8359. * @param result The vector3 that the local position should be copied to
  8360. */
  8361. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8362. }
  8363. }
  8364. declare module "babylonjs/Misc/iInspectable" {
  8365. /**
  8366. * Enum that determines the text-wrapping mode to use.
  8367. */
  8368. export enum InspectableType {
  8369. /**
  8370. * Checkbox for booleans
  8371. */
  8372. Checkbox = 0,
  8373. /**
  8374. * Sliders for numbers
  8375. */
  8376. Slider = 1,
  8377. /**
  8378. * Vector3
  8379. */
  8380. Vector3 = 2,
  8381. /**
  8382. * Quaternions
  8383. */
  8384. Quaternion = 3,
  8385. /**
  8386. * Color3
  8387. */
  8388. Color3 = 4
  8389. }
  8390. /**
  8391. * Interface used to define custom inspectable properties.
  8392. * This interface is used by the inspector to display custom property grids
  8393. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8394. */
  8395. export interface IInspectable {
  8396. /**
  8397. * Gets the label to display
  8398. */
  8399. label: string;
  8400. /**
  8401. * Gets the name of the property to edit
  8402. */
  8403. propertyName: string;
  8404. /**
  8405. * Gets the type of the editor to use
  8406. */
  8407. type: InspectableType;
  8408. /**
  8409. * Gets the minimum value of the property when using in "slider" mode
  8410. */
  8411. min?: number;
  8412. /**
  8413. * Gets the maximum value of the property when using in "slider" mode
  8414. */
  8415. max?: number;
  8416. /**
  8417. * Gets the setp to use when using in "slider" mode
  8418. */
  8419. step?: number;
  8420. }
  8421. }
  8422. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8423. import { Nullable } from "babylonjs/types";
  8424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8425. /**
  8426. * This represents the required contract to create a new type of texture loader.
  8427. */
  8428. export interface IInternalTextureLoader {
  8429. /**
  8430. * Defines wether the loader supports cascade loading the different faces.
  8431. */
  8432. supportCascades: boolean;
  8433. /**
  8434. * This returns if the loader support the current file information.
  8435. * @param extension defines the file extension of the file being loaded
  8436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8437. * @param fallback defines the fallback internal texture if any
  8438. * @param isBase64 defines whether the texture is encoded as a base64
  8439. * @param isBuffer defines whether the texture data are stored as a buffer
  8440. * @returns true if the loader can load the specified file
  8441. */
  8442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8443. /**
  8444. * Transform the url before loading if required.
  8445. * @param rootUrl the url of the texture
  8446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8447. * @returns the transformed texture
  8448. */
  8449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8450. /**
  8451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8452. * @param rootUrl the url of the texture
  8453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8454. * @returns the fallback texture
  8455. */
  8456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8457. /**
  8458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8459. * @param data contains the texture data
  8460. * @param texture defines the BabylonJS internal texture
  8461. * @param createPolynomials will be true if polynomials have been requested
  8462. * @param onLoad defines the callback to trigger once the texture is ready
  8463. * @param onError defines the callback to trigger in case of error
  8464. */
  8465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8466. /**
  8467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8468. * @param data contains the texture data
  8469. * @param texture defines the BabylonJS internal texture
  8470. * @param callback defines the method to call once ready to upload
  8471. */
  8472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8473. }
  8474. }
  8475. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8477. import { Nullable } from "babylonjs/types";
  8478. import { Scene } from "babylonjs/scene";
  8479. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8480. module "babylonjs/Engines/engine" {
  8481. interface Engine {
  8482. /**
  8483. * Creates a depth stencil cube texture.
  8484. * This is only available in WebGL 2.
  8485. * @param size The size of face edge in the cube texture.
  8486. * @param options The options defining the cube texture.
  8487. * @returns The cube texture
  8488. */
  8489. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8490. /**
  8491. * Creates a cube texture
  8492. * @param rootUrl defines the url where the files to load is located
  8493. * @param scene defines the current scene
  8494. * @param files defines the list of files to load (1 per face)
  8495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8496. * @param onLoad defines an optional callback raised when the texture is loaded
  8497. * @param onError defines an optional callback raised if there is an issue to load the texture
  8498. * @param format defines the format of the data
  8499. * @param forcedExtension defines the extension to use to pick the right loader
  8500. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8503. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8504. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8505. * @returns the cube texture as an InternalTexture
  8506. */
  8507. 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;
  8508. /**
  8509. * Creates a cube texture
  8510. * @param rootUrl defines the url where the files to load is located
  8511. * @param scene defines the current scene
  8512. * @param files defines the list of files to load (1 per face)
  8513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8514. * @param onLoad defines an optional callback raised when the texture is loaded
  8515. * @param onError defines an optional callback raised if there is an issue to load the texture
  8516. * @param format defines the format of the data
  8517. * @param forcedExtension defines the extension to use to pick the right loader
  8518. * @returns the cube texture as an InternalTexture
  8519. */
  8520. 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;
  8521. /**
  8522. * Creates a cube texture
  8523. * @param rootUrl defines the url where the files to load is located
  8524. * @param scene defines the current scene
  8525. * @param files defines the list of files to load (1 per face)
  8526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8527. * @param onLoad defines an optional callback raised when the texture is loaded
  8528. * @param onError defines an optional callback raised if there is an issue to load the texture
  8529. * @param format defines the format of the data
  8530. * @param forcedExtension defines the extension to use to pick the right loader
  8531. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8534. * @returns the cube texture as an InternalTexture
  8535. */
  8536. 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;
  8537. /** @hidden */
  8538. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8539. /** @hidden */
  8540. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8541. /** @hidden */
  8542. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8543. /** @hidden */
  8544. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8545. }
  8546. }
  8547. }
  8548. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8549. import { Nullable } from "babylonjs/types";
  8550. import { Scene } from "babylonjs/scene";
  8551. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8553. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8554. /**
  8555. * Class for creating a cube texture
  8556. */
  8557. export class CubeTexture extends BaseTexture {
  8558. private _delayedOnLoad;
  8559. /**
  8560. * The url of the texture
  8561. */
  8562. url: string;
  8563. /**
  8564. * Gets or sets the center of the bounding box associated with the cube texture.
  8565. * It must define where the camera used to render the texture was set
  8566. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8567. */
  8568. boundingBoxPosition: Vector3;
  8569. private _boundingBoxSize;
  8570. /**
  8571. * Gets or sets the size of the bounding box associated with the cube texture
  8572. * When defined, the cubemap will switch to local mode
  8573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8574. * @example https://www.babylonjs-playground.com/#RNASML
  8575. */
  8576. /**
  8577. * Returns the bounding box size
  8578. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8579. */
  8580. boundingBoxSize: Vector3;
  8581. protected _rotationY: number;
  8582. /**
  8583. * Sets texture matrix rotation angle around Y axis in radians.
  8584. */
  8585. /**
  8586. * Gets texture matrix rotation angle around Y axis radians.
  8587. */
  8588. rotationY: number;
  8589. /**
  8590. * Are mip maps generated for this texture or not.
  8591. */
  8592. readonly noMipmap: boolean;
  8593. private _noMipmap;
  8594. private _files;
  8595. private _extensions;
  8596. private _textureMatrix;
  8597. private _format;
  8598. private _createPolynomials;
  8599. /** @hidden */
  8600. _prefiltered: boolean;
  8601. /**
  8602. * Creates a cube texture from an array of image urls
  8603. * @param files defines an array of image urls
  8604. * @param scene defines the hosting scene
  8605. * @param noMipmap specifies if mip maps are not used
  8606. * @returns a cube texture
  8607. */
  8608. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8609. /**
  8610. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8611. * @param url defines the url of the prefiltered texture
  8612. * @param scene defines the scene the texture is attached to
  8613. * @param forcedExtension defines the extension of the file if different from the url
  8614. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8615. * @return the prefiltered texture
  8616. */
  8617. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8618. /**
  8619. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8620. * as prefiltered data.
  8621. * @param rootUrl defines the url of the texture or the root name of the six images
  8622. * @param scene defines the scene the texture is attached to
  8623. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8624. * @param noMipmap defines if mipmaps should be created or not
  8625. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8626. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8627. * @param onError defines a callback triggered in case of error during load
  8628. * @param format defines the internal format to use for the texture once loaded
  8629. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8630. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8634. * @return the cube texture
  8635. */
  8636. 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);
  8637. /**
  8638. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8639. */
  8640. readonly isPrefiltered: boolean;
  8641. /**
  8642. * Get the current class name of the texture useful for serialization or dynamic coding.
  8643. * @returns "CubeTexture"
  8644. */
  8645. getClassName(): string;
  8646. /**
  8647. * Update the url (and optional buffer) of this texture if url was null during construction.
  8648. * @param url the url of the texture
  8649. * @param forcedExtension defines the extension to use
  8650. * @param onLoad callback called when the texture is loaded (defaults to null)
  8651. */
  8652. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8653. /**
  8654. * Delays loading of the cube texture
  8655. * @param forcedExtension defines the extension to use
  8656. */
  8657. delayLoad(forcedExtension?: string): void;
  8658. /**
  8659. * Returns the reflection texture matrix
  8660. * @returns the reflection texture matrix
  8661. */
  8662. getReflectionTextureMatrix(): Matrix;
  8663. /**
  8664. * Sets the reflection texture matrix
  8665. * @param value Reflection texture matrix
  8666. */
  8667. setReflectionTextureMatrix(value: Matrix): void;
  8668. /**
  8669. * Parses text to create a cube texture
  8670. * @param parsedTexture define the serialized text to read from
  8671. * @param scene defines the hosting scene
  8672. * @param rootUrl defines the root url of the cube texture
  8673. * @returns a cube texture
  8674. */
  8675. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8676. /**
  8677. * Makes a clone, or deep copy, of the cube texture
  8678. * @returns a new cube texture
  8679. */
  8680. clone(): CubeTexture;
  8681. }
  8682. }
  8683. declare module "babylonjs/Shaders/postprocess.vertex" {
  8684. /** @hidden */
  8685. export var postprocessVertexShader: {
  8686. name: string;
  8687. shader: string;
  8688. };
  8689. }
  8690. declare module "babylonjs/Cameras/targetCamera" {
  8691. import { Nullable } from "babylonjs/types";
  8692. import { Camera } from "babylonjs/Cameras/camera";
  8693. import { Scene } from "babylonjs/scene";
  8694. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8695. /**
  8696. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8697. * This is the base of the follow, arc rotate cameras and Free camera
  8698. * @see http://doc.babylonjs.com/features/cameras
  8699. */
  8700. export class TargetCamera extends Camera {
  8701. private static _RigCamTransformMatrix;
  8702. private static _TargetTransformMatrix;
  8703. private static _TargetFocalPoint;
  8704. /**
  8705. * Define the current direction the camera is moving to
  8706. */
  8707. cameraDirection: Vector3;
  8708. /**
  8709. * Define the current rotation the camera is rotating to
  8710. */
  8711. cameraRotation: Vector2;
  8712. /**
  8713. * When set, the up vector of the camera will be updated by the rotation of the camera
  8714. */
  8715. updateUpVectorFromRotation: boolean;
  8716. private _tmpQuaternion;
  8717. /**
  8718. * Define the current rotation of the camera
  8719. */
  8720. rotation: Vector3;
  8721. /**
  8722. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8723. */
  8724. rotationQuaternion: Quaternion;
  8725. /**
  8726. * Define the current speed of the camera
  8727. */
  8728. speed: number;
  8729. /**
  8730. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8731. * around all axis.
  8732. */
  8733. noRotationConstraint: boolean;
  8734. /**
  8735. * Define the current target of the camera as an object or a position.
  8736. */
  8737. lockedTarget: any;
  8738. /** @hidden */
  8739. _currentTarget: Vector3;
  8740. /** @hidden */
  8741. _initialFocalDistance: number;
  8742. /** @hidden */
  8743. _viewMatrix: Matrix;
  8744. /** @hidden */
  8745. _camMatrix: Matrix;
  8746. /** @hidden */
  8747. _cameraTransformMatrix: Matrix;
  8748. /** @hidden */
  8749. _cameraRotationMatrix: Matrix;
  8750. /** @hidden */
  8751. _referencePoint: Vector3;
  8752. /** @hidden */
  8753. _transformedReferencePoint: Vector3;
  8754. protected _globalCurrentTarget: Vector3;
  8755. protected _globalCurrentUpVector: Vector3;
  8756. /** @hidden */
  8757. _reset: () => void;
  8758. private _defaultUp;
  8759. /**
  8760. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8761. * This is the base of the follow, arc rotate cameras and Free camera
  8762. * @see http://doc.babylonjs.com/features/cameras
  8763. * @param name Defines the name of the camera in the scene
  8764. * @param position Defines the start position of the camera in the scene
  8765. * @param scene Defines the scene the camera belongs to
  8766. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8767. */
  8768. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8769. /**
  8770. * Gets the position in front of the camera at a given distance.
  8771. * @param distance The distance from the camera we want the position to be
  8772. * @returns the position
  8773. */
  8774. getFrontPosition(distance: number): Vector3;
  8775. /** @hidden */
  8776. _getLockedTargetPosition(): Nullable<Vector3>;
  8777. private _storedPosition;
  8778. private _storedRotation;
  8779. private _storedRotationQuaternion;
  8780. /**
  8781. * Store current camera state of the camera (fov, position, rotation, etc..)
  8782. * @returns the camera
  8783. */
  8784. storeState(): Camera;
  8785. /**
  8786. * Restored camera state. You must call storeState() first
  8787. * @returns whether it was successful or not
  8788. * @hidden
  8789. */
  8790. _restoreStateValues(): boolean;
  8791. /** @hidden */
  8792. _initCache(): void;
  8793. /** @hidden */
  8794. _updateCache(ignoreParentClass?: boolean): void;
  8795. /** @hidden */
  8796. _isSynchronizedViewMatrix(): boolean;
  8797. /** @hidden */
  8798. _computeLocalCameraSpeed(): number;
  8799. /**
  8800. * Defines the target the camera should look at.
  8801. * This will automatically adapt alpha beta and radius to fit within the new target.
  8802. * @param target Defines the new target as a Vector or a mesh
  8803. */
  8804. setTarget(target: Vector3): void;
  8805. /**
  8806. * Return the current target position of the camera. This value is expressed in local space.
  8807. * @returns the target position
  8808. */
  8809. getTarget(): Vector3;
  8810. /** @hidden */
  8811. _decideIfNeedsToMove(): boolean;
  8812. /** @hidden */
  8813. _updatePosition(): void;
  8814. /** @hidden */
  8815. _checkInputs(): void;
  8816. protected _updateCameraRotationMatrix(): void;
  8817. /**
  8818. * 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)
  8819. * @returns the current camera
  8820. */
  8821. private _rotateUpVectorWithCameraRotationMatrix;
  8822. private _cachedRotationZ;
  8823. private _cachedQuaternionRotationZ;
  8824. /** @hidden */
  8825. _getViewMatrix(): Matrix;
  8826. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8827. /**
  8828. * @hidden
  8829. */
  8830. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8831. /**
  8832. * @hidden
  8833. */
  8834. _updateRigCameras(): void;
  8835. private _getRigCamPositionAndTarget;
  8836. /**
  8837. * Gets the current object class name.
  8838. * @return the class name
  8839. */
  8840. getClassName(): string;
  8841. }
  8842. }
  8843. declare module "babylonjs/Cameras/cameraInputsManager" {
  8844. import { Nullable } from "babylonjs/types";
  8845. import { Camera } from "babylonjs/Cameras/camera";
  8846. /**
  8847. * @ignore
  8848. * This is a list of all the different input types that are available in the application.
  8849. * Fo instance: ArcRotateCameraGamepadInput...
  8850. */
  8851. export var CameraInputTypes: {};
  8852. /**
  8853. * This is the contract to implement in order to create a new input class.
  8854. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8855. */
  8856. export interface ICameraInput<TCamera extends Camera> {
  8857. /**
  8858. * Defines the camera the input is attached to.
  8859. */
  8860. camera: Nullable<TCamera>;
  8861. /**
  8862. * Gets the class name of the current intput.
  8863. * @returns the class name
  8864. */
  8865. getClassName(): string;
  8866. /**
  8867. * Get the friendly name associated with the input class.
  8868. * @returns the input friendly name
  8869. */
  8870. getSimpleName(): string;
  8871. /**
  8872. * Attach the input controls to a specific dom element to get the input from.
  8873. * @param element Defines the element the controls should be listened from
  8874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8875. */
  8876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8877. /**
  8878. * Detach the current controls from the specified dom element.
  8879. * @param element Defines the element to stop listening the inputs from
  8880. */
  8881. detachControl(element: Nullable<HTMLElement>): void;
  8882. /**
  8883. * Update the current camera state depending on the inputs that have been used this frame.
  8884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8885. */
  8886. checkInputs?: () => void;
  8887. }
  8888. /**
  8889. * Represents a map of input types to input instance or input index to input instance.
  8890. */
  8891. export interface CameraInputsMap<TCamera extends Camera> {
  8892. /**
  8893. * Accessor to the input by input type.
  8894. */
  8895. [name: string]: ICameraInput<TCamera>;
  8896. /**
  8897. * Accessor to the input by input index.
  8898. */
  8899. [idx: number]: ICameraInput<TCamera>;
  8900. }
  8901. /**
  8902. * This represents the input manager used within a camera.
  8903. * It helps dealing with all the different kind of input attached to a camera.
  8904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8905. */
  8906. export class CameraInputsManager<TCamera extends Camera> {
  8907. /**
  8908. * Defines the list of inputs attahed to the camera.
  8909. */
  8910. attached: CameraInputsMap<TCamera>;
  8911. /**
  8912. * Defines the dom element the camera is collecting inputs from.
  8913. * This is null if the controls have not been attached.
  8914. */
  8915. attachedElement: Nullable<HTMLElement>;
  8916. /**
  8917. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8918. */
  8919. noPreventDefault: boolean;
  8920. /**
  8921. * Defined the camera the input manager belongs to.
  8922. */
  8923. camera: TCamera;
  8924. /**
  8925. * Update the current camera state depending on the inputs that have been used this frame.
  8926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8927. */
  8928. checkInputs: () => void;
  8929. /**
  8930. * Instantiate a new Camera Input Manager.
  8931. * @param camera Defines the camera the input manager blongs to
  8932. */
  8933. constructor(camera: TCamera);
  8934. /**
  8935. * Add an input method to a camera
  8936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8937. * @param input camera input method
  8938. */
  8939. add(input: ICameraInput<TCamera>): void;
  8940. /**
  8941. * Remove a specific input method from a camera
  8942. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8943. * @param inputToRemove camera input method
  8944. */
  8945. remove(inputToRemove: ICameraInput<TCamera>): void;
  8946. /**
  8947. * Remove a specific input type from a camera
  8948. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8949. * @param inputType the type of the input to remove
  8950. */
  8951. removeByType(inputType: string): void;
  8952. private _addCheckInputs;
  8953. /**
  8954. * Attach the input controls to the currently attached dom element to listen the events from.
  8955. * @param input Defines the input to attach
  8956. */
  8957. attachInput(input: ICameraInput<TCamera>): void;
  8958. /**
  8959. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8960. * @param element Defines the dom element to collect the events from
  8961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8962. */
  8963. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8964. /**
  8965. * Detach the current manager inputs controls from a specific dom element.
  8966. * @param element Defines the dom element to collect the events from
  8967. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8968. */
  8969. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8970. /**
  8971. * Rebuild the dynamic inputCheck function from the current list of
  8972. * defined inputs in the manager.
  8973. */
  8974. rebuildInputCheck(): void;
  8975. /**
  8976. * Remove all attached input methods from a camera
  8977. */
  8978. clear(): void;
  8979. /**
  8980. * Serialize the current input manager attached to a camera.
  8981. * This ensures than once parsed,
  8982. * the input associated to the camera will be identical to the current ones
  8983. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8984. */
  8985. serialize(serializedCamera: any): void;
  8986. /**
  8987. * Parses an input manager serialized JSON to restore the previous list of inputs
  8988. * and states associated to a camera.
  8989. * @param parsedCamera Defines the JSON to parse
  8990. */
  8991. parse(parsedCamera: any): void;
  8992. }
  8993. }
  8994. declare module "babylonjs/Events/keyboardEvents" {
  8995. /**
  8996. * Gather the list of keyboard event types as constants.
  8997. */
  8998. export class KeyboardEventTypes {
  8999. /**
  9000. * The keydown event is fired when a key becomes active (pressed).
  9001. */
  9002. static readonly KEYDOWN: number;
  9003. /**
  9004. * The keyup event is fired when a key has been released.
  9005. */
  9006. static readonly KEYUP: number;
  9007. }
  9008. /**
  9009. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9010. */
  9011. export class KeyboardInfo {
  9012. /**
  9013. * Defines the type of event (KeyboardEventTypes)
  9014. */
  9015. type: number;
  9016. /**
  9017. * Defines the related dom event
  9018. */
  9019. event: KeyboardEvent;
  9020. /**
  9021. * Instantiates a new keyboard info.
  9022. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9023. * @param type Defines the type of event (KeyboardEventTypes)
  9024. * @param event Defines the related dom event
  9025. */
  9026. constructor(
  9027. /**
  9028. * Defines the type of event (KeyboardEventTypes)
  9029. */
  9030. type: number,
  9031. /**
  9032. * Defines the related dom event
  9033. */
  9034. event: KeyboardEvent);
  9035. }
  9036. /**
  9037. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9038. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9039. */
  9040. export class KeyboardInfoPre extends KeyboardInfo {
  9041. /**
  9042. * Defines the type of event (KeyboardEventTypes)
  9043. */
  9044. type: number;
  9045. /**
  9046. * Defines the related dom event
  9047. */
  9048. event: KeyboardEvent;
  9049. /**
  9050. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9051. */
  9052. skipOnPointerObservable: boolean;
  9053. /**
  9054. * Instantiates a new keyboard pre info.
  9055. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9056. * @param type Defines the type of event (KeyboardEventTypes)
  9057. * @param event Defines the related dom event
  9058. */
  9059. constructor(
  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. }
  9070. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9071. import { Nullable } from "babylonjs/types";
  9072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9074. /**
  9075. * Manage the keyboard inputs to control the movement of a free camera.
  9076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9077. */
  9078. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9079. /**
  9080. * Defines the camera the input is attached to.
  9081. */
  9082. camera: FreeCamera;
  9083. /**
  9084. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9085. */
  9086. keysUp: number[];
  9087. /**
  9088. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9089. */
  9090. keysDown: number[];
  9091. /**
  9092. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9093. */
  9094. keysLeft: number[];
  9095. /**
  9096. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9097. */
  9098. keysRight: number[];
  9099. private _keys;
  9100. private _onCanvasBlurObserver;
  9101. private _onKeyboardObserver;
  9102. private _engine;
  9103. private _scene;
  9104. /**
  9105. * Attach the input controls to a specific dom element to get the input from.
  9106. * @param element Defines the element the controls should be listened from
  9107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9108. */
  9109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9110. /**
  9111. * Detach the current controls from the specified dom element.
  9112. * @param element Defines the element to stop listening the inputs from
  9113. */
  9114. detachControl(element: Nullable<HTMLElement>): void;
  9115. /**
  9116. * Update the current camera state depending on the inputs that have been used this frame.
  9117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9118. */
  9119. checkInputs(): void;
  9120. /**
  9121. * Gets the class name of the current intput.
  9122. * @returns the class name
  9123. */
  9124. getClassName(): string;
  9125. /** @hidden */
  9126. _onLostFocus(): void;
  9127. /**
  9128. * Get the friendly name associated with the input class.
  9129. * @returns the input friendly name
  9130. */
  9131. getSimpleName(): string;
  9132. }
  9133. }
  9134. declare module "babylonjs/Lights/shadowLight" {
  9135. import { Camera } from "babylonjs/Cameras/camera";
  9136. import { Scene } from "babylonjs/scene";
  9137. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9139. import { Light } from "babylonjs/Lights/light";
  9140. /**
  9141. * Interface describing all the common properties and methods a shadow light needs to implement.
  9142. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9143. * as well as binding the different shadow properties to the effects.
  9144. */
  9145. export interface IShadowLight extends Light {
  9146. /**
  9147. * The light id in the scene (used in scene.findLighById for instance)
  9148. */
  9149. id: string;
  9150. /**
  9151. * The position the shdow will be casted from.
  9152. */
  9153. position: Vector3;
  9154. /**
  9155. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9156. */
  9157. direction: Vector3;
  9158. /**
  9159. * The transformed position. Position of the light in world space taking parenting in account.
  9160. */
  9161. transformedPosition: Vector3;
  9162. /**
  9163. * The transformed direction. Direction of the light in world space taking parenting in account.
  9164. */
  9165. transformedDirection: Vector3;
  9166. /**
  9167. * The friendly name of the light in the scene.
  9168. */
  9169. name: string;
  9170. /**
  9171. * Defines the shadow projection clipping minimum z value.
  9172. */
  9173. shadowMinZ: number;
  9174. /**
  9175. * Defines the shadow projection clipping maximum z value.
  9176. */
  9177. shadowMaxZ: number;
  9178. /**
  9179. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9180. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9181. */
  9182. computeTransformedInformation(): boolean;
  9183. /**
  9184. * Gets the scene the light belongs to.
  9185. * @returns The scene
  9186. */
  9187. getScene(): Scene;
  9188. /**
  9189. * Callback defining a custom Projection Matrix Builder.
  9190. * This can be used to override the default projection matrix computation.
  9191. */
  9192. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9193. /**
  9194. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9195. * @param matrix The materix to updated with the projection information
  9196. * @param viewMatrix The transform matrix of the light
  9197. * @param renderList The list of mesh to render in the map
  9198. * @returns The current light
  9199. */
  9200. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9201. /**
  9202. * Gets the current depth scale used in ESM.
  9203. * @returns The scale
  9204. */
  9205. getDepthScale(): number;
  9206. /**
  9207. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9208. * @returns true if a cube texture needs to be use
  9209. */
  9210. needCube(): boolean;
  9211. /**
  9212. * Detects if the projection matrix requires to be recomputed this frame.
  9213. * @returns true if it requires to be recomputed otherwise, false.
  9214. */
  9215. needProjectionMatrixCompute(): boolean;
  9216. /**
  9217. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9218. */
  9219. forceProjectionMatrixCompute(): void;
  9220. /**
  9221. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9222. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9223. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9224. */
  9225. getShadowDirection(faceIndex?: number): Vector3;
  9226. /**
  9227. * Gets the minZ used for shadow according to both the scene and the light.
  9228. * @param activeCamera The camera we are returning the min for
  9229. * @returns the depth min z
  9230. */
  9231. getDepthMinZ(activeCamera: Camera): number;
  9232. /**
  9233. * Gets the maxZ used for shadow according to both the scene and the light.
  9234. * @param activeCamera The camera we are returning the max for
  9235. * @returns the depth max z
  9236. */
  9237. getDepthMaxZ(activeCamera: Camera): number;
  9238. }
  9239. /**
  9240. * Base implementation IShadowLight
  9241. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9242. */
  9243. export abstract class ShadowLight extends Light implements IShadowLight {
  9244. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9245. protected _position: Vector3;
  9246. protected _setPosition(value: Vector3): void;
  9247. /**
  9248. * Sets the position the shadow will be casted from. Also use as the light position for both
  9249. * point and spot lights.
  9250. */
  9251. /**
  9252. * Sets the position the shadow will be casted from. Also use as the light position for both
  9253. * point and spot lights.
  9254. */
  9255. position: Vector3;
  9256. protected _direction: Vector3;
  9257. protected _setDirection(value: Vector3): void;
  9258. /**
  9259. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9260. * Also use as the light direction on spot and directional lights.
  9261. */
  9262. /**
  9263. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9264. * Also use as the light direction on spot and directional lights.
  9265. */
  9266. direction: Vector3;
  9267. private _shadowMinZ;
  9268. /**
  9269. * Gets the shadow projection clipping minimum z value.
  9270. */
  9271. /**
  9272. * Sets the shadow projection clipping minimum z value.
  9273. */
  9274. shadowMinZ: number;
  9275. private _shadowMaxZ;
  9276. /**
  9277. * Sets the shadow projection clipping maximum z value.
  9278. */
  9279. /**
  9280. * Gets the shadow projection clipping maximum z value.
  9281. */
  9282. shadowMaxZ: number;
  9283. /**
  9284. * Callback defining a custom Projection Matrix Builder.
  9285. * This can be used to override the default projection matrix computation.
  9286. */
  9287. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9288. /**
  9289. * The transformed position. Position of the light in world space taking parenting in account.
  9290. */
  9291. transformedPosition: Vector3;
  9292. /**
  9293. * The transformed direction. Direction of the light in world space taking parenting in account.
  9294. */
  9295. transformedDirection: Vector3;
  9296. private _needProjectionMatrixCompute;
  9297. /**
  9298. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9299. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9300. */
  9301. computeTransformedInformation(): boolean;
  9302. /**
  9303. * Return the depth scale used for the shadow map.
  9304. * @returns the depth scale.
  9305. */
  9306. getDepthScale(): number;
  9307. /**
  9308. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9309. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9310. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9311. */
  9312. getShadowDirection(faceIndex?: number): Vector3;
  9313. /**
  9314. * Returns the ShadowLight absolute position in the World.
  9315. * @returns the position vector in world space
  9316. */
  9317. getAbsolutePosition(): Vector3;
  9318. /**
  9319. * Sets the ShadowLight direction toward the passed target.
  9320. * @param target The point to target in local space
  9321. * @returns the updated ShadowLight direction
  9322. */
  9323. setDirectionToTarget(target: Vector3): Vector3;
  9324. /**
  9325. * Returns the light rotation in euler definition.
  9326. * @returns the x y z rotation in local space.
  9327. */
  9328. getRotation(): Vector3;
  9329. /**
  9330. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9331. * @returns true if a cube texture needs to be use
  9332. */
  9333. needCube(): boolean;
  9334. /**
  9335. * Detects if the projection matrix requires to be recomputed this frame.
  9336. * @returns true if it requires to be recomputed otherwise, false.
  9337. */
  9338. needProjectionMatrixCompute(): boolean;
  9339. /**
  9340. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9341. */
  9342. forceProjectionMatrixCompute(): void;
  9343. /** @hidden */
  9344. _initCache(): void;
  9345. /** @hidden */
  9346. _isSynchronized(): boolean;
  9347. /**
  9348. * Computes the world matrix of the node
  9349. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9350. * @returns the world matrix
  9351. */
  9352. computeWorldMatrix(force?: boolean): Matrix;
  9353. /**
  9354. * Gets the minZ used for shadow according to both the scene and the light.
  9355. * @param activeCamera The camera we are returning the min for
  9356. * @returns the depth min z
  9357. */
  9358. getDepthMinZ(activeCamera: Camera): number;
  9359. /**
  9360. * Gets the maxZ used for shadow according to both the scene and the light.
  9361. * @param activeCamera The camera we are returning the max for
  9362. * @returns the depth max z
  9363. */
  9364. getDepthMaxZ(activeCamera: Camera): number;
  9365. /**
  9366. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9367. * @param matrix The materix to updated with the projection information
  9368. * @param viewMatrix The transform matrix of the light
  9369. * @param renderList The list of mesh to render in the map
  9370. * @returns The current light
  9371. */
  9372. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9373. }
  9374. }
  9375. declare module "babylonjs/Materials/materialHelper" {
  9376. import { Nullable } from "babylonjs/types";
  9377. import { Scene } from "babylonjs/scene";
  9378. import { Engine } from "babylonjs/Engines/engine";
  9379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9380. import { Light } from "babylonjs/Lights/light";
  9381. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9382. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9384. /**
  9385. * "Static Class" containing the most commonly used helper while dealing with material for
  9386. * rendering purpose.
  9387. *
  9388. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9389. *
  9390. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9391. */
  9392. export class MaterialHelper {
  9393. /**
  9394. * Bind the current view position to an effect.
  9395. * @param effect The effect to be bound
  9396. * @param scene The scene the eyes position is used from
  9397. */
  9398. static BindEyePosition(effect: Effect, scene: Scene): void;
  9399. /**
  9400. * Helps preparing the defines values about the UVs in used in the effect.
  9401. * UVs are shared as much as we can accross channels in the shaders.
  9402. * @param texture The texture we are preparing the UVs for
  9403. * @param defines The defines to update
  9404. * @param key The channel key "diffuse", "specular"... used in the shader
  9405. */
  9406. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9407. /**
  9408. * Binds a texture matrix value to its corrsponding uniform
  9409. * @param texture The texture to bind the matrix for
  9410. * @param uniformBuffer The uniform buffer receivin the data
  9411. * @param key The channel key "diffuse", "specular"... used in the shader
  9412. */
  9413. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9414. /**
  9415. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9416. * @param mesh defines the current mesh
  9417. * @param scene defines the current scene
  9418. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9419. * @param pointsCloud defines if point cloud rendering has to be turned on
  9420. * @param fogEnabled defines if fog has to be turned on
  9421. * @param alphaTest defines if alpha testing has to be turned on
  9422. * @param defines defines the current list of defines
  9423. */
  9424. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9425. /**
  9426. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9427. * @param scene defines the current scene
  9428. * @param engine defines the current engine
  9429. * @param defines specifies the list of active defines
  9430. * @param useInstances defines if instances have to be turned on
  9431. * @param useClipPlane defines if clip plane have to be turned on
  9432. */
  9433. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9434. /**
  9435. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9436. * @param mesh The mesh containing the geometry data we will draw
  9437. * @param defines The defines to update
  9438. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9439. * @param useBones Precise whether bones should be used or not (override mesh info)
  9440. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9441. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9442. * @returns false if defines are considered not dirty and have not been checked
  9443. */
  9444. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9445. /**
  9446. * Prepares the defines related to multiview
  9447. * @param scene The scene we are intending to draw
  9448. * @param defines The defines to update
  9449. */
  9450. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9451. /**
  9452. * Prepares the defines related to the light information passed in parameter
  9453. * @param scene The scene we are intending to draw
  9454. * @param mesh The mesh the effect is compiling for
  9455. * @param defines The defines to update
  9456. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9457. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9458. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9459. * @returns true if normals will be required for the rest of the effect
  9460. */
  9461. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9462. /**
  9463. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9464. * that won t be acctive due to defines being turned off.
  9465. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9466. * @param samplersList The samplers list
  9467. * @param defines The defines helping in the list generation
  9468. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9469. */
  9470. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9471. /**
  9472. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9473. * @param defines The defines to update while falling back
  9474. * @param fallbacks The authorized effect fallbacks
  9475. * @param maxSimultaneousLights The maximum number of lights allowed
  9476. * @param rank the current rank of the Effect
  9477. * @returns The newly affected rank
  9478. */
  9479. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9480. /**
  9481. * Prepares the list of attributes required for morph targets according to the effect defines.
  9482. * @param attribs The current list of supported attribs
  9483. * @param mesh The mesh to prepare the morph targets attributes for
  9484. * @param defines The current Defines of the effect
  9485. */
  9486. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9487. /**
  9488. * Prepares the list of attributes required for bones according to the effect defines.
  9489. * @param attribs The current list of supported attribs
  9490. * @param mesh The mesh to prepare the bones attributes for
  9491. * @param defines The current Defines of the effect
  9492. * @param fallbacks The current efffect fallback strategy
  9493. */
  9494. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9495. /**
  9496. * Prepares the list of attributes required for instances according to the effect defines.
  9497. * @param attribs The current list of supported attribs
  9498. * @param defines The current Defines of the effect
  9499. */
  9500. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9501. /**
  9502. * Binds the light shadow information to the effect for the given mesh.
  9503. * @param light The light containing the generator
  9504. * @param scene The scene the lights belongs to
  9505. * @param mesh The mesh we are binding the information to render
  9506. * @param lightIndex The light index in the effect used to render the mesh
  9507. * @param effect The effect we are binding the data to
  9508. */
  9509. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9510. /**
  9511. * Binds the light information to the effect.
  9512. * @param light The light containing the generator
  9513. * @param effect The effect we are binding the data to
  9514. * @param lightIndex The light index in the effect used to render
  9515. */
  9516. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9517. /**
  9518. * Binds the lights information from the scene to the effect for the given mesh.
  9519. * @param scene The scene the lights belongs to
  9520. * @param mesh The mesh we are binding the information to render
  9521. * @param effect The effect we are binding the data to
  9522. * @param defines The generated defines for the effect
  9523. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9524. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9525. */
  9526. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9527. private static _tempFogColor;
  9528. /**
  9529. * Binds the fog information from the scene to the effect for the given mesh.
  9530. * @param scene The scene the lights belongs to
  9531. * @param mesh The mesh we are binding the information to render
  9532. * @param effect The effect we are binding the data to
  9533. * @param linearSpace Defines if the fog effect is applied in linear space
  9534. */
  9535. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9536. /**
  9537. * Binds the bones information from the mesh to the effect.
  9538. * @param mesh The mesh we are binding the information to render
  9539. * @param effect The effect we are binding the data to
  9540. */
  9541. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9542. /**
  9543. * Binds the morph targets information from the mesh to the effect.
  9544. * @param abstractMesh The mesh we are binding the information to render
  9545. * @param effect The effect we are binding the data to
  9546. */
  9547. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9548. /**
  9549. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9550. * @param defines The generated defines used in the effect
  9551. * @param effect The effect we are binding the data to
  9552. * @param scene The scene we are willing to render with logarithmic scale for
  9553. */
  9554. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9555. /**
  9556. * Binds the clip plane information from the scene to the effect.
  9557. * @param scene The scene the clip plane information are extracted from
  9558. * @param effect The effect we are binding the data to
  9559. */
  9560. static BindClipPlane(effect: Effect, scene: Scene): void;
  9561. }
  9562. }
  9563. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9564. /** @hidden */
  9565. export var kernelBlurVaryingDeclaration: {
  9566. name: string;
  9567. shader: string;
  9568. };
  9569. }
  9570. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9571. /** @hidden */
  9572. export var kernelBlurFragment: {
  9573. name: string;
  9574. shader: string;
  9575. };
  9576. }
  9577. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9578. /** @hidden */
  9579. export var kernelBlurFragment2: {
  9580. name: string;
  9581. shader: string;
  9582. };
  9583. }
  9584. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9585. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9586. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9587. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9588. /** @hidden */
  9589. export var kernelBlurPixelShader: {
  9590. name: string;
  9591. shader: string;
  9592. };
  9593. }
  9594. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9595. /** @hidden */
  9596. export var kernelBlurVertex: {
  9597. name: string;
  9598. shader: string;
  9599. };
  9600. }
  9601. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9602. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9603. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9604. /** @hidden */
  9605. export var kernelBlurVertexShader: {
  9606. name: string;
  9607. shader: string;
  9608. };
  9609. }
  9610. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9611. import { Vector2 } from "babylonjs/Maths/math";
  9612. import { Nullable } from "babylonjs/types";
  9613. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9614. import { Camera } from "babylonjs/Cameras/camera";
  9615. import { Effect } from "babylonjs/Materials/effect";
  9616. import { Engine } from "babylonjs/Engines/engine";
  9617. import "babylonjs/Shaders/kernelBlur.fragment";
  9618. import "babylonjs/Shaders/kernelBlur.vertex";
  9619. /**
  9620. * The Blur Post Process which blurs an image based on a kernel and direction.
  9621. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9622. */
  9623. export class BlurPostProcess extends PostProcess {
  9624. /** The direction in which to blur the image. */
  9625. direction: Vector2;
  9626. private blockCompilation;
  9627. protected _kernel: number;
  9628. protected _idealKernel: number;
  9629. protected _packedFloat: boolean;
  9630. private _staticDefines;
  9631. /**
  9632. * Sets the length in pixels of the blur sample region
  9633. */
  9634. /**
  9635. * Gets the length in pixels of the blur sample region
  9636. */
  9637. kernel: number;
  9638. /**
  9639. * Sets wether or not the blur needs to unpack/repack floats
  9640. */
  9641. /**
  9642. * Gets wether or not the blur is unpacking/repacking floats
  9643. */
  9644. packedFloat: boolean;
  9645. /**
  9646. * Creates a new instance BlurPostProcess
  9647. * @param name The name of the effect.
  9648. * @param direction The direction in which to blur the image.
  9649. * @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.
  9650. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9651. * @param camera The camera to apply the render pass to.
  9652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9653. * @param engine The engine which the post process will be applied. (default: current engine)
  9654. * @param reusable If the post process can be reused on the same frame. (default: false)
  9655. * @param textureType Type of textures used when performing the post process. (default: 0)
  9656. * @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)
  9657. */
  9658. constructor(name: string,
  9659. /** The direction in which to blur the image. */
  9660. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9661. /**
  9662. * Updates the effect with the current post process compile time values and recompiles the shader.
  9663. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9664. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9665. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9666. * @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
  9667. * @param onCompiled Called when the shader has been compiled.
  9668. * @param onError Called if there is an error when compiling a shader.
  9669. */
  9670. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9671. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9672. /**
  9673. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9674. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9675. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9676. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9677. * The gaps between physical kernels are compensated for in the weighting of the samples
  9678. * @param idealKernel Ideal blur kernel.
  9679. * @return Nearest best kernel.
  9680. */
  9681. protected _nearestBestKernel(idealKernel: number): number;
  9682. /**
  9683. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9684. * @param x The point on the Gaussian distribution to sample.
  9685. * @return the value of the Gaussian function at x.
  9686. */
  9687. protected _gaussianWeight(x: number): number;
  9688. /**
  9689. * Generates a string that can be used as a floating point number in GLSL.
  9690. * @param x Value to print.
  9691. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9692. * @return GLSL float string.
  9693. */
  9694. protected _glslFloat(x: number, decimalFigures?: number): string;
  9695. }
  9696. }
  9697. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9698. /** @hidden */
  9699. export var shadowMapPixelShader: {
  9700. name: string;
  9701. shader: string;
  9702. };
  9703. }
  9704. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9705. /** @hidden */
  9706. export var bonesDeclaration: {
  9707. name: string;
  9708. shader: string;
  9709. };
  9710. }
  9711. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9712. /** @hidden */
  9713. export var morphTargetsVertexGlobalDeclaration: {
  9714. name: string;
  9715. shader: string;
  9716. };
  9717. }
  9718. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9719. /** @hidden */
  9720. export var morphTargetsVertexDeclaration: {
  9721. name: string;
  9722. shader: string;
  9723. };
  9724. }
  9725. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9726. /** @hidden */
  9727. export var instancesDeclaration: {
  9728. name: string;
  9729. shader: string;
  9730. };
  9731. }
  9732. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9733. /** @hidden */
  9734. export var helperFunctions: {
  9735. name: string;
  9736. shader: string;
  9737. };
  9738. }
  9739. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9740. /** @hidden */
  9741. export var morphTargetsVertex: {
  9742. name: string;
  9743. shader: string;
  9744. };
  9745. }
  9746. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9747. /** @hidden */
  9748. export var instancesVertex: {
  9749. name: string;
  9750. shader: string;
  9751. };
  9752. }
  9753. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9754. /** @hidden */
  9755. export var bonesVertex: {
  9756. name: string;
  9757. shader: string;
  9758. };
  9759. }
  9760. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9761. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9763. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9764. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9765. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9766. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9767. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9768. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9769. /** @hidden */
  9770. export var shadowMapVertexShader: {
  9771. name: string;
  9772. shader: string;
  9773. };
  9774. }
  9775. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9776. /** @hidden */
  9777. export var depthBoxBlurPixelShader: {
  9778. name: string;
  9779. shader: string;
  9780. };
  9781. }
  9782. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9783. import { Nullable } from "babylonjs/types";
  9784. import { Scene } from "babylonjs/scene";
  9785. import { Matrix } from "babylonjs/Maths/math";
  9786. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9788. import { Mesh } from "babylonjs/Meshes/mesh";
  9789. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9790. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9791. import { Effect } from "babylonjs/Materials/effect";
  9792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9793. import "babylonjs/Shaders/shadowMap.fragment";
  9794. import "babylonjs/Shaders/shadowMap.vertex";
  9795. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9796. import { Observable } from "babylonjs/Misc/observable";
  9797. /**
  9798. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9799. */
  9800. export interface ICustomShaderOptions {
  9801. /**
  9802. * Gets or sets the custom shader name to use
  9803. */
  9804. shaderName: string;
  9805. /**
  9806. * The list of attribute names used in the shader
  9807. */
  9808. attributes?: string[];
  9809. /**
  9810. * The list of unifrom names used in the shader
  9811. */
  9812. uniforms?: string[];
  9813. /**
  9814. * The list of sampler names used in the shader
  9815. */
  9816. samplers?: string[];
  9817. /**
  9818. * The list of defines used in the shader
  9819. */
  9820. defines?: string[];
  9821. }
  9822. /**
  9823. * Interface to implement to create a shadow generator compatible with BJS.
  9824. */
  9825. export interface IShadowGenerator {
  9826. /**
  9827. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9828. * @returns The render target texture if present otherwise, null
  9829. */
  9830. getShadowMap(): Nullable<RenderTargetTexture>;
  9831. /**
  9832. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9833. * @returns The render target texture if the shadow map is present otherwise, null
  9834. */
  9835. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9836. /**
  9837. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9838. * @param subMesh The submesh we want to render in the shadow map
  9839. * @param useInstances Defines wether will draw in the map using instances
  9840. * @returns true if ready otherwise, false
  9841. */
  9842. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9843. /**
  9844. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9845. * @param defines Defines of the material we want to update
  9846. * @param lightIndex Index of the light in the enabled light list of the material
  9847. */
  9848. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9849. /**
  9850. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9851. * defined in the generator but impacting the effect).
  9852. * It implies the unifroms available on the materials are the standard BJS ones.
  9853. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9854. * @param effect The effect we are binfing the information for
  9855. */
  9856. bindShadowLight(lightIndex: string, effect: Effect): void;
  9857. /**
  9858. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9859. * (eq to shadow prjection matrix * light transform matrix)
  9860. * @returns The transform matrix used to create the shadow map
  9861. */
  9862. getTransformMatrix(): Matrix;
  9863. /**
  9864. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9865. * Cube and 2D textures for instance.
  9866. */
  9867. recreateShadowMap(): void;
  9868. /**
  9869. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9870. * @param onCompiled Callback triggered at the and of the effects compilation
  9871. * @param options Sets of optional options forcing the compilation with different modes
  9872. */
  9873. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9874. useInstances: boolean;
  9875. }>): void;
  9876. /**
  9877. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9878. * @param options Sets of optional options forcing the compilation with different modes
  9879. * @returns A promise that resolves when the compilation completes
  9880. */
  9881. forceCompilationAsync(options?: Partial<{
  9882. useInstances: boolean;
  9883. }>): Promise<void>;
  9884. /**
  9885. * Serializes the shadow generator setup to a json object.
  9886. * @returns The serialized JSON object
  9887. */
  9888. serialize(): any;
  9889. /**
  9890. * Disposes the Shadow map and related Textures and effects.
  9891. */
  9892. dispose(): void;
  9893. }
  9894. /**
  9895. * Default implementation IShadowGenerator.
  9896. * This is the main object responsible of generating shadows in the framework.
  9897. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9898. */
  9899. export class ShadowGenerator implements IShadowGenerator {
  9900. /**
  9901. * Shadow generator mode None: no filtering applied.
  9902. */
  9903. static readonly FILTER_NONE: number;
  9904. /**
  9905. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9906. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9907. */
  9908. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9909. /**
  9910. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9911. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9912. */
  9913. static readonly FILTER_POISSONSAMPLING: number;
  9914. /**
  9915. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9916. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9917. */
  9918. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9919. /**
  9920. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9921. * edge artifacts on steep falloff.
  9922. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9923. */
  9924. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9925. /**
  9926. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9927. * edge artifacts on steep falloff.
  9928. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9929. */
  9930. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9931. /**
  9932. * Shadow generator mode PCF: Percentage Closer Filtering
  9933. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9934. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9935. */
  9936. static readonly FILTER_PCF: number;
  9937. /**
  9938. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9939. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9940. * Contact Hardening
  9941. */
  9942. static readonly FILTER_PCSS: number;
  9943. /**
  9944. * Reserved for PCF and PCSS
  9945. * Highest Quality.
  9946. *
  9947. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9948. *
  9949. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9950. */
  9951. static readonly QUALITY_HIGH: number;
  9952. /**
  9953. * Reserved for PCF and PCSS
  9954. * Good tradeoff for quality/perf cross devices
  9955. *
  9956. * Execute PCF on a 3*3 kernel.
  9957. *
  9958. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9959. */
  9960. static readonly QUALITY_MEDIUM: number;
  9961. /**
  9962. * Reserved for PCF and PCSS
  9963. * The lowest quality but the fastest.
  9964. *
  9965. * Execute PCF on a 1*1 kernel.
  9966. *
  9967. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9968. */
  9969. static readonly QUALITY_LOW: number;
  9970. /** Gets or sets the custom shader name to use */
  9971. customShaderOptions: ICustomShaderOptions;
  9972. /**
  9973. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9974. */
  9975. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9976. /**
  9977. * Observable triggered before a mesh is rendered in the shadow map.
  9978. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9979. */
  9980. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9981. private _bias;
  9982. /**
  9983. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9984. */
  9985. /**
  9986. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9987. */
  9988. bias: number;
  9989. private _normalBias;
  9990. /**
  9991. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9992. */
  9993. /**
  9994. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9995. */
  9996. normalBias: number;
  9997. private _blurBoxOffset;
  9998. /**
  9999. * Gets the blur box offset: offset applied during the blur pass.
  10000. * Only useful if useKernelBlur = false
  10001. */
  10002. /**
  10003. * Sets the blur box offset: offset applied during the blur pass.
  10004. * Only useful if useKernelBlur = false
  10005. */
  10006. blurBoxOffset: number;
  10007. private _blurScale;
  10008. /**
  10009. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10010. * 2 means half of the size.
  10011. */
  10012. /**
  10013. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10014. * 2 means half of the size.
  10015. */
  10016. blurScale: number;
  10017. private _blurKernel;
  10018. /**
  10019. * Gets the blur kernel: kernel size of the blur pass.
  10020. * Only useful if useKernelBlur = true
  10021. */
  10022. /**
  10023. * Sets the blur kernel: kernel size of the blur pass.
  10024. * Only useful if useKernelBlur = true
  10025. */
  10026. blurKernel: number;
  10027. private _useKernelBlur;
  10028. /**
  10029. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10030. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10031. */
  10032. /**
  10033. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10034. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10035. */
  10036. useKernelBlur: boolean;
  10037. private _depthScale;
  10038. /**
  10039. * Gets the depth scale used in ESM mode.
  10040. */
  10041. /**
  10042. * Sets the depth scale used in ESM mode.
  10043. * This can override the scale stored on the light.
  10044. */
  10045. depthScale: number;
  10046. private _filter;
  10047. /**
  10048. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10049. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10050. */
  10051. /**
  10052. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10053. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10054. */
  10055. filter: number;
  10056. /**
  10057. * Gets if the current filter is set to Poisson Sampling.
  10058. */
  10059. /**
  10060. * Sets the current filter to Poisson Sampling.
  10061. */
  10062. usePoissonSampling: boolean;
  10063. /**
  10064. * Gets if the current filter is set to ESM.
  10065. */
  10066. /**
  10067. * Sets the current filter is to ESM.
  10068. */
  10069. useExponentialShadowMap: boolean;
  10070. /**
  10071. * Gets if the current filter is set to filtered ESM.
  10072. */
  10073. /**
  10074. * Gets if the current filter is set to filtered ESM.
  10075. */
  10076. useBlurExponentialShadowMap: boolean;
  10077. /**
  10078. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10079. * exponential to prevent steep falloff artifacts).
  10080. */
  10081. /**
  10082. * Sets the current filter to "close ESM" (using the inverse of the
  10083. * exponential to prevent steep falloff artifacts).
  10084. */
  10085. useCloseExponentialShadowMap: boolean;
  10086. /**
  10087. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10088. * exponential to prevent steep falloff artifacts).
  10089. */
  10090. /**
  10091. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10092. * exponential to prevent steep falloff artifacts).
  10093. */
  10094. useBlurCloseExponentialShadowMap: boolean;
  10095. /**
  10096. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10097. */
  10098. /**
  10099. * Sets the current filter to "PCF" (percentage closer filtering).
  10100. */
  10101. usePercentageCloserFiltering: boolean;
  10102. private _filteringQuality;
  10103. /**
  10104. * Gets the PCF or PCSS Quality.
  10105. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10106. */
  10107. /**
  10108. * Sets the PCF or PCSS Quality.
  10109. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10110. */
  10111. filteringQuality: number;
  10112. /**
  10113. * Gets if the current filter is set to "PCSS" (contact hardening).
  10114. */
  10115. /**
  10116. * Sets the current filter to "PCSS" (contact hardening).
  10117. */
  10118. useContactHardeningShadow: boolean;
  10119. private _contactHardeningLightSizeUVRatio;
  10120. /**
  10121. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10122. * Using a ratio helps keeping shape stability independently of the map size.
  10123. *
  10124. * It does not account for the light projection as it was having too much
  10125. * instability during the light setup or during light position changes.
  10126. *
  10127. * Only valid if useContactHardeningShadow is true.
  10128. */
  10129. /**
  10130. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10131. * Using a ratio helps keeping shape stability independently of the map size.
  10132. *
  10133. * It does not account for the light projection as it was having too much
  10134. * instability during the light setup or during light position changes.
  10135. *
  10136. * Only valid if useContactHardeningShadow is true.
  10137. */
  10138. contactHardeningLightSizeUVRatio: number;
  10139. private _darkness;
  10140. /**
  10141. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10142. * 0 means strongest and 1 would means no shadow.
  10143. * @returns the darkness.
  10144. */
  10145. getDarkness(): number;
  10146. /**
  10147. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10148. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10149. * @returns the shadow generator allowing fluent coding.
  10150. */
  10151. setDarkness(darkness: number): ShadowGenerator;
  10152. private _transparencyShadow;
  10153. /**
  10154. * Sets the ability to have transparent shadow (boolean).
  10155. * @param transparent True if transparent else False
  10156. * @returns the shadow generator allowing fluent coding
  10157. */
  10158. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10159. private _shadowMap;
  10160. private _shadowMap2;
  10161. /**
  10162. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10163. * @returns The render target texture if present otherwise, null
  10164. */
  10165. getShadowMap(): Nullable<RenderTargetTexture>;
  10166. /**
  10167. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10168. * @returns The render target texture if the shadow map is present otherwise, null
  10169. */
  10170. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10171. /**
  10172. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10173. * @param mesh Mesh to add
  10174. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10175. * @returns the Shadow Generator itself
  10176. */
  10177. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10178. /**
  10179. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10180. * @param mesh Mesh to remove
  10181. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10182. * @returns the Shadow Generator itself
  10183. */
  10184. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10185. /**
  10186. * Controls the extent to which the shadows fade out at the edge of the frustum
  10187. * Used only by directionals and spots
  10188. */
  10189. frustumEdgeFalloff: number;
  10190. private _light;
  10191. /**
  10192. * Returns the associated light object.
  10193. * @returns the light generating the shadow
  10194. */
  10195. getLight(): IShadowLight;
  10196. /**
  10197. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10198. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10199. * It might on the other hand introduce peter panning.
  10200. */
  10201. forceBackFacesOnly: boolean;
  10202. private _scene;
  10203. private _lightDirection;
  10204. private _effect;
  10205. private _viewMatrix;
  10206. private _projectionMatrix;
  10207. private _transformMatrix;
  10208. private _cachedPosition;
  10209. private _cachedDirection;
  10210. private _cachedDefines;
  10211. private _currentRenderID;
  10212. private _boxBlurPostprocess;
  10213. private _kernelBlurXPostprocess;
  10214. private _kernelBlurYPostprocess;
  10215. private _blurPostProcesses;
  10216. private _mapSize;
  10217. private _currentFaceIndex;
  10218. private _currentFaceIndexCache;
  10219. private _textureType;
  10220. private _defaultTextureMatrix;
  10221. /** @hidden */
  10222. static _SceneComponentInitialization: (scene: Scene) => void;
  10223. /**
  10224. * Creates a ShadowGenerator object.
  10225. * A ShadowGenerator is the required tool to use the shadows.
  10226. * Each light casting shadows needs to use its own ShadowGenerator.
  10227. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10228. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10229. * @param light The light object generating the shadows.
  10230. * @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.
  10231. */
  10232. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10233. private _initializeGenerator;
  10234. private _initializeShadowMap;
  10235. private _initializeBlurRTTAndPostProcesses;
  10236. private _renderForShadowMap;
  10237. private _renderSubMeshForShadowMap;
  10238. private _applyFilterValues;
  10239. /**
  10240. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10241. * @param onCompiled Callback triggered at the and of the effects compilation
  10242. * @param options Sets of optional options forcing the compilation with different modes
  10243. */
  10244. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10245. useInstances: boolean;
  10246. }>): void;
  10247. /**
  10248. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10249. * @param options Sets of optional options forcing the compilation with different modes
  10250. * @returns A promise that resolves when the compilation completes
  10251. */
  10252. forceCompilationAsync(options?: Partial<{
  10253. useInstances: boolean;
  10254. }>): Promise<void>;
  10255. /**
  10256. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10257. * @param subMesh The submesh we want to render in the shadow map
  10258. * @param useInstances Defines wether will draw in the map using instances
  10259. * @returns true if ready otherwise, false
  10260. */
  10261. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10262. /**
  10263. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10264. * @param defines Defines of the material we want to update
  10265. * @param lightIndex Index of the light in the enabled light list of the material
  10266. */
  10267. prepareDefines(defines: any, lightIndex: number): void;
  10268. /**
  10269. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10270. * defined in the generator but impacting the effect).
  10271. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10272. * @param effect The effect we are binfing the information for
  10273. */
  10274. bindShadowLight(lightIndex: string, effect: Effect): void;
  10275. /**
  10276. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10277. * (eq to shadow prjection matrix * light transform matrix)
  10278. * @returns The transform matrix used to create the shadow map
  10279. */
  10280. getTransformMatrix(): Matrix;
  10281. /**
  10282. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10283. * Cube and 2D textures for instance.
  10284. */
  10285. recreateShadowMap(): void;
  10286. private _disposeBlurPostProcesses;
  10287. private _disposeRTTandPostProcesses;
  10288. /**
  10289. * Disposes the ShadowGenerator.
  10290. * Returns nothing.
  10291. */
  10292. dispose(): void;
  10293. /**
  10294. * Serializes the shadow generator setup to a json object.
  10295. * @returns The serialized JSON object
  10296. */
  10297. serialize(): any;
  10298. /**
  10299. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10300. * @param parsedShadowGenerator The JSON object to parse
  10301. * @param scene The scene to create the shadow map for
  10302. * @returns The parsed shadow generator
  10303. */
  10304. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10305. }
  10306. }
  10307. declare module "babylonjs/Lights/light" {
  10308. import { Nullable } from "babylonjs/types";
  10309. import { Scene } from "babylonjs/scene";
  10310. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10311. import { Node } from "babylonjs/node";
  10312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10313. import { Effect } from "babylonjs/Materials/effect";
  10314. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10315. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10316. /**
  10317. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10318. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10319. * 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.
  10320. */
  10321. export abstract class Light extends Node {
  10322. /**
  10323. * Falloff Default: light is falling off following the material specification:
  10324. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10325. */
  10326. static readonly FALLOFF_DEFAULT: number;
  10327. /**
  10328. * Falloff Physical: light is falling off following the inverse squared distance law.
  10329. */
  10330. static readonly FALLOFF_PHYSICAL: number;
  10331. /**
  10332. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10333. * to enhance interoperability with other engines.
  10334. */
  10335. static readonly FALLOFF_GLTF: number;
  10336. /**
  10337. * Falloff Standard: light is falling off like in the standard material
  10338. * to enhance interoperability with other materials.
  10339. */
  10340. static readonly FALLOFF_STANDARD: number;
  10341. /**
  10342. * If every light affecting the material is in this lightmapMode,
  10343. * material.lightmapTexture adds or multiplies
  10344. * (depends on material.useLightmapAsShadowmap)
  10345. * after every other light calculations.
  10346. */
  10347. static readonly LIGHTMAP_DEFAULT: number;
  10348. /**
  10349. * material.lightmapTexture as only diffuse lighting from this light
  10350. * adds only specular lighting from this light
  10351. * adds dynamic shadows
  10352. */
  10353. static readonly LIGHTMAP_SPECULAR: number;
  10354. /**
  10355. * material.lightmapTexture as only lighting
  10356. * no light calculation from this light
  10357. * only adds dynamic shadows from this light
  10358. */
  10359. static readonly LIGHTMAP_SHADOWSONLY: number;
  10360. /**
  10361. * Each light type uses the default quantity according to its type:
  10362. * point/spot lights use luminous intensity
  10363. * directional lights use illuminance
  10364. */
  10365. static readonly INTENSITYMODE_AUTOMATIC: number;
  10366. /**
  10367. * lumen (lm)
  10368. */
  10369. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10370. /**
  10371. * candela (lm/sr)
  10372. */
  10373. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10374. /**
  10375. * lux (lm/m^2)
  10376. */
  10377. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10378. /**
  10379. * nit (cd/m^2)
  10380. */
  10381. static readonly INTENSITYMODE_LUMINANCE: number;
  10382. /**
  10383. * Light type const id of the point light.
  10384. */
  10385. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10386. /**
  10387. * Light type const id of the directional light.
  10388. */
  10389. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10390. /**
  10391. * Light type const id of the spot light.
  10392. */
  10393. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10394. /**
  10395. * Light type const id of the hemispheric light.
  10396. */
  10397. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10398. /**
  10399. * Diffuse gives the basic color to an object.
  10400. */
  10401. diffuse: Color3;
  10402. /**
  10403. * Specular produces a highlight color on an object.
  10404. * Note: This is note affecting PBR materials.
  10405. */
  10406. specular: Color3;
  10407. /**
  10408. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10409. * falling off base on range or angle.
  10410. * This can be set to any values in Light.FALLOFF_x.
  10411. *
  10412. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10413. * other types of materials.
  10414. */
  10415. falloffType: number;
  10416. /**
  10417. * Strength of the light.
  10418. * Note: By default it is define in the framework own unit.
  10419. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10420. */
  10421. intensity: number;
  10422. private _range;
  10423. protected _inverseSquaredRange: number;
  10424. /**
  10425. * Defines how far from the source the light is impacting in scene units.
  10426. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10427. */
  10428. /**
  10429. * Defines how far from the source the light is impacting in scene units.
  10430. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10431. */
  10432. range: number;
  10433. /**
  10434. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10435. * of light.
  10436. */
  10437. private _photometricScale;
  10438. private _intensityMode;
  10439. /**
  10440. * Gets the photometric scale used to interpret the intensity.
  10441. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10442. */
  10443. /**
  10444. * Sets the photometric scale used to interpret the intensity.
  10445. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10446. */
  10447. intensityMode: number;
  10448. private _radius;
  10449. /**
  10450. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10451. */
  10452. /**
  10453. * sets the light radius used by PBR Materials to simulate soft area lights.
  10454. */
  10455. radius: number;
  10456. private _renderPriority;
  10457. /**
  10458. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10459. * exceeding the number allowed of the materials.
  10460. */
  10461. renderPriority: number;
  10462. private _shadowEnabled;
  10463. /**
  10464. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10465. * the current shadow generator.
  10466. */
  10467. /**
  10468. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10469. * the current shadow generator.
  10470. */
  10471. shadowEnabled: boolean;
  10472. private _includedOnlyMeshes;
  10473. /**
  10474. * Gets the only meshes impacted by this light.
  10475. */
  10476. /**
  10477. * Sets the only meshes impacted by this light.
  10478. */
  10479. includedOnlyMeshes: AbstractMesh[];
  10480. private _excludedMeshes;
  10481. /**
  10482. * Gets the meshes not impacted by this light.
  10483. */
  10484. /**
  10485. * Sets the meshes not impacted by this light.
  10486. */
  10487. excludedMeshes: AbstractMesh[];
  10488. private _excludeWithLayerMask;
  10489. /**
  10490. * Gets the layer id use to find what meshes are not impacted by the light.
  10491. * Inactive if 0
  10492. */
  10493. /**
  10494. * Sets the layer id use to find what meshes are not impacted by the light.
  10495. * Inactive if 0
  10496. */
  10497. excludeWithLayerMask: number;
  10498. private _includeOnlyWithLayerMask;
  10499. /**
  10500. * Gets the layer id use to find what meshes are impacted by the light.
  10501. * Inactive if 0
  10502. */
  10503. /**
  10504. * Sets the layer id use to find what meshes are impacted by the light.
  10505. * Inactive if 0
  10506. */
  10507. includeOnlyWithLayerMask: number;
  10508. private _lightmapMode;
  10509. /**
  10510. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10511. */
  10512. /**
  10513. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10514. */
  10515. lightmapMode: number;
  10516. /**
  10517. * Shadow generator associted to the light.
  10518. * @hidden Internal use only.
  10519. */
  10520. _shadowGenerator: Nullable<IShadowGenerator>;
  10521. /**
  10522. * @hidden Internal use only.
  10523. */
  10524. _excludedMeshesIds: string[];
  10525. /**
  10526. * @hidden Internal use only.
  10527. */
  10528. _includedOnlyMeshesIds: string[];
  10529. /**
  10530. * The current light unifom buffer.
  10531. * @hidden Internal use only.
  10532. */
  10533. _uniformBuffer: UniformBuffer;
  10534. /**
  10535. * Creates a Light object in the scene.
  10536. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10537. * @param name The firendly name of the light
  10538. * @param scene The scene the light belongs too
  10539. */
  10540. constructor(name: string, scene: Scene);
  10541. protected abstract _buildUniformLayout(): void;
  10542. /**
  10543. * Sets the passed Effect "effect" with the Light information.
  10544. * @param effect The effect to update
  10545. * @param lightIndex The index of the light in the effect to update
  10546. * @returns The light
  10547. */
  10548. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10549. /**
  10550. * Returns the string "Light".
  10551. * @returns the class name
  10552. */
  10553. getClassName(): string;
  10554. /** @hidden */
  10555. readonly _isLight: boolean;
  10556. /**
  10557. * Converts the light information to a readable string for debug purpose.
  10558. * @param fullDetails Supports for multiple levels of logging within scene loading
  10559. * @returns the human readable light info
  10560. */
  10561. toString(fullDetails?: boolean): string;
  10562. /** @hidden */
  10563. protected _syncParentEnabledState(): void;
  10564. /**
  10565. * Set the enabled state of this node.
  10566. * @param value - the new enabled state
  10567. */
  10568. setEnabled(value: boolean): void;
  10569. /**
  10570. * Returns the Light associated shadow generator if any.
  10571. * @return the associated shadow generator.
  10572. */
  10573. getShadowGenerator(): Nullable<IShadowGenerator>;
  10574. /**
  10575. * Returns a Vector3, the absolute light position in the World.
  10576. * @returns the world space position of the light
  10577. */
  10578. getAbsolutePosition(): Vector3;
  10579. /**
  10580. * Specifies if the light will affect the passed mesh.
  10581. * @param mesh The mesh to test against the light
  10582. * @return true the mesh is affected otherwise, false.
  10583. */
  10584. canAffectMesh(mesh: AbstractMesh): boolean;
  10585. /**
  10586. * Sort function to order lights for rendering.
  10587. * @param a First Light object to compare to second.
  10588. * @param b Second Light object to compare first.
  10589. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10590. */
  10591. static CompareLightsPriority(a: Light, b: Light): number;
  10592. /**
  10593. * Releases resources associated with this node.
  10594. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10595. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10596. */
  10597. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10598. /**
  10599. * Returns the light type ID (integer).
  10600. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10601. */
  10602. getTypeID(): number;
  10603. /**
  10604. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10605. * @returns the scaled intensity in intensity mode unit
  10606. */
  10607. getScaledIntensity(): number;
  10608. /**
  10609. * Returns a new Light object, named "name", from the current one.
  10610. * @param name The name of the cloned light
  10611. * @returns the new created light
  10612. */
  10613. clone(name: string): Nullable<Light>;
  10614. /**
  10615. * Serializes the current light into a Serialization object.
  10616. * @returns the serialized object.
  10617. */
  10618. serialize(): any;
  10619. /**
  10620. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10621. * This new light is named "name" and added to the passed scene.
  10622. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10623. * @param name The friendly name of the light
  10624. * @param scene The scene the new light will belong to
  10625. * @returns the constructor function
  10626. */
  10627. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10628. /**
  10629. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10630. * @param parsedLight The JSON representation of the light
  10631. * @param scene The scene to create the parsed light in
  10632. * @returns the created light after parsing
  10633. */
  10634. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10635. private _hookArrayForExcluded;
  10636. private _hookArrayForIncludedOnly;
  10637. private _resyncMeshes;
  10638. /**
  10639. * Forces the meshes to update their light related information in their rendering used effects
  10640. * @hidden Internal Use Only
  10641. */
  10642. _markMeshesAsLightDirty(): void;
  10643. /**
  10644. * Recomputes the cached photometric scale if needed.
  10645. */
  10646. private _computePhotometricScale;
  10647. /**
  10648. * Returns the Photometric Scale according to the light type and intensity mode.
  10649. */
  10650. private _getPhotometricScale;
  10651. /**
  10652. * Reorder the light in the scene according to their defined priority.
  10653. * @hidden Internal Use Only
  10654. */
  10655. _reorderLightsInScene(): void;
  10656. /**
  10657. * Prepares the list of defines specific to the light type.
  10658. * @param defines the list of defines
  10659. * @param lightIndex defines the index of the light for the effect
  10660. */
  10661. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10662. }
  10663. }
  10664. declare module "babylonjs/Actions/action" {
  10665. import { Observable } from "babylonjs/Misc/observable";
  10666. import { Condition } from "babylonjs/Actions/condition";
  10667. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10668. import { ActionManager } from "babylonjs/Actions/actionManager";
  10669. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10670. /**
  10671. * Interface used to define Action
  10672. */
  10673. export interface IAction {
  10674. /**
  10675. * Trigger for the action
  10676. */
  10677. trigger: number;
  10678. /** Options of the trigger */
  10679. triggerOptions: any;
  10680. /**
  10681. * Gets the trigger parameters
  10682. * @returns the trigger parameters
  10683. */
  10684. getTriggerParameter(): any;
  10685. /**
  10686. * Internal only - executes current action event
  10687. * @hidden
  10688. */
  10689. _executeCurrent(evt?: ActionEvent): void;
  10690. /**
  10691. * Serialize placeholder for child classes
  10692. * @param parent of child
  10693. * @returns the serialized object
  10694. */
  10695. serialize(parent: any): any;
  10696. /**
  10697. * Internal only
  10698. * @hidden
  10699. */
  10700. _prepare(): void;
  10701. /**
  10702. * Internal only - manager for action
  10703. * @hidden
  10704. */
  10705. _actionManager: AbstractActionManager;
  10706. }
  10707. /**
  10708. * The action to be carried out following a trigger
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10710. */
  10711. export class Action implements IAction {
  10712. /** the trigger, with or without parameters, for the action */
  10713. triggerOptions: any;
  10714. /**
  10715. * Trigger for the action
  10716. */
  10717. trigger: number;
  10718. /**
  10719. * Internal only - manager for action
  10720. * @hidden
  10721. */
  10722. _actionManager: ActionManager;
  10723. private _nextActiveAction;
  10724. private _child;
  10725. private _condition?;
  10726. private _triggerParameter;
  10727. /**
  10728. * An event triggered prior to action being executed.
  10729. */
  10730. onBeforeExecuteObservable: Observable<Action>;
  10731. /**
  10732. * Creates a new Action
  10733. * @param triggerOptions the trigger, with or without parameters, for the action
  10734. * @param condition an optional determinant of action
  10735. */
  10736. constructor(
  10737. /** the trigger, with or without parameters, for the action */
  10738. triggerOptions: any, condition?: Condition);
  10739. /**
  10740. * Internal only
  10741. * @hidden
  10742. */
  10743. _prepare(): void;
  10744. /**
  10745. * Gets the trigger parameters
  10746. * @returns the trigger parameters
  10747. */
  10748. getTriggerParameter(): any;
  10749. /**
  10750. * Internal only - executes current action event
  10751. * @hidden
  10752. */
  10753. _executeCurrent(evt?: ActionEvent): void;
  10754. /**
  10755. * Execute placeholder for child classes
  10756. * @param evt optional action event
  10757. */
  10758. execute(evt?: ActionEvent): void;
  10759. /**
  10760. * Skips to next active action
  10761. */
  10762. skipToNextActiveAction(): void;
  10763. /**
  10764. * Adds action to chain of actions, may be a DoNothingAction
  10765. * @param action defines the next action to execute
  10766. * @returns The action passed in
  10767. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10768. */
  10769. then(action: Action): Action;
  10770. /**
  10771. * Internal only
  10772. * @hidden
  10773. */
  10774. _getProperty(propertyPath: string): string;
  10775. /**
  10776. * Internal only
  10777. * @hidden
  10778. */
  10779. _getEffectiveTarget(target: any, propertyPath: string): any;
  10780. /**
  10781. * Serialize placeholder for child classes
  10782. * @param parent of child
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. /**
  10787. * Internal only called by serialize
  10788. * @hidden
  10789. */
  10790. protected _serialize(serializedAction: any, parent?: any): any;
  10791. /**
  10792. * Internal only
  10793. * @hidden
  10794. */
  10795. static _SerializeValueAsString: (value: any) => string;
  10796. /**
  10797. * Internal only
  10798. * @hidden
  10799. */
  10800. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10801. name: string;
  10802. targetType: string;
  10803. value: string;
  10804. };
  10805. }
  10806. }
  10807. declare module "babylonjs/Actions/condition" {
  10808. import { ActionManager } from "babylonjs/Actions/actionManager";
  10809. /**
  10810. * A Condition applied to an Action
  10811. */
  10812. export class Condition {
  10813. /**
  10814. * Internal only - manager for action
  10815. * @hidden
  10816. */
  10817. _actionManager: ActionManager;
  10818. /**
  10819. * Internal only
  10820. * @hidden
  10821. */
  10822. _evaluationId: number;
  10823. /**
  10824. * Internal only
  10825. * @hidden
  10826. */
  10827. _currentResult: boolean;
  10828. /**
  10829. * Creates a new Condition
  10830. * @param actionManager the manager of the action the condition is applied to
  10831. */
  10832. constructor(actionManager: ActionManager);
  10833. /**
  10834. * Check if the current condition is valid
  10835. * @returns a boolean
  10836. */
  10837. isValid(): boolean;
  10838. /**
  10839. * Internal only
  10840. * @hidden
  10841. */
  10842. _getProperty(propertyPath: string): string;
  10843. /**
  10844. * Internal only
  10845. * @hidden
  10846. */
  10847. _getEffectiveTarget(target: any, propertyPath: string): any;
  10848. /**
  10849. * Serialize placeholder for child classes
  10850. * @returns the serialized object
  10851. */
  10852. serialize(): any;
  10853. /**
  10854. * Internal only
  10855. * @hidden
  10856. */
  10857. protected _serialize(serializedCondition: any): any;
  10858. }
  10859. /**
  10860. * Defines specific conditional operators as extensions of Condition
  10861. */
  10862. export class ValueCondition extends Condition {
  10863. /** path to specify the property of the target the conditional operator uses */
  10864. propertyPath: string;
  10865. /** the value compared by the conditional operator against the current value of the property */
  10866. value: any;
  10867. /** the conditional operator, default ValueCondition.IsEqual */
  10868. operator: number;
  10869. /**
  10870. * Internal only
  10871. * @hidden
  10872. */
  10873. private static _IsEqual;
  10874. /**
  10875. * Internal only
  10876. * @hidden
  10877. */
  10878. private static _IsDifferent;
  10879. /**
  10880. * Internal only
  10881. * @hidden
  10882. */
  10883. private static _IsGreater;
  10884. /**
  10885. * Internal only
  10886. * @hidden
  10887. */
  10888. private static _IsLesser;
  10889. /**
  10890. * returns the number for IsEqual
  10891. */
  10892. static readonly IsEqual: number;
  10893. /**
  10894. * Returns the number for IsDifferent
  10895. */
  10896. static readonly IsDifferent: number;
  10897. /**
  10898. * Returns the number for IsGreater
  10899. */
  10900. static readonly IsGreater: number;
  10901. /**
  10902. * Returns the number for IsLesser
  10903. */
  10904. static readonly IsLesser: number;
  10905. /**
  10906. * Internal only The action manager for the condition
  10907. * @hidden
  10908. */
  10909. _actionManager: ActionManager;
  10910. /**
  10911. * Internal only
  10912. * @hidden
  10913. */
  10914. private _target;
  10915. /**
  10916. * Internal only
  10917. * @hidden
  10918. */
  10919. private _effectiveTarget;
  10920. /**
  10921. * Internal only
  10922. * @hidden
  10923. */
  10924. private _property;
  10925. /**
  10926. * Creates a new ValueCondition
  10927. * @param actionManager manager for the action the condition applies to
  10928. * @param target for the action
  10929. * @param propertyPath path to specify the property of the target the conditional operator uses
  10930. * @param value the value compared by the conditional operator against the current value of the property
  10931. * @param operator the conditional operator, default ValueCondition.IsEqual
  10932. */
  10933. constructor(actionManager: ActionManager, target: any,
  10934. /** path to specify the property of the target the conditional operator uses */
  10935. propertyPath: string,
  10936. /** the value compared by the conditional operator against the current value of the property */
  10937. value: any,
  10938. /** the conditional operator, default ValueCondition.IsEqual */
  10939. operator?: number);
  10940. /**
  10941. * Compares the given value with the property value for the specified conditional operator
  10942. * @returns the result of the comparison
  10943. */
  10944. isValid(): boolean;
  10945. /**
  10946. * Serialize the ValueCondition into a JSON compatible object
  10947. * @returns serialization object
  10948. */
  10949. serialize(): any;
  10950. /**
  10951. * Gets the name of the conditional operator for the ValueCondition
  10952. * @param operator the conditional operator
  10953. * @returns the name
  10954. */
  10955. static GetOperatorName(operator: number): string;
  10956. }
  10957. /**
  10958. * Defines a predicate condition as an extension of Condition
  10959. */
  10960. export class PredicateCondition extends Condition {
  10961. /** defines the predicate function used to validate the condition */
  10962. predicate: () => boolean;
  10963. /**
  10964. * Internal only - manager for action
  10965. * @hidden
  10966. */
  10967. _actionManager: ActionManager;
  10968. /**
  10969. * Creates a new PredicateCondition
  10970. * @param actionManager manager for the action the condition applies to
  10971. * @param predicate defines the predicate function used to validate the condition
  10972. */
  10973. constructor(actionManager: ActionManager,
  10974. /** defines the predicate function used to validate the condition */
  10975. predicate: () => boolean);
  10976. /**
  10977. * @returns the validity of the predicate condition
  10978. */
  10979. isValid(): boolean;
  10980. }
  10981. /**
  10982. * Defines a state condition as an extension of Condition
  10983. */
  10984. export class StateCondition extends Condition {
  10985. /** Value to compare with target state */
  10986. value: string;
  10987. /**
  10988. * Internal only - manager for action
  10989. * @hidden
  10990. */
  10991. _actionManager: ActionManager;
  10992. /**
  10993. * Internal only
  10994. * @hidden
  10995. */
  10996. private _target;
  10997. /**
  10998. * Creates a new StateCondition
  10999. * @param actionManager manager for the action the condition applies to
  11000. * @param target of the condition
  11001. * @param value to compare with target state
  11002. */
  11003. constructor(actionManager: ActionManager, target: any,
  11004. /** Value to compare with target state */
  11005. value: string);
  11006. /**
  11007. * Gets a boolean indicating if the current condition is met
  11008. * @returns the validity of the state
  11009. */
  11010. isValid(): boolean;
  11011. /**
  11012. * Serialize the StateCondition into a JSON compatible object
  11013. * @returns serialization object
  11014. */
  11015. serialize(): any;
  11016. }
  11017. }
  11018. declare module "babylonjs/Actions/directActions" {
  11019. import { Action } from "babylonjs/Actions/action";
  11020. import { Condition } from "babylonjs/Actions/condition";
  11021. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11022. /**
  11023. * This defines an action responsible to toggle a boolean once triggered.
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11025. */
  11026. export class SwitchBooleanAction extends Action {
  11027. /**
  11028. * The path to the boolean property in the target object
  11029. */
  11030. propertyPath: string;
  11031. private _target;
  11032. private _effectiveTarget;
  11033. private _property;
  11034. /**
  11035. * Instantiate the action
  11036. * @param triggerOptions defines the trigger options
  11037. * @param target defines the object containing the boolean
  11038. * @param propertyPath defines the path to the boolean property in the target object
  11039. * @param condition defines the trigger related conditions
  11040. */
  11041. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11042. /** @hidden */
  11043. _prepare(): void;
  11044. /**
  11045. * Execute the action toggle the boolean value.
  11046. */
  11047. execute(): void;
  11048. /**
  11049. * Serializes the actions and its related information.
  11050. * @param parent defines the object to serialize in
  11051. * @returns the serialized object
  11052. */
  11053. serialize(parent: any): any;
  11054. }
  11055. /**
  11056. * This defines an action responsible to set a the state field of the target
  11057. * to a desired value once triggered.
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11059. */
  11060. export class SetStateAction extends Action {
  11061. /**
  11062. * The value to store in the state field.
  11063. */
  11064. value: string;
  11065. private _target;
  11066. /**
  11067. * Instantiate the action
  11068. * @param triggerOptions defines the trigger options
  11069. * @param target defines the object containing the state property
  11070. * @param value defines the value to store in the state field
  11071. * @param condition defines the trigger related conditions
  11072. */
  11073. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11074. /**
  11075. * Execute the action and store the value on the target state property.
  11076. */
  11077. execute(): void;
  11078. /**
  11079. * Serializes the actions and its related information.
  11080. * @param parent defines the object to serialize in
  11081. * @returns the serialized object
  11082. */
  11083. serialize(parent: any): any;
  11084. }
  11085. /**
  11086. * This defines an action responsible to set a property of the target
  11087. * to a desired value once triggered.
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11089. */
  11090. export class SetValueAction extends Action {
  11091. /**
  11092. * The path of the property to set in the target.
  11093. */
  11094. propertyPath: string;
  11095. /**
  11096. * The value to set in the property
  11097. */
  11098. value: any;
  11099. private _target;
  11100. private _effectiveTarget;
  11101. private _property;
  11102. /**
  11103. * Instantiate the action
  11104. * @param triggerOptions defines the trigger options
  11105. * @param target defines the object containing the property
  11106. * @param propertyPath defines the path of the property to set in the target
  11107. * @param value defines the value to set in the property
  11108. * @param condition defines the trigger related conditions
  11109. */
  11110. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11111. /** @hidden */
  11112. _prepare(): void;
  11113. /**
  11114. * Execute the action and set the targetted property to the desired value.
  11115. */
  11116. execute(): void;
  11117. /**
  11118. * Serializes the actions and its related information.
  11119. * @param parent defines the object to serialize in
  11120. * @returns the serialized object
  11121. */
  11122. serialize(parent: any): any;
  11123. }
  11124. /**
  11125. * This defines an action responsible to increment the target value
  11126. * to a desired value once triggered.
  11127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11128. */
  11129. export class IncrementValueAction extends Action {
  11130. /**
  11131. * The path of the property to increment in the target.
  11132. */
  11133. propertyPath: string;
  11134. /**
  11135. * The value we should increment the property by.
  11136. */
  11137. value: any;
  11138. private _target;
  11139. private _effectiveTarget;
  11140. private _property;
  11141. /**
  11142. * Instantiate the action
  11143. * @param triggerOptions defines the trigger options
  11144. * @param target defines the object containing the property
  11145. * @param propertyPath defines the path of the property to increment in the target
  11146. * @param value defines the value value we should increment the property by
  11147. * @param condition defines the trigger related conditions
  11148. */
  11149. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11150. /** @hidden */
  11151. _prepare(): void;
  11152. /**
  11153. * Execute the action and increment the target of the value amount.
  11154. */
  11155. execute(): void;
  11156. /**
  11157. * Serializes the actions and its related information.
  11158. * @param parent defines the object to serialize in
  11159. * @returns the serialized object
  11160. */
  11161. serialize(parent: any): any;
  11162. }
  11163. /**
  11164. * This defines an action responsible to start an animation once triggered.
  11165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11166. */
  11167. export class PlayAnimationAction extends Action {
  11168. /**
  11169. * Where the animation should start (animation frame)
  11170. */
  11171. from: number;
  11172. /**
  11173. * Where the animation should stop (animation frame)
  11174. */
  11175. to: number;
  11176. /**
  11177. * Define if the animation should loop or stop after the first play.
  11178. */
  11179. loop?: boolean;
  11180. private _target;
  11181. /**
  11182. * Instantiate the action
  11183. * @param triggerOptions defines the trigger options
  11184. * @param target defines the target animation or animation name
  11185. * @param from defines from where the animation should start (animation frame)
  11186. * @param end defines where the animation should stop (animation frame)
  11187. * @param loop defines if the animation should loop or stop after the first play
  11188. * @param condition defines the trigger related conditions
  11189. */
  11190. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11191. /** @hidden */
  11192. _prepare(): void;
  11193. /**
  11194. * Execute the action and play the animation.
  11195. */
  11196. execute(): void;
  11197. /**
  11198. * Serializes the actions and its related information.
  11199. * @param parent defines the object to serialize in
  11200. * @returns the serialized object
  11201. */
  11202. serialize(parent: any): any;
  11203. }
  11204. /**
  11205. * This defines an action responsible to stop an animation once triggered.
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11207. */
  11208. export class StopAnimationAction extends Action {
  11209. private _target;
  11210. /**
  11211. * Instantiate the action
  11212. * @param triggerOptions defines the trigger options
  11213. * @param target defines the target animation or animation name
  11214. * @param condition defines the trigger related conditions
  11215. */
  11216. constructor(triggerOptions: any, target: any, condition?: Condition);
  11217. /** @hidden */
  11218. _prepare(): void;
  11219. /**
  11220. * Execute the action and stop the animation.
  11221. */
  11222. execute(): void;
  11223. /**
  11224. * Serializes the actions and its related information.
  11225. * @param parent defines the object to serialize in
  11226. * @returns the serialized object
  11227. */
  11228. serialize(parent: any): any;
  11229. }
  11230. /**
  11231. * This defines an action responsible that does nothing once triggered.
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11233. */
  11234. export class DoNothingAction extends Action {
  11235. /**
  11236. * Instantiate the action
  11237. * @param triggerOptions defines the trigger options
  11238. * @param condition defines the trigger related conditions
  11239. */
  11240. constructor(triggerOptions?: any, condition?: Condition);
  11241. /**
  11242. * Execute the action and do nothing.
  11243. */
  11244. execute(): void;
  11245. /**
  11246. * Serializes the actions and its related information.
  11247. * @param parent defines the object to serialize in
  11248. * @returns the serialized object
  11249. */
  11250. serialize(parent: any): any;
  11251. }
  11252. /**
  11253. * This defines an action responsible to trigger several actions once triggered.
  11254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11255. */
  11256. export class CombineAction extends Action {
  11257. /**
  11258. * The list of aggregated animations to run.
  11259. */
  11260. children: Action[];
  11261. /**
  11262. * Instantiate the action
  11263. * @param triggerOptions defines the trigger options
  11264. * @param children defines the list of aggregated animations to run
  11265. * @param condition defines the trigger related conditions
  11266. */
  11267. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11268. /** @hidden */
  11269. _prepare(): void;
  11270. /**
  11271. * Execute the action and executes all the aggregated actions.
  11272. */
  11273. execute(evt: ActionEvent): void;
  11274. /**
  11275. * Serializes the actions and its related information.
  11276. * @param parent defines the object to serialize in
  11277. * @returns the serialized object
  11278. */
  11279. serialize(parent: any): any;
  11280. }
  11281. /**
  11282. * This defines an action responsible to run code (external event) once triggered.
  11283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11284. */
  11285. export class ExecuteCodeAction extends Action {
  11286. /**
  11287. * The callback function to run.
  11288. */
  11289. func: (evt: ActionEvent) => void;
  11290. /**
  11291. * Instantiate the action
  11292. * @param triggerOptions defines the trigger options
  11293. * @param func defines the callback function to run
  11294. * @param condition defines the trigger related conditions
  11295. */
  11296. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11297. /**
  11298. * Execute the action and run the attached code.
  11299. */
  11300. execute(evt: ActionEvent): void;
  11301. }
  11302. /**
  11303. * This defines an action responsible to set the parent property of the target once triggered.
  11304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11305. */
  11306. export class SetParentAction extends Action {
  11307. private _parent;
  11308. private _target;
  11309. /**
  11310. * Instantiate the action
  11311. * @param triggerOptions defines the trigger options
  11312. * @param target defines the target containing the parent property
  11313. * @param parent defines from where the animation should start (animation frame)
  11314. * @param condition defines the trigger related conditions
  11315. */
  11316. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11317. /** @hidden */
  11318. _prepare(): void;
  11319. /**
  11320. * Execute the action and set the parent property.
  11321. */
  11322. execute(): void;
  11323. /**
  11324. * Serializes the actions and its related information.
  11325. * @param parent defines the object to serialize in
  11326. * @returns the serialized object
  11327. */
  11328. serialize(parent: any): any;
  11329. }
  11330. }
  11331. declare module "babylonjs/Actions/actionManager" {
  11332. import { Nullable } from "babylonjs/types";
  11333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11334. import { Scene } from "babylonjs/scene";
  11335. import { IAction } from "babylonjs/Actions/action";
  11336. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11337. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11338. /**
  11339. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11340. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11342. */
  11343. export class ActionManager extends AbstractActionManager {
  11344. /**
  11345. * Nothing
  11346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11347. */
  11348. static readonly NothingTrigger: number;
  11349. /**
  11350. * On pick
  11351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11352. */
  11353. static readonly OnPickTrigger: number;
  11354. /**
  11355. * On left pick
  11356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11357. */
  11358. static readonly OnLeftPickTrigger: number;
  11359. /**
  11360. * On right pick
  11361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11362. */
  11363. static readonly OnRightPickTrigger: number;
  11364. /**
  11365. * On center pick
  11366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11367. */
  11368. static readonly OnCenterPickTrigger: number;
  11369. /**
  11370. * On pick down
  11371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11372. */
  11373. static readonly OnPickDownTrigger: number;
  11374. /**
  11375. * On double pick
  11376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11377. */
  11378. static readonly OnDoublePickTrigger: number;
  11379. /**
  11380. * On pick up
  11381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11382. */
  11383. static readonly OnPickUpTrigger: number;
  11384. /**
  11385. * On pick out.
  11386. * This trigger will only be raised if you also declared a OnPickDown
  11387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11388. */
  11389. static readonly OnPickOutTrigger: number;
  11390. /**
  11391. * On long press
  11392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11393. */
  11394. static readonly OnLongPressTrigger: number;
  11395. /**
  11396. * On pointer over
  11397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11398. */
  11399. static readonly OnPointerOverTrigger: number;
  11400. /**
  11401. * On pointer out
  11402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11403. */
  11404. static readonly OnPointerOutTrigger: number;
  11405. /**
  11406. * On every frame
  11407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11408. */
  11409. static readonly OnEveryFrameTrigger: number;
  11410. /**
  11411. * On intersection enter
  11412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11413. */
  11414. static readonly OnIntersectionEnterTrigger: number;
  11415. /**
  11416. * On intersection exit
  11417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11418. */
  11419. static readonly OnIntersectionExitTrigger: number;
  11420. /**
  11421. * On key down
  11422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11423. */
  11424. static readonly OnKeyDownTrigger: number;
  11425. /**
  11426. * On key up
  11427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11428. */
  11429. static readonly OnKeyUpTrigger: number;
  11430. private _scene;
  11431. /**
  11432. * Creates a new action manager
  11433. * @param scene defines the hosting scene
  11434. */
  11435. constructor(scene: Scene);
  11436. /**
  11437. * Releases all associated resources
  11438. */
  11439. dispose(): void;
  11440. /**
  11441. * Gets hosting scene
  11442. * @returns the hosting scene
  11443. */
  11444. getScene(): Scene;
  11445. /**
  11446. * Does this action manager handles actions of any of the given triggers
  11447. * @param triggers defines the triggers to be tested
  11448. * @return a boolean indicating whether one (or more) of the triggers is handled
  11449. */
  11450. hasSpecificTriggers(triggers: number[]): boolean;
  11451. /**
  11452. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11453. * speed.
  11454. * @param triggerA defines the trigger to be tested
  11455. * @param triggerB defines the trigger to be tested
  11456. * @return a boolean indicating whether one (or more) of the triggers is handled
  11457. */
  11458. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11459. /**
  11460. * Does this action manager handles actions of a given trigger
  11461. * @param trigger defines the trigger to be tested
  11462. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11463. * @return whether the trigger is handled
  11464. */
  11465. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11466. /**
  11467. * Does this action manager has pointer triggers
  11468. */
  11469. readonly hasPointerTriggers: boolean;
  11470. /**
  11471. * Does this action manager has pick triggers
  11472. */
  11473. readonly hasPickTriggers: boolean;
  11474. /**
  11475. * Registers an action to this action manager
  11476. * @param action defines the action to be registered
  11477. * @return the action amended (prepared) after registration
  11478. */
  11479. registerAction(action: IAction): Nullable<IAction>;
  11480. /**
  11481. * Unregisters an action to this action manager
  11482. * @param action defines the action to be unregistered
  11483. * @return a boolean indicating whether the action has been unregistered
  11484. */
  11485. unregisterAction(action: IAction): Boolean;
  11486. /**
  11487. * Process a specific trigger
  11488. * @param trigger defines the trigger to process
  11489. * @param evt defines the event details to be processed
  11490. */
  11491. processTrigger(trigger: number, evt?: IActionEvent): void;
  11492. /** @hidden */
  11493. _getEffectiveTarget(target: any, propertyPath: string): any;
  11494. /** @hidden */
  11495. _getProperty(propertyPath: string): string;
  11496. /**
  11497. * Serialize this manager to a JSON object
  11498. * @param name defines the property name to store this manager
  11499. * @returns a JSON representation of this manager
  11500. */
  11501. serialize(name: string): any;
  11502. /**
  11503. * Creates a new ActionManager from a JSON data
  11504. * @param parsedActions defines the JSON data to read from
  11505. * @param object defines the hosting mesh
  11506. * @param scene defines the hosting scene
  11507. */
  11508. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11509. /**
  11510. * Get a trigger name by index
  11511. * @param trigger defines the trigger index
  11512. * @returns a trigger name
  11513. */
  11514. static GetTriggerName(trigger: number): string;
  11515. }
  11516. }
  11517. declare module "babylonjs/Culling/ray" {
  11518. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11519. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11521. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11522. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11523. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11524. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11525. /**
  11526. * Class representing a ray with position and direction
  11527. */
  11528. export class Ray {
  11529. /** origin point */
  11530. origin: Vector3;
  11531. /** direction */
  11532. direction: Vector3;
  11533. /** length of the ray */
  11534. length: number;
  11535. private static readonly TmpVector3;
  11536. private _tmpRay;
  11537. /**
  11538. * Creates a new ray
  11539. * @param origin origin point
  11540. * @param direction direction
  11541. * @param length length of the ray
  11542. */
  11543. constructor(
  11544. /** origin point */
  11545. origin: Vector3,
  11546. /** direction */
  11547. direction: Vector3,
  11548. /** length of the ray */
  11549. length?: number);
  11550. /**
  11551. * Checks if the ray intersects a box
  11552. * @param minimum bound of the box
  11553. * @param maximum bound of the box
  11554. * @param intersectionTreshold extra extend to be added to the box in all direction
  11555. * @returns if the box was hit
  11556. */
  11557. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11558. /**
  11559. * Checks if the ray intersects a box
  11560. * @param box the bounding box to check
  11561. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11562. * @returns if the box was hit
  11563. */
  11564. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11565. /**
  11566. * If the ray hits a sphere
  11567. * @param sphere the bounding sphere to check
  11568. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11569. * @returns true if it hits the sphere
  11570. */
  11571. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11572. /**
  11573. * If the ray hits a triange
  11574. * @param vertex0 triangle vertex
  11575. * @param vertex1 triangle vertex
  11576. * @param vertex2 triangle vertex
  11577. * @returns intersection information if hit
  11578. */
  11579. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11580. /**
  11581. * Checks if ray intersects a plane
  11582. * @param plane the plane to check
  11583. * @returns the distance away it was hit
  11584. */
  11585. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11586. /**
  11587. * Checks if ray intersects a mesh
  11588. * @param mesh the mesh to check
  11589. * @param fastCheck if only the bounding box should checked
  11590. * @returns picking info of the intersecton
  11591. */
  11592. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11593. /**
  11594. * Checks if ray intersects a mesh
  11595. * @param meshes the meshes to check
  11596. * @param fastCheck if only the bounding box should checked
  11597. * @param results array to store result in
  11598. * @returns Array of picking infos
  11599. */
  11600. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11601. private _comparePickingInfo;
  11602. private static smallnum;
  11603. private static rayl;
  11604. /**
  11605. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11606. * @param sega the first point of the segment to test the intersection against
  11607. * @param segb the second point of the segment to test the intersection against
  11608. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11609. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11610. */
  11611. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11612. /**
  11613. * Update the ray from viewport position
  11614. * @param x position
  11615. * @param y y position
  11616. * @param viewportWidth viewport width
  11617. * @param viewportHeight viewport height
  11618. * @param world world matrix
  11619. * @param view view matrix
  11620. * @param projection projection matrix
  11621. * @returns this ray updated
  11622. */
  11623. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11624. /**
  11625. * Creates a ray with origin and direction of 0,0,0
  11626. * @returns the new ray
  11627. */
  11628. static Zero(): Ray;
  11629. /**
  11630. * Creates a new ray from screen space and viewport
  11631. * @param x position
  11632. * @param y y position
  11633. * @param viewportWidth viewport width
  11634. * @param viewportHeight viewport height
  11635. * @param world world matrix
  11636. * @param view view matrix
  11637. * @param projection projection matrix
  11638. * @returns new ray
  11639. */
  11640. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11641. /**
  11642. * 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
  11643. * transformed to the given world matrix.
  11644. * @param origin The origin point
  11645. * @param end The end point
  11646. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11647. * @returns the new ray
  11648. */
  11649. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11650. /**
  11651. * Transforms a ray by a matrix
  11652. * @param ray ray to transform
  11653. * @param matrix matrix to apply
  11654. * @returns the resulting new ray
  11655. */
  11656. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11657. /**
  11658. * Transforms a ray by a matrix
  11659. * @param ray ray to transform
  11660. * @param matrix matrix to apply
  11661. * @param result ray to store result in
  11662. */
  11663. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11664. /**
  11665. * Unproject a ray from screen space to object space
  11666. * @param sourceX defines the screen space x coordinate to use
  11667. * @param sourceY defines the screen space y coordinate to use
  11668. * @param viewportWidth defines the current width of the viewport
  11669. * @param viewportHeight defines the current height of the viewport
  11670. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11671. * @param view defines the view matrix to use
  11672. * @param projection defines the projection matrix to use
  11673. */
  11674. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11675. }
  11676. /**
  11677. * Type used to define predicate used to select faces when a mesh intersection is detected
  11678. */
  11679. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11680. module "babylonjs/scene" {
  11681. interface Scene {
  11682. /** @hidden */
  11683. _tempPickingRay: Nullable<Ray>;
  11684. /** @hidden */
  11685. _cachedRayForTransform: Ray;
  11686. /** @hidden */
  11687. _pickWithRayInverseMatrix: Matrix;
  11688. /** @hidden */
  11689. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11690. /** @hidden */
  11691. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11692. }
  11693. }
  11694. }
  11695. declare module "babylonjs/sceneComponent" {
  11696. import { Scene } from "babylonjs/scene";
  11697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11698. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11699. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11700. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11701. import { Nullable } from "babylonjs/types";
  11702. import { Camera } from "babylonjs/Cameras/camera";
  11703. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11704. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11705. import { AbstractScene } from "babylonjs/abstractScene";
  11706. /**
  11707. * Groups all the scene component constants in one place to ease maintenance.
  11708. * @hidden
  11709. */
  11710. export class SceneComponentConstants {
  11711. static readonly NAME_EFFECTLAYER: string;
  11712. static readonly NAME_LAYER: string;
  11713. static readonly NAME_LENSFLARESYSTEM: string;
  11714. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11715. static readonly NAME_PARTICLESYSTEM: string;
  11716. static readonly NAME_GAMEPAD: string;
  11717. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11718. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11719. static readonly NAME_DEPTHRENDERER: string;
  11720. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11721. static readonly NAME_SPRITE: string;
  11722. static readonly NAME_OUTLINERENDERER: string;
  11723. static readonly NAME_PROCEDURALTEXTURE: string;
  11724. static readonly NAME_SHADOWGENERATOR: string;
  11725. static readonly NAME_OCTREE: string;
  11726. static readonly NAME_PHYSICSENGINE: string;
  11727. static readonly NAME_AUDIO: string;
  11728. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11729. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11730. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11731. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11732. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11733. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11734. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11735. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11736. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11737. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11738. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11739. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11740. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11741. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11742. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11743. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11744. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11745. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11746. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11747. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11748. static readonly STEP_AFTERRENDER_AUDIO: number;
  11749. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11750. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11751. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11752. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11753. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11754. static readonly STEP_POINTERMOVE_SPRITE: number;
  11755. static readonly STEP_POINTERDOWN_SPRITE: number;
  11756. static readonly STEP_POINTERUP_SPRITE: number;
  11757. }
  11758. /**
  11759. * This represents a scene component.
  11760. *
  11761. * This is used to decouple the dependency the scene is having on the different workloads like
  11762. * layers, post processes...
  11763. */
  11764. export interface ISceneComponent {
  11765. /**
  11766. * The name of the component. Each component must have a unique name.
  11767. */
  11768. name: string;
  11769. /**
  11770. * The scene the component belongs to.
  11771. */
  11772. scene: Scene;
  11773. /**
  11774. * Register the component to one instance of a scene.
  11775. */
  11776. register(): void;
  11777. /**
  11778. * Rebuilds the elements related to this component in case of
  11779. * context lost for instance.
  11780. */
  11781. rebuild(): void;
  11782. /**
  11783. * Disposes the component and the associated ressources.
  11784. */
  11785. dispose(): void;
  11786. }
  11787. /**
  11788. * This represents a SERIALIZABLE scene component.
  11789. *
  11790. * This extends Scene Component to add Serialization methods on top.
  11791. */
  11792. export interface ISceneSerializableComponent extends ISceneComponent {
  11793. /**
  11794. * Adds all the element from the container to the scene
  11795. * @param container the container holding the elements
  11796. */
  11797. addFromContainer(container: AbstractScene): void;
  11798. /**
  11799. * Removes all the elements in the container from the scene
  11800. * @param container contains the elements to remove
  11801. * @param dispose if the removed element should be disposed (default: false)
  11802. */
  11803. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11804. /**
  11805. * Serializes the component data to the specified json object
  11806. * @param serializationObject The object to serialize to
  11807. */
  11808. serialize(serializationObject: any): void;
  11809. }
  11810. /**
  11811. * Strong typing of a Mesh related stage step action
  11812. */
  11813. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11814. /**
  11815. * Strong typing of a Evaluate Sub Mesh related stage step action
  11816. */
  11817. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11818. /**
  11819. * Strong typing of a Active Mesh related stage step action
  11820. */
  11821. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11822. /**
  11823. * Strong typing of a Camera related stage step action
  11824. */
  11825. export type CameraStageAction = (camera: Camera) => void;
  11826. /**
  11827. * Strong typing of a Camera Frame buffer related stage step action
  11828. */
  11829. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11830. /**
  11831. * Strong typing of a Render Target related stage step action
  11832. */
  11833. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11834. /**
  11835. * Strong typing of a RenderingGroup related stage step action
  11836. */
  11837. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11838. /**
  11839. * Strong typing of a Mesh Render related stage step action
  11840. */
  11841. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11842. /**
  11843. * Strong typing of a simple stage step action
  11844. */
  11845. export type SimpleStageAction = () => void;
  11846. /**
  11847. * Strong typing of a render target action.
  11848. */
  11849. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11850. /**
  11851. * Strong typing of a pointer move action.
  11852. */
  11853. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11854. /**
  11855. * Strong typing of a pointer up/down action.
  11856. */
  11857. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11858. /**
  11859. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11860. * @hidden
  11861. */
  11862. export class Stage<T extends Function> extends Array<{
  11863. index: number;
  11864. component: ISceneComponent;
  11865. action: T;
  11866. }> {
  11867. /**
  11868. * Hide ctor from the rest of the world.
  11869. * @param items The items to add.
  11870. */
  11871. private constructor();
  11872. /**
  11873. * Creates a new Stage.
  11874. * @returns A new instance of a Stage
  11875. */
  11876. static Create<T extends Function>(): Stage<T>;
  11877. /**
  11878. * Registers a step in an ordered way in the targeted stage.
  11879. * @param index Defines the position to register the step in
  11880. * @param component Defines the component attached to the step
  11881. * @param action Defines the action to launch during the step
  11882. */
  11883. registerStep(index: number, component: ISceneComponent, action: T): void;
  11884. /**
  11885. * Clears all the steps from the stage.
  11886. */
  11887. clear(): void;
  11888. }
  11889. }
  11890. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11891. import { Nullable } from "babylonjs/types";
  11892. import { Observable } from "babylonjs/Misc/observable";
  11893. import { Scene } from "babylonjs/scene";
  11894. import { Sprite } from "babylonjs/Sprites/sprite";
  11895. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11896. import { Ray } from "babylonjs/Culling/ray";
  11897. import { Camera } from "babylonjs/Cameras/camera";
  11898. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11899. import { ISceneComponent } from "babylonjs/sceneComponent";
  11900. module "babylonjs/scene" {
  11901. interface Scene {
  11902. /** @hidden */
  11903. _pointerOverSprite: Nullable<Sprite>;
  11904. /** @hidden */
  11905. _pickedDownSprite: Nullable<Sprite>;
  11906. /** @hidden */
  11907. _tempSpritePickingRay: Nullable<Ray>;
  11908. /**
  11909. * All of the sprite managers added to this scene
  11910. * @see http://doc.babylonjs.com/babylon101/sprites
  11911. */
  11912. spriteManagers: Array<ISpriteManager>;
  11913. /**
  11914. * An event triggered when sprites rendering is about to start
  11915. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11916. */
  11917. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11918. /**
  11919. * An event triggered when sprites rendering is done
  11920. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11921. */
  11922. onAfterSpritesRenderingObservable: Observable<Scene>;
  11923. /** @hidden */
  11924. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11925. /** Launch a ray to try to pick a sprite in the scene
  11926. * @param x position on screen
  11927. * @param y position on screen
  11928. * @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
  11929. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11930. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11931. * @returns a PickingInfo
  11932. */
  11933. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11934. /** Use the given ray to pick a sprite in the scene
  11935. * @param ray The ray (in world space) to use to pick meshes
  11936. * @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
  11937. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11938. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11939. * @returns a PickingInfo
  11940. */
  11941. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11942. /**
  11943. * Force the sprite under the pointer
  11944. * @param sprite defines the sprite to use
  11945. */
  11946. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11947. /**
  11948. * Gets the sprite under the pointer
  11949. * @returns a Sprite or null if no sprite is under the pointer
  11950. */
  11951. getPointerOverSprite(): Nullable<Sprite>;
  11952. }
  11953. }
  11954. /**
  11955. * Defines the sprite scene component responsible to manage sprites
  11956. * in a given scene.
  11957. */
  11958. export class SpriteSceneComponent implements ISceneComponent {
  11959. /**
  11960. * The component name helpfull to identify the component in the list of scene components.
  11961. */
  11962. readonly name: string;
  11963. /**
  11964. * The scene the component belongs to.
  11965. */
  11966. scene: Scene;
  11967. /** @hidden */
  11968. private _spritePredicate;
  11969. /**
  11970. * Creates a new instance of the component for the given scene
  11971. * @param scene Defines the scene to register the component in
  11972. */
  11973. constructor(scene: Scene);
  11974. /**
  11975. * Registers the component in a given scene
  11976. */
  11977. register(): void;
  11978. /**
  11979. * Rebuilds the elements related to this component in case of
  11980. * context lost for instance.
  11981. */
  11982. rebuild(): void;
  11983. /**
  11984. * Disposes the component and the associated ressources.
  11985. */
  11986. dispose(): void;
  11987. private _pickSpriteButKeepRay;
  11988. private _pointerMove;
  11989. private _pointerDown;
  11990. private _pointerUp;
  11991. }
  11992. }
  11993. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11994. /** @hidden */
  11995. export var fogFragmentDeclaration: {
  11996. name: string;
  11997. shader: string;
  11998. };
  11999. }
  12000. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12001. /** @hidden */
  12002. export var fogFragment: {
  12003. name: string;
  12004. shader: string;
  12005. };
  12006. }
  12007. declare module "babylonjs/Shaders/sprites.fragment" {
  12008. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12009. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12010. /** @hidden */
  12011. export var spritesPixelShader: {
  12012. name: string;
  12013. shader: string;
  12014. };
  12015. }
  12016. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12017. /** @hidden */
  12018. export var fogVertexDeclaration: {
  12019. name: string;
  12020. shader: string;
  12021. };
  12022. }
  12023. declare module "babylonjs/Shaders/sprites.vertex" {
  12024. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12025. /** @hidden */
  12026. export var spritesVertexShader: {
  12027. name: string;
  12028. shader: string;
  12029. };
  12030. }
  12031. declare module "babylonjs/Sprites/spriteManager" {
  12032. import { IDisposable, Scene } from "babylonjs/scene";
  12033. import { Nullable } from "babylonjs/types";
  12034. import { Observable } from "babylonjs/Misc/observable";
  12035. import { Sprite } from "babylonjs/Sprites/sprite";
  12036. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12037. import { Camera } from "babylonjs/Cameras/camera";
  12038. import { Texture } from "babylonjs/Materials/Textures/texture";
  12039. import "babylonjs/Shaders/sprites.fragment";
  12040. import "babylonjs/Shaders/sprites.vertex";
  12041. import { Ray } from "babylonjs/Culling/ray";
  12042. /**
  12043. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12044. */
  12045. export interface ISpriteManager extends IDisposable {
  12046. /**
  12047. * Restricts the camera to viewing objects with the same layerMask.
  12048. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12049. */
  12050. layerMask: number;
  12051. /**
  12052. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12053. */
  12054. isPickable: boolean;
  12055. /**
  12056. * Specifies the rendering group id for this mesh (0 by default)
  12057. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12058. */
  12059. renderingGroupId: number;
  12060. /**
  12061. * Defines the list of sprites managed by the manager.
  12062. */
  12063. sprites: Array<Sprite>;
  12064. /**
  12065. * Tests the intersection of a sprite with a specific ray.
  12066. * @param ray The ray we are sending to test the collision
  12067. * @param camera The camera space we are sending rays in
  12068. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12069. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12070. * @returns picking info or null.
  12071. */
  12072. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12073. /**
  12074. * Renders the list of sprites on screen.
  12075. */
  12076. render(): void;
  12077. }
  12078. /**
  12079. * Class used to manage multiple sprites on the same spritesheet
  12080. * @see http://doc.babylonjs.com/babylon101/sprites
  12081. */
  12082. export class SpriteManager implements ISpriteManager {
  12083. /** defines the manager's name */
  12084. name: string;
  12085. /** Gets the list of sprites */
  12086. sprites: Sprite[];
  12087. /** Gets or sets the rendering group id (0 by default) */
  12088. renderingGroupId: number;
  12089. /** Gets or sets camera layer mask */
  12090. layerMask: number;
  12091. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12092. fogEnabled: boolean;
  12093. /** Gets or sets a boolean indicating if the sprites are pickable */
  12094. isPickable: boolean;
  12095. /** Defines the default width of a cell in the spritesheet */
  12096. cellWidth: number;
  12097. /** Defines the default height of a cell in the spritesheet */
  12098. cellHeight: number;
  12099. /**
  12100. * An event triggered when the manager is disposed.
  12101. */
  12102. onDisposeObservable: Observable<SpriteManager>;
  12103. private _onDisposeObserver;
  12104. /**
  12105. * Callback called when the manager is disposed
  12106. */
  12107. onDispose: () => void;
  12108. private _capacity;
  12109. private _spriteTexture;
  12110. private _epsilon;
  12111. private _scene;
  12112. private _vertexData;
  12113. private _buffer;
  12114. private _vertexBuffers;
  12115. private _indexBuffer;
  12116. private _effectBase;
  12117. private _effectFog;
  12118. /**
  12119. * Gets or sets the spritesheet texture
  12120. */
  12121. texture: Texture;
  12122. /**
  12123. * Creates a new sprite manager
  12124. * @param name defines the manager's name
  12125. * @param imgUrl defines the sprite sheet url
  12126. * @param capacity defines the maximum allowed number of sprites
  12127. * @param cellSize defines the size of a sprite cell
  12128. * @param scene defines the hosting scene
  12129. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12130. * @param samplingMode defines the smapling mode to use with spritesheet
  12131. */
  12132. constructor(
  12133. /** defines the manager's name */
  12134. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12135. private _appendSpriteVertex;
  12136. /**
  12137. * Intersects the sprites with a ray
  12138. * @param ray defines the ray to intersect with
  12139. * @param camera defines the current active camera
  12140. * @param predicate defines a predicate used to select candidate sprites
  12141. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12142. * @returns null if no hit or a PickingInfo
  12143. */
  12144. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12145. /**
  12146. * Render all child sprites
  12147. */
  12148. render(): void;
  12149. /**
  12150. * Release associated resources
  12151. */
  12152. dispose(): void;
  12153. }
  12154. }
  12155. declare module "babylonjs/Sprites/sprite" {
  12156. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12157. import { Nullable } from "babylonjs/types";
  12158. import { ActionManager } from "babylonjs/Actions/actionManager";
  12159. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12160. /**
  12161. * Class used to represent a sprite
  12162. * @see http://doc.babylonjs.com/babylon101/sprites
  12163. */
  12164. export class Sprite {
  12165. /** defines the name */
  12166. name: string;
  12167. /** Gets or sets the current world position */
  12168. position: Vector3;
  12169. /** Gets or sets the main color */
  12170. color: Color4;
  12171. /** Gets or sets the width */
  12172. width: number;
  12173. /** Gets or sets the height */
  12174. height: number;
  12175. /** Gets or sets rotation angle */
  12176. angle: number;
  12177. /** Gets or sets the cell index in the sprite sheet */
  12178. cellIndex: number;
  12179. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12180. invertU: number;
  12181. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12182. invertV: number;
  12183. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12184. disposeWhenFinishedAnimating: boolean;
  12185. /** Gets the list of attached animations */
  12186. animations: Animation[];
  12187. /** Gets or sets a boolean indicating if the sprite can be picked */
  12188. isPickable: boolean;
  12189. /**
  12190. * Gets or sets the associated action manager
  12191. */
  12192. actionManager: Nullable<ActionManager>;
  12193. private _animationStarted;
  12194. private _loopAnimation;
  12195. private _fromIndex;
  12196. private _toIndex;
  12197. private _delay;
  12198. private _direction;
  12199. private _manager;
  12200. private _time;
  12201. private _onAnimationEnd;
  12202. /**
  12203. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12204. */
  12205. isVisible: boolean;
  12206. /**
  12207. * Gets or sets the sprite size
  12208. */
  12209. size: number;
  12210. /**
  12211. * Creates a new Sprite
  12212. * @param name defines the name
  12213. * @param manager defines the manager
  12214. */
  12215. constructor(
  12216. /** defines the name */
  12217. name: string, manager: ISpriteManager);
  12218. /**
  12219. * Starts an animation
  12220. * @param from defines the initial key
  12221. * @param to defines the end key
  12222. * @param loop defines if the animation must loop
  12223. * @param delay defines the start delay (in ms)
  12224. * @param onAnimationEnd defines a callback to call when animation ends
  12225. */
  12226. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12227. /** Stops current animation (if any) */
  12228. stopAnimation(): void;
  12229. /** @hidden */
  12230. _animate(deltaTime: number): void;
  12231. /** Release associated resources */
  12232. dispose(): void;
  12233. }
  12234. }
  12235. declare module "babylonjs/Collisions/pickingInfo" {
  12236. import { Nullable } from "babylonjs/types";
  12237. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12239. import { Sprite } from "babylonjs/Sprites/sprite";
  12240. import { Ray } from "babylonjs/Culling/ray";
  12241. /**
  12242. * Information about the result of picking within a scene
  12243. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12244. */
  12245. export class PickingInfo {
  12246. /** @hidden */
  12247. _pickingUnavailable: boolean;
  12248. /**
  12249. * If the pick collided with an object
  12250. */
  12251. hit: boolean;
  12252. /**
  12253. * Distance away where the pick collided
  12254. */
  12255. distance: number;
  12256. /**
  12257. * The location of pick collision
  12258. */
  12259. pickedPoint: Nullable<Vector3>;
  12260. /**
  12261. * The mesh corresponding the the pick collision
  12262. */
  12263. pickedMesh: Nullable<AbstractMesh>;
  12264. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12265. bu: number;
  12266. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12267. bv: number;
  12268. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12269. faceId: number;
  12270. /** Id of the the submesh that was picked */
  12271. subMeshId: number;
  12272. /** If a sprite was picked, this will be the sprite the pick collided with */
  12273. pickedSprite: Nullable<Sprite>;
  12274. /**
  12275. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12276. */
  12277. originMesh: Nullable<AbstractMesh>;
  12278. /**
  12279. * The ray that was used to perform the picking.
  12280. */
  12281. ray: Nullable<Ray>;
  12282. /**
  12283. * Gets the normal correspodning to the face the pick collided with
  12284. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12285. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12286. * @returns The normal correspodning to the face the pick collided with
  12287. */
  12288. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12289. /**
  12290. * Gets the texture coordinates of where the pick occured
  12291. * @returns the vector containing the coordnates of the texture
  12292. */
  12293. getTextureCoordinates(): Nullable<Vector2>;
  12294. }
  12295. }
  12296. declare module "babylonjs/Events/pointerEvents" {
  12297. import { Nullable } from "babylonjs/types";
  12298. import { Vector2 } from "babylonjs/Maths/math";
  12299. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12300. import { Ray } from "babylonjs/Culling/ray";
  12301. /**
  12302. * Gather the list of pointer event types as constants.
  12303. */
  12304. export class PointerEventTypes {
  12305. /**
  12306. * 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.
  12307. */
  12308. static readonly POINTERDOWN: number;
  12309. /**
  12310. * The pointerup event is fired when a pointer is no longer active.
  12311. */
  12312. static readonly POINTERUP: number;
  12313. /**
  12314. * The pointermove event is fired when a pointer changes coordinates.
  12315. */
  12316. static readonly POINTERMOVE: number;
  12317. /**
  12318. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12319. */
  12320. static readonly POINTERWHEEL: number;
  12321. /**
  12322. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12323. */
  12324. static readonly POINTERPICK: number;
  12325. /**
  12326. * The pointertap event is fired when a the object has been touched and released without drag.
  12327. */
  12328. static readonly POINTERTAP: number;
  12329. /**
  12330. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12331. */
  12332. static readonly POINTERDOUBLETAP: number;
  12333. }
  12334. /**
  12335. * Base class of pointer info types.
  12336. */
  12337. export class PointerInfoBase {
  12338. /**
  12339. * Defines the type of event (PointerEventTypes)
  12340. */
  12341. type: number;
  12342. /**
  12343. * Defines the related dom event
  12344. */
  12345. event: PointerEvent | MouseWheelEvent;
  12346. /**
  12347. * Instantiates the base class of pointers info.
  12348. * @param type Defines the type of event (PointerEventTypes)
  12349. * @param event Defines the related dom event
  12350. */
  12351. constructor(
  12352. /**
  12353. * Defines the type of event (PointerEventTypes)
  12354. */
  12355. type: number,
  12356. /**
  12357. * Defines the related dom event
  12358. */
  12359. event: PointerEvent | MouseWheelEvent);
  12360. }
  12361. /**
  12362. * This class is used to store pointer related info for the onPrePointerObservable event.
  12363. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12364. */
  12365. export class PointerInfoPre extends PointerInfoBase {
  12366. /**
  12367. * Ray from a pointer if availible (eg. 6dof controller)
  12368. */
  12369. ray: Nullable<Ray>;
  12370. /**
  12371. * Defines the local position of the pointer on the canvas.
  12372. */
  12373. localPosition: Vector2;
  12374. /**
  12375. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12376. */
  12377. skipOnPointerObservable: boolean;
  12378. /**
  12379. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12380. * @param type Defines the type of event (PointerEventTypes)
  12381. * @param event Defines the related dom event
  12382. * @param localX Defines the local x coordinates of the pointer when the event occured
  12383. * @param localY Defines the local y coordinates of the pointer when the event occured
  12384. */
  12385. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12386. }
  12387. /**
  12388. * This type contains all the data related to a pointer event in Babylon.js.
  12389. * 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.
  12390. */
  12391. export class PointerInfo extends PointerInfoBase {
  12392. /**
  12393. * Defines the picking info associated to the info (if any)\
  12394. */
  12395. pickInfo: Nullable<PickingInfo>;
  12396. /**
  12397. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12398. * @param type Defines the type of event (PointerEventTypes)
  12399. * @param event Defines the related dom event
  12400. * @param pickInfo Defines the picking info associated to the info (if any)\
  12401. */
  12402. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12403. /**
  12404. * Defines the picking info associated to the info (if any)\
  12405. */
  12406. pickInfo: Nullable<PickingInfo>);
  12407. }
  12408. /**
  12409. * Data relating to a touch event on the screen.
  12410. */
  12411. export interface PointerTouch {
  12412. /**
  12413. * X coordinate of touch.
  12414. */
  12415. x: number;
  12416. /**
  12417. * Y coordinate of touch.
  12418. */
  12419. y: number;
  12420. /**
  12421. * Id of touch. Unique for each finger.
  12422. */
  12423. pointerId: number;
  12424. /**
  12425. * Event type passed from DOM.
  12426. */
  12427. type: any;
  12428. }
  12429. }
  12430. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12431. import { Observable } from "babylonjs/Misc/observable";
  12432. import { Nullable } from "babylonjs/types";
  12433. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12434. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12435. /**
  12436. * Manage the mouse inputs to control the movement of a free camera.
  12437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12438. */
  12439. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12440. /**
  12441. * Define if touch is enabled in the mouse input
  12442. */
  12443. touchEnabled: boolean;
  12444. /**
  12445. * Defines the camera the input is attached to.
  12446. */
  12447. camera: FreeCamera;
  12448. /**
  12449. * Defines the buttons associated with the input to handle camera move.
  12450. */
  12451. buttons: number[];
  12452. /**
  12453. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12454. */
  12455. angularSensibility: number;
  12456. private _pointerInput;
  12457. private _onMouseMove;
  12458. private _observer;
  12459. private previousPosition;
  12460. /**
  12461. * Observable for when a pointer move event occurs containing the move offset
  12462. */
  12463. onPointerMovedObservable: Observable<{
  12464. offsetX: number;
  12465. offsetY: number;
  12466. }>;
  12467. /**
  12468. * @hidden
  12469. * If the camera should be rotated automatically based on pointer movement
  12470. */
  12471. _allowCameraRotation: boolean;
  12472. /**
  12473. * Manage the mouse inputs to control the movement of a free camera.
  12474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12475. * @param touchEnabled Defines if touch is enabled or not
  12476. */
  12477. constructor(
  12478. /**
  12479. * Define if touch is enabled in the mouse input
  12480. */
  12481. touchEnabled?: boolean);
  12482. /**
  12483. * Attach the input controls to a specific dom element to get the input from.
  12484. * @param element Defines the element the controls should be listened from
  12485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12486. */
  12487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12488. /**
  12489. * Called on JS contextmenu event.
  12490. * Override this method to provide functionality.
  12491. */
  12492. protected onContextMenu(evt: PointerEvent): void;
  12493. /**
  12494. * Detach the current controls from the specified dom element.
  12495. * @param element Defines the element to stop listening the inputs from
  12496. */
  12497. detachControl(element: Nullable<HTMLElement>): void;
  12498. /**
  12499. * Gets the class name of the current intput.
  12500. * @returns the class name
  12501. */
  12502. getClassName(): string;
  12503. /**
  12504. * Get the friendly name associated with the input class.
  12505. * @returns the input friendly name
  12506. */
  12507. getSimpleName(): string;
  12508. }
  12509. }
  12510. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12511. import { Nullable } from "babylonjs/types";
  12512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12513. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12514. /**
  12515. * Manage the touch inputs to control the movement of a free camera.
  12516. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12517. */
  12518. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12519. /**
  12520. * Defines the camera the input is attached to.
  12521. */
  12522. camera: FreeCamera;
  12523. /**
  12524. * Defines the touch sensibility for rotation.
  12525. * The higher the faster.
  12526. */
  12527. touchAngularSensibility: number;
  12528. /**
  12529. * Defines the touch sensibility for move.
  12530. * The higher the faster.
  12531. */
  12532. touchMoveSensibility: number;
  12533. private _offsetX;
  12534. private _offsetY;
  12535. private _pointerPressed;
  12536. private _pointerInput;
  12537. private _observer;
  12538. private _onLostFocus;
  12539. /**
  12540. * Attach the input controls to a specific dom element to get the input from.
  12541. * @param element Defines the element the controls should be listened from
  12542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12543. */
  12544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12545. /**
  12546. * Detach the current controls from the specified dom element.
  12547. * @param element Defines the element to stop listening the inputs from
  12548. */
  12549. detachControl(element: Nullable<HTMLElement>): void;
  12550. /**
  12551. * Update the current camera state depending on the inputs that have been used this frame.
  12552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12553. */
  12554. checkInputs(): void;
  12555. /**
  12556. * Gets the class name of the current intput.
  12557. * @returns the class name
  12558. */
  12559. getClassName(): string;
  12560. /**
  12561. * Get the friendly name associated with the input class.
  12562. * @returns the input friendly name
  12563. */
  12564. getSimpleName(): string;
  12565. }
  12566. }
  12567. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12568. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12569. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12570. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12571. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12572. import { Nullable } from "babylonjs/types";
  12573. /**
  12574. * Default Inputs manager for the FreeCamera.
  12575. * It groups all the default supported inputs for ease of use.
  12576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12577. */
  12578. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12579. /**
  12580. * @hidden
  12581. */
  12582. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12583. /**
  12584. * @hidden
  12585. */
  12586. _mouseInput: Nullable<FreeCameraMouseInput>;
  12587. /**
  12588. * Instantiates a new FreeCameraInputsManager.
  12589. * @param camera Defines the camera the inputs belong to
  12590. */
  12591. constructor(camera: FreeCamera);
  12592. /**
  12593. * Add keyboard input support to the input manager.
  12594. * @returns the current input manager
  12595. */
  12596. addKeyboard(): FreeCameraInputsManager;
  12597. /**
  12598. * Add mouse input support to the input manager.
  12599. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12600. * @returns the current input manager
  12601. */
  12602. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12603. /**
  12604. * Removes the mouse input support from the manager
  12605. * @returns the current input manager
  12606. */
  12607. removeMouse(): FreeCameraInputsManager;
  12608. /**
  12609. * Add touch input support to the input manager.
  12610. * @returns the current input manager
  12611. */
  12612. addTouch(): FreeCameraInputsManager;
  12613. }
  12614. }
  12615. declare module "babylonjs/Cameras/freeCamera" {
  12616. import { Vector3 } from "babylonjs/Maths/math";
  12617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12618. import { Scene } from "babylonjs/scene";
  12619. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12620. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12621. /**
  12622. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12623. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12624. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12625. */
  12626. export class FreeCamera extends TargetCamera {
  12627. /**
  12628. * Define the collision ellipsoid of the camera.
  12629. * This is helpful to simulate a camera body like the player body around the camera
  12630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12631. */
  12632. ellipsoid: Vector3;
  12633. /**
  12634. * Define an offset for the position of the ellipsoid around the camera.
  12635. * This can be helpful to determine the center of the body near the gravity center of the body
  12636. * instead of its head.
  12637. */
  12638. ellipsoidOffset: Vector3;
  12639. /**
  12640. * Enable or disable collisions of the camera with the rest of the scene objects.
  12641. */
  12642. checkCollisions: boolean;
  12643. /**
  12644. * Enable or disable gravity on the camera.
  12645. */
  12646. applyGravity: boolean;
  12647. /**
  12648. * Define the input manager associated to the camera.
  12649. */
  12650. inputs: FreeCameraInputsManager;
  12651. /**
  12652. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12653. * Higher values reduce sensitivity.
  12654. */
  12655. /**
  12656. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12657. * Higher values reduce sensitivity.
  12658. */
  12659. angularSensibility: number;
  12660. /**
  12661. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12662. */
  12663. keysUp: number[];
  12664. /**
  12665. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12666. */
  12667. keysDown: number[];
  12668. /**
  12669. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12670. */
  12671. keysLeft: number[];
  12672. /**
  12673. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12674. */
  12675. keysRight: number[];
  12676. /**
  12677. * Event raised when the camera collide with a mesh in the scene.
  12678. */
  12679. onCollide: (collidedMesh: AbstractMesh) => void;
  12680. private _collider;
  12681. private _needMoveForGravity;
  12682. private _oldPosition;
  12683. private _diffPosition;
  12684. private _newPosition;
  12685. /** @hidden */
  12686. _localDirection: Vector3;
  12687. /** @hidden */
  12688. _transformedDirection: Vector3;
  12689. /**
  12690. * Instantiates a Free Camera.
  12691. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12692. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12693. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12694. * @param name Define the name of the camera in the scene
  12695. * @param position Define the start position of the camera in the scene
  12696. * @param scene Define the scene the camera belongs to
  12697. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12698. */
  12699. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12700. /**
  12701. * Attached controls to the current camera.
  12702. * @param element Defines the element the controls should be listened from
  12703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12704. */
  12705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12706. /**
  12707. * Detach the current controls from the camera.
  12708. * The camera will stop reacting to inputs.
  12709. * @param element Defines the element to stop listening the inputs from
  12710. */
  12711. detachControl(element: HTMLElement): void;
  12712. private _collisionMask;
  12713. /**
  12714. * Define a collision mask to limit the list of object the camera can collide with
  12715. */
  12716. collisionMask: number;
  12717. /** @hidden */
  12718. _collideWithWorld(displacement: Vector3): void;
  12719. private _onCollisionPositionChange;
  12720. /** @hidden */
  12721. _checkInputs(): void;
  12722. /** @hidden */
  12723. _decideIfNeedsToMove(): boolean;
  12724. /** @hidden */
  12725. _updatePosition(): void;
  12726. /**
  12727. * Destroy the camera and release the current resources hold by it.
  12728. */
  12729. dispose(): void;
  12730. /**
  12731. * Gets the current object class name.
  12732. * @return the class name
  12733. */
  12734. getClassName(): string;
  12735. }
  12736. }
  12737. declare module "babylonjs/Gamepads/gamepad" {
  12738. import { Observable } from "babylonjs/Misc/observable";
  12739. /**
  12740. * Represents a gamepad control stick position
  12741. */
  12742. export class StickValues {
  12743. /**
  12744. * The x component of the control stick
  12745. */
  12746. x: number;
  12747. /**
  12748. * The y component of the control stick
  12749. */
  12750. y: number;
  12751. /**
  12752. * Initializes the gamepad x and y control stick values
  12753. * @param x The x component of the gamepad control stick value
  12754. * @param y The y component of the gamepad control stick value
  12755. */
  12756. constructor(
  12757. /**
  12758. * The x component of the control stick
  12759. */
  12760. x: number,
  12761. /**
  12762. * The y component of the control stick
  12763. */
  12764. y: number);
  12765. }
  12766. /**
  12767. * An interface which manages callbacks for gamepad button changes
  12768. */
  12769. export interface GamepadButtonChanges {
  12770. /**
  12771. * Called when a gamepad has been changed
  12772. */
  12773. changed: boolean;
  12774. /**
  12775. * Called when a gamepad press event has been triggered
  12776. */
  12777. pressChanged: boolean;
  12778. /**
  12779. * Called when a touch event has been triggered
  12780. */
  12781. touchChanged: boolean;
  12782. /**
  12783. * Called when a value has changed
  12784. */
  12785. valueChanged: boolean;
  12786. }
  12787. /**
  12788. * Represents a gamepad
  12789. */
  12790. export class Gamepad {
  12791. /**
  12792. * The id of the gamepad
  12793. */
  12794. id: string;
  12795. /**
  12796. * The index of the gamepad
  12797. */
  12798. index: number;
  12799. /**
  12800. * The browser gamepad
  12801. */
  12802. browserGamepad: any;
  12803. /**
  12804. * Specifies what type of gamepad this represents
  12805. */
  12806. type: number;
  12807. private _leftStick;
  12808. private _rightStick;
  12809. /** @hidden */
  12810. _isConnected: boolean;
  12811. private _leftStickAxisX;
  12812. private _leftStickAxisY;
  12813. private _rightStickAxisX;
  12814. private _rightStickAxisY;
  12815. /**
  12816. * Triggered when the left control stick has been changed
  12817. */
  12818. private _onleftstickchanged;
  12819. /**
  12820. * Triggered when the right control stick has been changed
  12821. */
  12822. private _onrightstickchanged;
  12823. /**
  12824. * Represents a gamepad controller
  12825. */
  12826. static GAMEPAD: number;
  12827. /**
  12828. * Represents a generic controller
  12829. */
  12830. static GENERIC: number;
  12831. /**
  12832. * Represents an XBox controller
  12833. */
  12834. static XBOX: number;
  12835. /**
  12836. * Represents a pose-enabled controller
  12837. */
  12838. static POSE_ENABLED: number;
  12839. /**
  12840. * Specifies whether the left control stick should be Y-inverted
  12841. */
  12842. protected _invertLeftStickY: boolean;
  12843. /**
  12844. * Specifies if the gamepad has been connected
  12845. */
  12846. readonly isConnected: boolean;
  12847. /**
  12848. * Initializes the gamepad
  12849. * @param id The id of the gamepad
  12850. * @param index The index of the gamepad
  12851. * @param browserGamepad The browser gamepad
  12852. * @param leftStickX The x component of the left joystick
  12853. * @param leftStickY The y component of the left joystick
  12854. * @param rightStickX The x component of the right joystick
  12855. * @param rightStickY The y component of the right joystick
  12856. */
  12857. constructor(
  12858. /**
  12859. * The id of the gamepad
  12860. */
  12861. id: string,
  12862. /**
  12863. * The index of the gamepad
  12864. */
  12865. index: number,
  12866. /**
  12867. * The browser gamepad
  12868. */
  12869. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12870. /**
  12871. * Callback triggered when the left joystick has changed
  12872. * @param callback
  12873. */
  12874. onleftstickchanged(callback: (values: StickValues) => void): void;
  12875. /**
  12876. * Callback triggered when the right joystick has changed
  12877. * @param callback
  12878. */
  12879. onrightstickchanged(callback: (values: StickValues) => void): void;
  12880. /**
  12881. * Gets the left joystick
  12882. */
  12883. /**
  12884. * Sets the left joystick values
  12885. */
  12886. leftStick: StickValues;
  12887. /**
  12888. * Gets the right joystick
  12889. */
  12890. /**
  12891. * Sets the right joystick value
  12892. */
  12893. rightStick: StickValues;
  12894. /**
  12895. * Updates the gamepad joystick positions
  12896. */
  12897. update(): void;
  12898. /**
  12899. * Disposes the gamepad
  12900. */
  12901. dispose(): void;
  12902. }
  12903. /**
  12904. * Represents a generic gamepad
  12905. */
  12906. export class GenericPad extends Gamepad {
  12907. private _buttons;
  12908. private _onbuttondown;
  12909. private _onbuttonup;
  12910. /**
  12911. * Observable triggered when a button has been pressed
  12912. */
  12913. onButtonDownObservable: Observable<number>;
  12914. /**
  12915. * Observable triggered when a button has been released
  12916. */
  12917. onButtonUpObservable: Observable<number>;
  12918. /**
  12919. * Callback triggered when a button has been pressed
  12920. * @param callback Called when a button has been pressed
  12921. */
  12922. onbuttondown(callback: (buttonPressed: number) => void): void;
  12923. /**
  12924. * Callback triggered when a button has been released
  12925. * @param callback Called when a button has been released
  12926. */
  12927. onbuttonup(callback: (buttonReleased: number) => void): void;
  12928. /**
  12929. * Initializes the generic gamepad
  12930. * @param id The id of the generic gamepad
  12931. * @param index The index of the generic gamepad
  12932. * @param browserGamepad The browser gamepad
  12933. */
  12934. constructor(id: string, index: number, browserGamepad: any);
  12935. private _setButtonValue;
  12936. /**
  12937. * Updates the generic gamepad
  12938. */
  12939. update(): void;
  12940. /**
  12941. * Disposes the generic gamepad
  12942. */
  12943. dispose(): void;
  12944. }
  12945. }
  12946. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12947. import { Observable } from "babylonjs/Misc/observable";
  12948. import { Nullable } from "babylonjs/types";
  12949. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12950. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12952. import { Ray } from "babylonjs/Culling/ray";
  12953. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12954. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12955. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12956. /**
  12957. * Defines the types of pose enabled controllers that are supported
  12958. */
  12959. export enum PoseEnabledControllerType {
  12960. /**
  12961. * HTC Vive
  12962. */
  12963. VIVE = 0,
  12964. /**
  12965. * Oculus Rift
  12966. */
  12967. OCULUS = 1,
  12968. /**
  12969. * Windows mixed reality
  12970. */
  12971. WINDOWS = 2,
  12972. /**
  12973. * Samsung gear VR
  12974. */
  12975. GEAR_VR = 3,
  12976. /**
  12977. * Google Daydream
  12978. */
  12979. DAYDREAM = 4,
  12980. /**
  12981. * Generic
  12982. */
  12983. GENERIC = 5
  12984. }
  12985. /**
  12986. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12987. */
  12988. export interface MutableGamepadButton {
  12989. /**
  12990. * Value of the button/trigger
  12991. */
  12992. value: number;
  12993. /**
  12994. * If the button/trigger is currently touched
  12995. */
  12996. touched: boolean;
  12997. /**
  12998. * If the button/trigger is currently pressed
  12999. */
  13000. pressed: boolean;
  13001. }
  13002. /**
  13003. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13004. * @hidden
  13005. */
  13006. export interface ExtendedGamepadButton extends GamepadButton {
  13007. /**
  13008. * If the button/trigger is currently pressed
  13009. */
  13010. readonly pressed: boolean;
  13011. /**
  13012. * If the button/trigger is currently touched
  13013. */
  13014. readonly touched: boolean;
  13015. /**
  13016. * Value of the button/trigger
  13017. */
  13018. readonly value: number;
  13019. }
  13020. /** @hidden */
  13021. export interface _GamePadFactory {
  13022. /**
  13023. * Returns wether or not the current gamepad can be created for this type of controller.
  13024. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13025. * @returns true if it can be created, otherwise false
  13026. */
  13027. canCreate(gamepadInfo: any): boolean;
  13028. /**
  13029. * Creates a new instance of the Gamepad.
  13030. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13031. * @returns the new gamepad instance
  13032. */
  13033. create(gamepadInfo: any): Gamepad;
  13034. }
  13035. /**
  13036. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13037. */
  13038. export class PoseEnabledControllerHelper {
  13039. /** @hidden */
  13040. static _ControllerFactories: _GamePadFactory[];
  13041. /** @hidden */
  13042. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13043. /**
  13044. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13045. * @param vrGamepad the gamepad to initialized
  13046. * @returns a vr controller of the type the gamepad identified as
  13047. */
  13048. static InitiateController(vrGamepad: any): Gamepad;
  13049. }
  13050. /**
  13051. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13052. */
  13053. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13054. private _deviceRoomPosition;
  13055. private _deviceRoomRotationQuaternion;
  13056. /**
  13057. * The device position in babylon space
  13058. */
  13059. devicePosition: Vector3;
  13060. /**
  13061. * The device rotation in babylon space
  13062. */
  13063. deviceRotationQuaternion: Quaternion;
  13064. /**
  13065. * The scale factor of the device in babylon space
  13066. */
  13067. deviceScaleFactor: number;
  13068. /**
  13069. * (Likely devicePosition should be used instead) The device position in its room space
  13070. */
  13071. position: Vector3;
  13072. /**
  13073. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13074. */
  13075. rotationQuaternion: Quaternion;
  13076. /**
  13077. * The type of controller (Eg. Windows mixed reality)
  13078. */
  13079. controllerType: PoseEnabledControllerType;
  13080. protected _calculatedPosition: Vector3;
  13081. private _calculatedRotation;
  13082. /**
  13083. * The raw pose from the device
  13084. */
  13085. rawPose: DevicePose;
  13086. private _trackPosition;
  13087. private _maxRotationDistFromHeadset;
  13088. private _draggedRoomRotation;
  13089. /**
  13090. * @hidden
  13091. */
  13092. _disableTrackPosition(fixedPosition: Vector3): void;
  13093. /**
  13094. * Internal, the mesh attached to the controller
  13095. * @hidden
  13096. */
  13097. _mesh: Nullable<AbstractMesh>;
  13098. private _poseControlledCamera;
  13099. private _leftHandSystemQuaternion;
  13100. /**
  13101. * Internal, matrix used to convert room space to babylon space
  13102. * @hidden
  13103. */
  13104. _deviceToWorld: Matrix;
  13105. /**
  13106. * Node to be used when casting a ray from the controller
  13107. * @hidden
  13108. */
  13109. _pointingPoseNode: Nullable<TransformNode>;
  13110. /**
  13111. * Name of the child mesh that can be used to cast a ray from the controller
  13112. */
  13113. static readonly POINTING_POSE: string;
  13114. /**
  13115. * Creates a new PoseEnabledController from a gamepad
  13116. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13117. */
  13118. constructor(browserGamepad: any);
  13119. private _workingMatrix;
  13120. /**
  13121. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13122. */
  13123. update(): void;
  13124. /**
  13125. * Updates only the pose device and mesh without doing any button event checking
  13126. */
  13127. protected _updatePoseAndMesh(): void;
  13128. /**
  13129. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13130. * @param poseData raw pose fromthe device
  13131. */
  13132. updateFromDevice(poseData: DevicePose): void;
  13133. /**
  13134. * @hidden
  13135. */
  13136. _meshAttachedObservable: Observable<AbstractMesh>;
  13137. /**
  13138. * Attaches a mesh to the controller
  13139. * @param mesh the mesh to be attached
  13140. */
  13141. attachToMesh(mesh: AbstractMesh): void;
  13142. /**
  13143. * Attaches the controllers mesh to a camera
  13144. * @param camera the camera the mesh should be attached to
  13145. */
  13146. attachToPoseControlledCamera(camera: TargetCamera): void;
  13147. /**
  13148. * Disposes of the controller
  13149. */
  13150. dispose(): void;
  13151. /**
  13152. * The mesh that is attached to the controller
  13153. */
  13154. readonly mesh: Nullable<AbstractMesh>;
  13155. /**
  13156. * Gets the ray of the controller in the direction the controller is pointing
  13157. * @param length the length the resulting ray should be
  13158. * @returns a ray in the direction the controller is pointing
  13159. */
  13160. getForwardRay(length?: number): Ray;
  13161. }
  13162. }
  13163. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13164. import { Observable } from "babylonjs/Misc/observable";
  13165. import { Scene } from "babylonjs/scene";
  13166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13167. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13168. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13169. /**
  13170. * Defines the WebVRController object that represents controllers tracked in 3D space
  13171. */
  13172. export abstract class WebVRController extends PoseEnabledController {
  13173. /**
  13174. * Internal, the default controller model for the controller
  13175. */
  13176. protected _defaultModel: AbstractMesh;
  13177. /**
  13178. * Fired when the trigger state has changed
  13179. */
  13180. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13181. /**
  13182. * Fired when the main button state has changed
  13183. */
  13184. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13185. /**
  13186. * Fired when the secondary button state has changed
  13187. */
  13188. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13189. /**
  13190. * Fired when the pad state has changed
  13191. */
  13192. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13193. /**
  13194. * Fired when controllers stick values have changed
  13195. */
  13196. onPadValuesChangedObservable: Observable<StickValues>;
  13197. /**
  13198. * Array of button availible on the controller
  13199. */
  13200. protected _buttons: Array<MutableGamepadButton>;
  13201. private _onButtonStateChange;
  13202. /**
  13203. * Fired when a controller button's state has changed
  13204. * @param callback the callback containing the button that was modified
  13205. */
  13206. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13207. /**
  13208. * X and Y axis corrisponding to the controllers joystick
  13209. */
  13210. pad: StickValues;
  13211. /**
  13212. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13213. */
  13214. hand: string;
  13215. /**
  13216. * The default controller model for the controller
  13217. */
  13218. readonly defaultModel: AbstractMesh;
  13219. /**
  13220. * Creates a new WebVRController from a gamepad
  13221. * @param vrGamepad the gamepad that the WebVRController should be created from
  13222. */
  13223. constructor(vrGamepad: any);
  13224. /**
  13225. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13226. */
  13227. update(): void;
  13228. /**
  13229. * Function to be called when a button is modified
  13230. */
  13231. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13232. /**
  13233. * Loads a mesh and attaches it to the controller
  13234. * @param scene the scene the mesh should be added to
  13235. * @param meshLoaded callback for when the mesh has been loaded
  13236. */
  13237. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13238. private _setButtonValue;
  13239. private _changes;
  13240. private _checkChanges;
  13241. /**
  13242. * Disposes of th webVRCOntroller
  13243. */
  13244. dispose(): void;
  13245. }
  13246. }
  13247. declare module "babylonjs/Lights/hemisphericLight" {
  13248. import { Nullable } from "babylonjs/types";
  13249. import { Scene } from "babylonjs/scene";
  13250. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13251. import { Effect } from "babylonjs/Materials/effect";
  13252. import { Light } from "babylonjs/Lights/light";
  13253. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13254. /**
  13255. * The HemisphericLight simulates the ambient environment light,
  13256. * so the passed direction is the light reflection direction, not the incoming direction.
  13257. */
  13258. export class HemisphericLight extends Light {
  13259. /**
  13260. * The groundColor is the light in the opposite direction to the one specified during creation.
  13261. * 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.
  13262. */
  13263. groundColor: Color3;
  13264. /**
  13265. * The light reflection direction, not the incoming direction.
  13266. */
  13267. direction: Vector3;
  13268. /**
  13269. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13270. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13271. * The HemisphericLight can't cast shadows.
  13272. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13273. * @param name The friendly name of the light
  13274. * @param direction The direction of the light reflection
  13275. * @param scene The scene the light belongs to
  13276. */
  13277. constructor(name: string, direction: Vector3, scene: Scene);
  13278. protected _buildUniformLayout(): void;
  13279. /**
  13280. * Returns the string "HemisphericLight".
  13281. * @return The class name
  13282. */
  13283. getClassName(): string;
  13284. /**
  13285. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13286. * Returns the updated direction.
  13287. * @param target The target the direction should point to
  13288. * @return The computed direction
  13289. */
  13290. setDirectionToTarget(target: Vector3): Vector3;
  13291. /**
  13292. * Returns the shadow generator associated to the light.
  13293. * @returns Always null for hemispheric lights because it does not support shadows.
  13294. */
  13295. getShadowGenerator(): Nullable<IShadowGenerator>;
  13296. /**
  13297. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13298. * @param effect The effect to update
  13299. * @param lightIndex The index of the light in the effect to update
  13300. * @returns The hemispheric light
  13301. */
  13302. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13303. /**
  13304. * Computes the world matrix of the node
  13305. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13306. * @param useWasUpdatedFlag defines a reserved property
  13307. * @returns the world matrix
  13308. */
  13309. computeWorldMatrix(): Matrix;
  13310. /**
  13311. * Returns the integer 3.
  13312. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13313. */
  13314. getTypeID(): number;
  13315. /**
  13316. * Prepares the list of defines specific to the light type.
  13317. * @param defines the list of defines
  13318. * @param lightIndex defines the index of the light for the effect
  13319. */
  13320. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13321. }
  13322. }
  13323. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13324. /** @hidden */
  13325. export var vrMultiviewToSingleviewPixelShader: {
  13326. name: string;
  13327. shader: string;
  13328. };
  13329. }
  13330. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13331. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13332. import { Scene } from "babylonjs/scene";
  13333. /**
  13334. * Renders to multiple views with a single draw call
  13335. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13336. */
  13337. export class MultiviewRenderTarget extends RenderTargetTexture {
  13338. /**
  13339. * Creates a multiview render target
  13340. * @param scene scene used with the render target
  13341. * @param size the size of the render target (used for each view)
  13342. */
  13343. constructor(scene: Scene, size?: number | {
  13344. width: number;
  13345. height: number;
  13346. } | {
  13347. ratio: number;
  13348. });
  13349. /**
  13350. * @hidden
  13351. * @param faceIndex the face index, if its a cube texture
  13352. */
  13353. _bindFrameBuffer(faceIndex?: number): void;
  13354. /**
  13355. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13356. * @returns the view count
  13357. */
  13358. getViewCount(): number;
  13359. }
  13360. }
  13361. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13362. import { Camera } from "babylonjs/Cameras/camera";
  13363. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13364. import { Nullable } from "babylonjs/types";
  13365. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13366. import { Matrix } from "babylonjs/Maths/math";
  13367. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13368. module "babylonjs/Engines/engine" {
  13369. interface Engine {
  13370. /**
  13371. * Creates a new multiview render target
  13372. * @param width defines the width of the texture
  13373. * @param height defines the height of the texture
  13374. * @returns the created multiview texture
  13375. */
  13376. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13377. /**
  13378. * Binds a multiview framebuffer to be drawn to
  13379. * @param multiviewTexture texture to bind
  13380. */
  13381. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13382. }
  13383. }
  13384. module "babylonjs/Cameras/camera" {
  13385. interface Camera {
  13386. /**
  13387. * @hidden
  13388. * 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)
  13389. */
  13390. _useMultiviewToSingleView: boolean;
  13391. /**
  13392. * @hidden
  13393. * 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)
  13394. */
  13395. _multiviewTexture: Nullable<RenderTargetTexture>;
  13396. /**
  13397. * @hidden
  13398. * ensures the multiview texture of the camera exists and has the specified width/height
  13399. * @param width height to set on the multiview texture
  13400. * @param height width to set on the multiview texture
  13401. */
  13402. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13403. }
  13404. }
  13405. module "babylonjs/scene" {
  13406. interface Scene {
  13407. /** @hidden */
  13408. _transformMatrixR: Matrix;
  13409. /** @hidden */
  13410. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13411. /** @hidden */
  13412. _createMultiviewUbo(): void;
  13413. /** @hidden */
  13414. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13415. /** @hidden */
  13416. _renderMultiviewToSingleView(camera: Camera): void;
  13417. }
  13418. }
  13419. }
  13420. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13421. import { Camera } from "babylonjs/Cameras/camera";
  13422. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13423. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13424. import "babylonjs/Engines/Extensions/engine.multiview";
  13425. /**
  13426. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13427. * This will not be used for webXR as it supports displaying texture arrays directly
  13428. */
  13429. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13430. /**
  13431. * Initializes a VRMultiviewToSingleview
  13432. * @param name name of the post process
  13433. * @param camera camera to be applied to
  13434. * @param scaleFactor scaling factor to the size of the output texture
  13435. */
  13436. constructor(name: string, camera: Camera, scaleFactor: number);
  13437. }
  13438. }
  13439. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13440. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13441. import { Nullable } from "babylonjs/types";
  13442. import { Size } from "babylonjs/Maths/math";
  13443. import { Observable } from "babylonjs/Misc/observable";
  13444. module "babylonjs/Engines/engine" {
  13445. /**
  13446. * Defines the interface used by display changed events
  13447. */
  13448. interface IDisplayChangedEventArgs {
  13449. /** Gets the vrDisplay object (if any) */
  13450. vrDisplay: Nullable<any>;
  13451. /** Gets a boolean indicating if webVR is supported */
  13452. vrSupported: boolean;
  13453. }
  13454. interface Engine {
  13455. /** @hidden */
  13456. _vrDisplay: any;
  13457. /** @hidden */
  13458. _vrSupported: boolean;
  13459. /** @hidden */
  13460. _oldSize: Size;
  13461. /** @hidden */
  13462. _oldHardwareScaleFactor: number;
  13463. /** @hidden */
  13464. _vrExclusivePointerMode: boolean;
  13465. /** @hidden */
  13466. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13467. /** @hidden */
  13468. _onVRDisplayPointerRestricted: () => void;
  13469. /** @hidden */
  13470. _onVRDisplayPointerUnrestricted: () => void;
  13471. /** @hidden */
  13472. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13473. /** @hidden */
  13474. _onVrDisplayDisconnect: Nullable<() => void>;
  13475. /** @hidden */
  13476. _onVrDisplayPresentChange: Nullable<() => void>;
  13477. /**
  13478. * Observable signaled when VR display mode changes
  13479. */
  13480. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13481. /**
  13482. * Observable signaled when VR request present is complete
  13483. */
  13484. onVRRequestPresentComplete: Observable<boolean>;
  13485. /**
  13486. * Observable signaled when VR request present starts
  13487. */
  13488. onVRRequestPresentStart: Observable<Engine>;
  13489. /**
  13490. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13491. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13492. */
  13493. isInVRExclusivePointerMode: boolean;
  13494. /**
  13495. * Gets a boolean indicating if a webVR device was detected
  13496. * @returns true if a webVR device was detected
  13497. */
  13498. isVRDevicePresent(): boolean;
  13499. /**
  13500. * Gets the current webVR device
  13501. * @returns the current webVR device (or null)
  13502. */
  13503. getVRDevice(): any;
  13504. /**
  13505. * Initializes a webVR display and starts listening to display change events
  13506. * The onVRDisplayChangedObservable will be notified upon these changes
  13507. * @returns A promise containing a VRDisplay and if vr is supported
  13508. */
  13509. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13510. /** @hidden */
  13511. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13512. /**
  13513. * Call this function to switch to webVR mode
  13514. * Will do nothing if webVR is not supported or if there is no webVR device
  13515. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13516. */
  13517. enableVR(): void;
  13518. /** @hidden */
  13519. _onVRFullScreenTriggered(): void;
  13520. }
  13521. }
  13522. }
  13523. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13524. import { Nullable } from "babylonjs/types";
  13525. import { Observable } from "babylonjs/Misc/observable";
  13526. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13527. import { Scene } from "babylonjs/scene";
  13528. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13529. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13530. import { Node } from "babylonjs/node";
  13531. import { Ray } from "babylonjs/Culling/ray";
  13532. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13533. import "babylonjs/Engines/Extensions/engine.webVR";
  13534. /**
  13535. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13536. * IMPORTANT!! The data is right-hand data.
  13537. * @export
  13538. * @interface DevicePose
  13539. */
  13540. export interface DevicePose {
  13541. /**
  13542. * The position of the device, values in array are [x,y,z].
  13543. */
  13544. readonly position: Nullable<Float32Array>;
  13545. /**
  13546. * The linearVelocity of the device, values in array are [x,y,z].
  13547. */
  13548. readonly linearVelocity: Nullable<Float32Array>;
  13549. /**
  13550. * The linearAcceleration of the device, values in array are [x,y,z].
  13551. */
  13552. readonly linearAcceleration: Nullable<Float32Array>;
  13553. /**
  13554. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13555. */
  13556. readonly orientation: Nullable<Float32Array>;
  13557. /**
  13558. * The angularVelocity of the device, values in array are [x,y,z].
  13559. */
  13560. readonly angularVelocity: Nullable<Float32Array>;
  13561. /**
  13562. * The angularAcceleration of the device, values in array are [x,y,z].
  13563. */
  13564. readonly angularAcceleration: Nullable<Float32Array>;
  13565. }
  13566. /**
  13567. * Interface representing a pose controlled object in Babylon.
  13568. * A pose controlled object has both regular pose values as well as pose values
  13569. * from an external device such as a VR head mounted display
  13570. */
  13571. export interface PoseControlled {
  13572. /**
  13573. * The position of the object in babylon space.
  13574. */
  13575. position: Vector3;
  13576. /**
  13577. * The rotation quaternion of the object in babylon space.
  13578. */
  13579. rotationQuaternion: Quaternion;
  13580. /**
  13581. * The position of the device in babylon space.
  13582. */
  13583. devicePosition?: Vector3;
  13584. /**
  13585. * The rotation quaternion of the device in babylon space.
  13586. */
  13587. deviceRotationQuaternion: Quaternion;
  13588. /**
  13589. * The raw pose coming from the device.
  13590. */
  13591. rawPose: Nullable<DevicePose>;
  13592. /**
  13593. * The scale of the device to be used when translating from device space to babylon space.
  13594. */
  13595. deviceScaleFactor: number;
  13596. /**
  13597. * Updates the poseControlled values based on the input device pose.
  13598. * @param poseData the pose data to update the object with
  13599. */
  13600. updateFromDevice(poseData: DevicePose): void;
  13601. }
  13602. /**
  13603. * Set of options to customize the webVRCamera
  13604. */
  13605. export interface WebVROptions {
  13606. /**
  13607. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13608. */
  13609. trackPosition?: boolean;
  13610. /**
  13611. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13612. */
  13613. positionScale?: number;
  13614. /**
  13615. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13616. */
  13617. displayName?: string;
  13618. /**
  13619. * Should the native controller meshes be initialized. (default: true)
  13620. */
  13621. controllerMeshes?: boolean;
  13622. /**
  13623. * Creating a default HemiLight only on controllers. (default: true)
  13624. */
  13625. defaultLightingOnControllers?: boolean;
  13626. /**
  13627. * If you don't want to use the default VR button of the helper. (default: false)
  13628. */
  13629. useCustomVRButton?: boolean;
  13630. /**
  13631. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13632. */
  13633. customVRButton?: HTMLButtonElement;
  13634. /**
  13635. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13636. */
  13637. rayLength?: number;
  13638. /**
  13639. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13640. */
  13641. defaultHeight?: number;
  13642. /**
  13643. * If multiview should be used if availible (default: false)
  13644. */
  13645. useMultiview?: boolean;
  13646. }
  13647. /**
  13648. * This represents a WebVR camera.
  13649. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13650. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13651. */
  13652. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13653. private webVROptions;
  13654. /**
  13655. * @hidden
  13656. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13657. */
  13658. _vrDevice: any;
  13659. /**
  13660. * The rawPose of the vrDevice.
  13661. */
  13662. rawPose: Nullable<DevicePose>;
  13663. private _onVREnabled;
  13664. private _specsVersion;
  13665. private _attached;
  13666. private _frameData;
  13667. protected _descendants: Array<Node>;
  13668. private _deviceRoomPosition;
  13669. /** @hidden */
  13670. _deviceRoomRotationQuaternion: Quaternion;
  13671. private _standingMatrix;
  13672. /**
  13673. * Represents device position in babylon space.
  13674. */
  13675. devicePosition: Vector3;
  13676. /**
  13677. * Represents device rotation in babylon space.
  13678. */
  13679. deviceRotationQuaternion: Quaternion;
  13680. /**
  13681. * The scale of the device to be used when translating from device space to babylon space.
  13682. */
  13683. deviceScaleFactor: number;
  13684. private _deviceToWorld;
  13685. private _worldToDevice;
  13686. /**
  13687. * References to the webVR controllers for the vrDevice.
  13688. */
  13689. controllers: Array<WebVRController>;
  13690. /**
  13691. * Emits an event when a controller is attached.
  13692. */
  13693. onControllersAttachedObservable: Observable<WebVRController[]>;
  13694. /**
  13695. * Emits an event when a controller's mesh has been loaded;
  13696. */
  13697. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13698. /**
  13699. * Emits an event when the HMD's pose has been updated.
  13700. */
  13701. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13702. private _poseSet;
  13703. /**
  13704. * If the rig cameras be used as parent instead of this camera.
  13705. */
  13706. rigParenting: boolean;
  13707. private _lightOnControllers;
  13708. private _defaultHeight?;
  13709. /**
  13710. * Instantiates a WebVRFreeCamera.
  13711. * @param name The name of the WebVRFreeCamera
  13712. * @param position The starting anchor position for the camera
  13713. * @param scene The scene the camera belongs to
  13714. * @param webVROptions a set of customizable options for the webVRCamera
  13715. */
  13716. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13717. /**
  13718. * Gets the device distance from the ground in meters.
  13719. * @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.
  13720. */
  13721. deviceDistanceToRoomGround(): number;
  13722. /**
  13723. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13724. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13725. */
  13726. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13727. /**
  13728. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13729. * @returns A promise with a boolean set to if the standing matrix is supported.
  13730. */
  13731. useStandingMatrixAsync(): Promise<boolean>;
  13732. /**
  13733. * Disposes the camera
  13734. */
  13735. dispose(): void;
  13736. /**
  13737. * Gets a vrController by name.
  13738. * @param name The name of the controller to retreive
  13739. * @returns the controller matching the name specified or null if not found
  13740. */
  13741. getControllerByName(name: string): Nullable<WebVRController>;
  13742. private _leftController;
  13743. /**
  13744. * The controller corrisponding to the users left hand.
  13745. */
  13746. readonly leftController: Nullable<WebVRController>;
  13747. private _rightController;
  13748. /**
  13749. * The controller corrisponding to the users right hand.
  13750. */
  13751. readonly rightController: Nullable<WebVRController>;
  13752. /**
  13753. * Casts a ray forward from the vrCamera's gaze.
  13754. * @param length Length of the ray (default: 100)
  13755. * @returns the ray corrisponding to the gaze
  13756. */
  13757. getForwardRay(length?: number): Ray;
  13758. /**
  13759. * @hidden
  13760. * Updates the camera based on device's frame data
  13761. */
  13762. _checkInputs(): void;
  13763. /**
  13764. * Updates the poseControlled values based on the input device pose.
  13765. * @param poseData Pose coming from the device
  13766. */
  13767. updateFromDevice(poseData: DevicePose): void;
  13768. private _htmlElementAttached;
  13769. private _detachIfAttached;
  13770. /**
  13771. * WebVR's attach control will start broadcasting frames to the device.
  13772. * Note that in certain browsers (chrome for example) this function must be called
  13773. * within a user-interaction callback. Example:
  13774. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13775. *
  13776. * @param element html element to attach the vrDevice to
  13777. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13778. */
  13779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13780. /**
  13781. * Detaches the camera from the html element and disables VR
  13782. *
  13783. * @param element html element to detach from
  13784. */
  13785. detachControl(element: HTMLElement): void;
  13786. /**
  13787. * @returns the name of this class
  13788. */
  13789. getClassName(): string;
  13790. /**
  13791. * Calls resetPose on the vrDisplay
  13792. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13793. */
  13794. resetToCurrentRotation(): void;
  13795. /**
  13796. * @hidden
  13797. * Updates the rig cameras (left and right eye)
  13798. */
  13799. _updateRigCameras(): void;
  13800. private _workingVector;
  13801. private _oneVector;
  13802. private _workingMatrix;
  13803. private updateCacheCalled;
  13804. private _correctPositionIfNotTrackPosition;
  13805. /**
  13806. * @hidden
  13807. * Updates the cached values of the camera
  13808. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13809. */
  13810. _updateCache(ignoreParentClass?: boolean): void;
  13811. /**
  13812. * @hidden
  13813. * Get current device position in babylon world
  13814. */
  13815. _computeDevicePosition(): void;
  13816. /**
  13817. * Updates the current device position and rotation in the babylon world
  13818. */
  13819. update(): void;
  13820. /**
  13821. * @hidden
  13822. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13823. * @returns an identity matrix
  13824. */
  13825. _getViewMatrix(): Matrix;
  13826. private _tmpMatrix;
  13827. /**
  13828. * This function is called by the two RIG cameras.
  13829. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13830. * @hidden
  13831. */
  13832. _getWebVRViewMatrix(): Matrix;
  13833. /** @hidden */
  13834. _getWebVRProjectionMatrix(): Matrix;
  13835. private _onGamepadConnectedObserver;
  13836. private _onGamepadDisconnectedObserver;
  13837. private _updateCacheWhenTrackingDisabledObserver;
  13838. /**
  13839. * Initializes the controllers and their meshes
  13840. */
  13841. initControllers(): void;
  13842. }
  13843. }
  13844. declare module "babylonjs/PostProcesses/postProcess" {
  13845. import { Nullable } from "babylonjs/types";
  13846. import { SmartArray } from "babylonjs/Misc/smartArray";
  13847. import { Observable } from "babylonjs/Misc/observable";
  13848. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13849. import { Camera } from "babylonjs/Cameras/camera";
  13850. import { Effect } from "babylonjs/Materials/effect";
  13851. import "babylonjs/Shaders/postprocess.vertex";
  13852. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13854. import { Engine } from "babylonjs/Engines/engine";
  13855. /**
  13856. * Size options for a post process
  13857. */
  13858. export type PostProcessOptions = {
  13859. width: number;
  13860. height: number;
  13861. };
  13862. /**
  13863. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13864. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13865. */
  13866. export class PostProcess {
  13867. /** Name of the PostProcess. */
  13868. name: string;
  13869. /**
  13870. * Gets or sets the unique id of the post process
  13871. */
  13872. uniqueId: number;
  13873. /**
  13874. * Width of the texture to apply the post process on
  13875. */
  13876. width: number;
  13877. /**
  13878. * Height of the texture to apply the post process on
  13879. */
  13880. height: number;
  13881. /**
  13882. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13883. * @hidden
  13884. */
  13885. _outputTexture: Nullable<InternalTexture>;
  13886. /**
  13887. * Sampling mode used by the shader
  13888. * See https://doc.babylonjs.com/classes/3.1/texture
  13889. */
  13890. renderTargetSamplingMode: number;
  13891. /**
  13892. * Clear color to use when screen clearing
  13893. */
  13894. clearColor: Color4;
  13895. /**
  13896. * If the buffer needs to be cleared before applying the post process. (default: true)
  13897. * Should be set to false if shader will overwrite all previous pixels.
  13898. */
  13899. autoClear: boolean;
  13900. /**
  13901. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13902. */
  13903. alphaMode: number;
  13904. /**
  13905. * Sets the setAlphaBlendConstants of the babylon engine
  13906. */
  13907. alphaConstants: Color4;
  13908. /**
  13909. * Animations to be used for the post processing
  13910. */
  13911. animations: import("babylonjs/Animations/animation").Animation[];
  13912. /**
  13913. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13914. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13915. */
  13916. enablePixelPerfectMode: boolean;
  13917. /**
  13918. * Force the postprocess to be applied without taking in account viewport
  13919. */
  13920. forceFullscreenViewport: boolean;
  13921. /**
  13922. * List of inspectable custom properties (used by the Inspector)
  13923. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13924. */
  13925. inspectableCustomProperties: IInspectable[];
  13926. /**
  13927. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13928. *
  13929. * | Value | Type | Description |
  13930. * | ----- | ----------------------------------- | ----------- |
  13931. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13932. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13933. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13934. *
  13935. */
  13936. scaleMode: number;
  13937. /**
  13938. * Force textures to be a power of two (default: false)
  13939. */
  13940. alwaysForcePOT: boolean;
  13941. private _samples;
  13942. /**
  13943. * Number of sample textures (default: 1)
  13944. */
  13945. samples: number;
  13946. /**
  13947. * Modify the scale of the post process to be the same as the viewport (default: false)
  13948. */
  13949. adaptScaleToCurrentViewport: boolean;
  13950. private _camera;
  13951. private _scene;
  13952. private _engine;
  13953. private _options;
  13954. private _reusable;
  13955. private _textureType;
  13956. /**
  13957. * Smart array of input and output textures for the post process.
  13958. * @hidden
  13959. */
  13960. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13961. /**
  13962. * The index in _textures that corresponds to the output texture.
  13963. * @hidden
  13964. */
  13965. _currentRenderTextureInd: number;
  13966. private _effect;
  13967. private _samplers;
  13968. private _fragmentUrl;
  13969. private _vertexUrl;
  13970. private _parameters;
  13971. private _scaleRatio;
  13972. protected _indexParameters: any;
  13973. private _shareOutputWithPostProcess;
  13974. private _texelSize;
  13975. private _forcedOutputTexture;
  13976. /**
  13977. * Returns the fragment url or shader name used in the post process.
  13978. * @returns the fragment url or name in the shader store.
  13979. */
  13980. getEffectName(): string;
  13981. /**
  13982. * An event triggered when the postprocess is activated.
  13983. */
  13984. onActivateObservable: Observable<Camera>;
  13985. private _onActivateObserver;
  13986. /**
  13987. * A function that is added to the onActivateObservable
  13988. */
  13989. onActivate: Nullable<(camera: Camera) => void>;
  13990. /**
  13991. * An event triggered when the postprocess changes its size.
  13992. */
  13993. onSizeChangedObservable: Observable<PostProcess>;
  13994. private _onSizeChangedObserver;
  13995. /**
  13996. * A function that is added to the onSizeChangedObservable
  13997. */
  13998. onSizeChanged: (postProcess: PostProcess) => void;
  13999. /**
  14000. * An event triggered when the postprocess applies its effect.
  14001. */
  14002. onApplyObservable: Observable<Effect>;
  14003. private _onApplyObserver;
  14004. /**
  14005. * A function that is added to the onApplyObservable
  14006. */
  14007. onApply: (effect: Effect) => void;
  14008. /**
  14009. * An event triggered before rendering the postprocess
  14010. */
  14011. onBeforeRenderObservable: Observable<Effect>;
  14012. private _onBeforeRenderObserver;
  14013. /**
  14014. * A function that is added to the onBeforeRenderObservable
  14015. */
  14016. onBeforeRender: (effect: Effect) => void;
  14017. /**
  14018. * An event triggered after rendering the postprocess
  14019. */
  14020. onAfterRenderObservable: Observable<Effect>;
  14021. private _onAfterRenderObserver;
  14022. /**
  14023. * A function that is added to the onAfterRenderObservable
  14024. */
  14025. onAfterRender: (efect: Effect) => void;
  14026. /**
  14027. * 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
  14028. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14029. */
  14030. inputTexture: InternalTexture;
  14031. /**
  14032. * Gets the camera which post process is applied to.
  14033. * @returns The camera the post process is applied to.
  14034. */
  14035. getCamera(): Camera;
  14036. /**
  14037. * Gets the texel size of the postprocess.
  14038. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14039. */
  14040. readonly texelSize: Vector2;
  14041. /**
  14042. * Creates a new instance PostProcess
  14043. * @param name The name of the PostProcess.
  14044. * @param fragmentUrl The url of the fragment shader to be used.
  14045. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14046. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14047. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14048. * @param camera The camera to apply the render pass to.
  14049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14050. * @param engine The engine which the post process will be applied. (default: current engine)
  14051. * @param reusable If the post process can be reused on the same frame. (default: false)
  14052. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14053. * @param textureType Type of textures used when performing the post process. (default: 0)
  14054. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14055. * @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
  14056. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14057. */
  14058. constructor(
  14059. /** Name of the PostProcess. */
  14060. 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);
  14061. /**
  14062. * Gets a string idenfifying the name of the class
  14063. * @returns "PostProcess" string
  14064. */
  14065. getClassName(): string;
  14066. /**
  14067. * Gets the engine which this post process belongs to.
  14068. * @returns The engine the post process was enabled with.
  14069. */
  14070. getEngine(): Engine;
  14071. /**
  14072. * The effect that is created when initializing the post process.
  14073. * @returns The created effect corrisponding the the postprocess.
  14074. */
  14075. getEffect(): Effect;
  14076. /**
  14077. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14078. * @param postProcess The post process to share the output with.
  14079. * @returns This post process.
  14080. */
  14081. shareOutputWith(postProcess: PostProcess): PostProcess;
  14082. /**
  14083. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14084. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14085. */
  14086. useOwnOutput(): void;
  14087. /**
  14088. * Updates the effect with the current post process compile time values and recompiles the shader.
  14089. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14090. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14091. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14092. * @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
  14093. * @param onCompiled Called when the shader has been compiled.
  14094. * @param onError Called if there is an error when compiling a shader.
  14095. */
  14096. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14097. /**
  14098. * The post process is reusable if it can be used multiple times within one frame.
  14099. * @returns If the post process is reusable
  14100. */
  14101. isReusable(): boolean;
  14102. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14103. markTextureDirty(): void;
  14104. /**
  14105. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14106. * 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.
  14107. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14108. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14109. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14110. * @returns The target texture that was bound to be written to.
  14111. */
  14112. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14113. /**
  14114. * If the post process is supported.
  14115. */
  14116. readonly isSupported: boolean;
  14117. /**
  14118. * The aspect ratio of the output texture.
  14119. */
  14120. readonly aspectRatio: number;
  14121. /**
  14122. * Get a value indicating if the post-process is ready to be used
  14123. * @returns true if the post-process is ready (shader is compiled)
  14124. */
  14125. isReady(): boolean;
  14126. /**
  14127. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14128. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14129. */
  14130. apply(): Nullable<Effect>;
  14131. private _disposeTextures;
  14132. /**
  14133. * Disposes the post process.
  14134. * @param camera The camera to dispose the post process on.
  14135. */
  14136. dispose(camera?: Camera): void;
  14137. }
  14138. }
  14139. declare module "babylonjs/PostProcesses/postProcessManager" {
  14140. import { Nullable } from "babylonjs/types";
  14141. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14142. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14143. import { Scene } from "babylonjs/scene";
  14144. /**
  14145. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14146. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14147. */
  14148. export class PostProcessManager {
  14149. private _scene;
  14150. private _indexBuffer;
  14151. private _vertexBuffers;
  14152. /**
  14153. * Creates a new instance PostProcess
  14154. * @param scene The scene that the post process is associated with.
  14155. */
  14156. constructor(scene: Scene);
  14157. private _prepareBuffers;
  14158. private _buildIndexBuffer;
  14159. /**
  14160. * Rebuilds the vertex buffers of the manager.
  14161. * @hidden
  14162. */
  14163. _rebuild(): void;
  14164. /**
  14165. * Prepares a frame to be run through a post process.
  14166. * @param sourceTexture The input texture to the post procesess. (default: null)
  14167. * @param postProcesses An array of post processes to be run. (default: null)
  14168. * @returns True if the post processes were able to be run.
  14169. * @hidden
  14170. */
  14171. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14172. /**
  14173. * Manually render a set of post processes to a texture.
  14174. * @param postProcesses An array of post processes to be run.
  14175. * @param targetTexture The target texture to render to.
  14176. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14177. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14178. * @param lodLevel defines which lod of the texture to render to
  14179. */
  14180. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14181. /**
  14182. * Finalize the result of the output of the postprocesses.
  14183. * @param doNotPresent If true the result will not be displayed to the screen.
  14184. * @param targetTexture The target texture to render to.
  14185. * @param faceIndex The index of the face to bind the target texture to.
  14186. * @param postProcesses The array of post processes to render.
  14187. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14188. * @hidden
  14189. */
  14190. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14191. /**
  14192. * Disposes of the post process manager.
  14193. */
  14194. dispose(): void;
  14195. }
  14196. }
  14197. declare module "babylonjs/Layers/layerSceneComponent" {
  14198. import { Scene } from "babylonjs/scene";
  14199. import { ISceneComponent } from "babylonjs/sceneComponent";
  14200. import { Layer } from "babylonjs/Layers/layer";
  14201. module "babylonjs/abstractScene" {
  14202. interface AbstractScene {
  14203. /**
  14204. * The list of layers (background and foreground) of the scene
  14205. */
  14206. layers: Array<Layer>;
  14207. }
  14208. }
  14209. /**
  14210. * Defines the layer scene component responsible to manage any layers
  14211. * in a given scene.
  14212. */
  14213. export class LayerSceneComponent implements ISceneComponent {
  14214. /**
  14215. * The component name helpfull to identify the component in the list of scene components.
  14216. */
  14217. readonly name: string;
  14218. /**
  14219. * The scene the component belongs to.
  14220. */
  14221. scene: Scene;
  14222. private _engine;
  14223. /**
  14224. * Creates a new instance of the component for the given scene
  14225. * @param scene Defines the scene to register the component in
  14226. */
  14227. constructor(scene: Scene);
  14228. /**
  14229. * Registers the component in a given scene
  14230. */
  14231. register(): void;
  14232. /**
  14233. * Rebuilds the elements related to this component in case of
  14234. * context lost for instance.
  14235. */
  14236. rebuild(): void;
  14237. /**
  14238. * Disposes the component and the associated ressources.
  14239. */
  14240. dispose(): void;
  14241. private _draw;
  14242. private _drawCameraPredicate;
  14243. private _drawCameraBackground;
  14244. private _drawCameraForeground;
  14245. private _drawRenderTargetPredicate;
  14246. private _drawRenderTargetBackground;
  14247. private _drawRenderTargetForeground;
  14248. }
  14249. }
  14250. declare module "babylonjs/Shaders/layer.fragment" {
  14251. /** @hidden */
  14252. export var layerPixelShader: {
  14253. name: string;
  14254. shader: string;
  14255. };
  14256. }
  14257. declare module "babylonjs/Shaders/layer.vertex" {
  14258. /** @hidden */
  14259. export var layerVertexShader: {
  14260. name: string;
  14261. shader: string;
  14262. };
  14263. }
  14264. declare module "babylonjs/Layers/layer" {
  14265. import { Observable } from "babylonjs/Misc/observable";
  14266. import { Nullable } from "babylonjs/types";
  14267. import { Scene } from "babylonjs/scene";
  14268. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14269. import { Texture } from "babylonjs/Materials/Textures/texture";
  14270. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14271. import "babylonjs/Shaders/layer.fragment";
  14272. import "babylonjs/Shaders/layer.vertex";
  14273. /**
  14274. * This represents a full screen 2d layer.
  14275. * This can be useful to display a picture in the background of your scene for instance.
  14276. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14277. */
  14278. export class Layer {
  14279. /**
  14280. * Define the name of the layer.
  14281. */
  14282. name: string;
  14283. /**
  14284. * Define the texture the layer should display.
  14285. */
  14286. texture: Nullable<Texture>;
  14287. /**
  14288. * Is the layer in background or foreground.
  14289. */
  14290. isBackground: boolean;
  14291. /**
  14292. * Define the color of the layer (instead of texture).
  14293. */
  14294. color: Color4;
  14295. /**
  14296. * Define the scale of the layer in order to zoom in out of the texture.
  14297. */
  14298. scale: Vector2;
  14299. /**
  14300. * Define an offset for the layer in order to shift the texture.
  14301. */
  14302. offset: Vector2;
  14303. /**
  14304. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14305. */
  14306. alphaBlendingMode: number;
  14307. /**
  14308. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14309. * Alpha test will not mix with the background color in case of transparency.
  14310. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14311. */
  14312. alphaTest: boolean;
  14313. /**
  14314. * Define a mask to restrict the layer to only some of the scene cameras.
  14315. */
  14316. layerMask: number;
  14317. /**
  14318. * Define the list of render target the layer is visible into.
  14319. */
  14320. renderTargetTextures: RenderTargetTexture[];
  14321. /**
  14322. * Define if the layer is only used in renderTarget or if it also
  14323. * renders in the main frame buffer of the canvas.
  14324. */
  14325. renderOnlyInRenderTargetTextures: boolean;
  14326. private _scene;
  14327. private _vertexBuffers;
  14328. private _indexBuffer;
  14329. private _effect;
  14330. private _alphaTestEffect;
  14331. /**
  14332. * An event triggered when the layer is disposed.
  14333. */
  14334. onDisposeObservable: Observable<Layer>;
  14335. private _onDisposeObserver;
  14336. /**
  14337. * Back compatibility with callback before the onDisposeObservable existed.
  14338. * The set callback will be triggered when the layer has been disposed.
  14339. */
  14340. onDispose: () => void;
  14341. /**
  14342. * An event triggered before rendering the scene
  14343. */
  14344. onBeforeRenderObservable: Observable<Layer>;
  14345. private _onBeforeRenderObserver;
  14346. /**
  14347. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14348. * The set callback will be triggered just before rendering the layer.
  14349. */
  14350. onBeforeRender: () => void;
  14351. /**
  14352. * An event triggered after rendering the scene
  14353. */
  14354. onAfterRenderObservable: Observable<Layer>;
  14355. private _onAfterRenderObserver;
  14356. /**
  14357. * Back compatibility with callback before the onAfterRenderObservable existed.
  14358. * The set callback will be triggered just after rendering the layer.
  14359. */
  14360. onAfterRender: () => void;
  14361. /**
  14362. * Instantiates a new layer.
  14363. * This represents a full screen 2d layer.
  14364. * This can be useful to display a picture in the background of your scene for instance.
  14365. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14366. * @param name Define the name of the layer in the scene
  14367. * @param imgUrl Define the url of the texture to display in the layer
  14368. * @param scene Define the scene the layer belongs to
  14369. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14370. * @param color Defines a color for the layer
  14371. */
  14372. constructor(
  14373. /**
  14374. * Define the name of the layer.
  14375. */
  14376. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14377. private _createIndexBuffer;
  14378. /** @hidden */
  14379. _rebuild(): void;
  14380. /**
  14381. * Renders the layer in the scene.
  14382. */
  14383. render(): void;
  14384. /**
  14385. * Disposes and releases the associated ressources.
  14386. */
  14387. dispose(): void;
  14388. }
  14389. }
  14390. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14391. import { Scene } from "babylonjs/scene";
  14392. import { ISceneComponent } from "babylonjs/sceneComponent";
  14393. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14394. module "babylonjs/abstractScene" {
  14395. interface AbstractScene {
  14396. /**
  14397. * The list of procedural textures added to the scene
  14398. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14399. */
  14400. proceduralTextures: Array<ProceduralTexture>;
  14401. }
  14402. }
  14403. /**
  14404. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14405. * in a given scene.
  14406. */
  14407. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14408. /**
  14409. * The component name helpfull to identify the component in the list of scene components.
  14410. */
  14411. readonly name: string;
  14412. /**
  14413. * The scene the component belongs to.
  14414. */
  14415. scene: Scene;
  14416. /**
  14417. * Creates a new instance of the component for the given scene
  14418. * @param scene Defines the scene to register the component in
  14419. */
  14420. constructor(scene: Scene);
  14421. /**
  14422. * Registers the component in a given scene
  14423. */
  14424. register(): void;
  14425. /**
  14426. * Rebuilds the elements related to this component in case of
  14427. * context lost for instance.
  14428. */
  14429. rebuild(): void;
  14430. /**
  14431. * Disposes the component and the associated ressources.
  14432. */
  14433. dispose(): void;
  14434. private _beforeClear;
  14435. }
  14436. }
  14437. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14438. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14439. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14440. module "babylonjs/Engines/engine" {
  14441. interface Engine {
  14442. /**
  14443. * Creates a new render target cube texture
  14444. * @param size defines the size of the texture
  14445. * @param options defines the options used to create the texture
  14446. * @returns a new render target cube texture stored in an InternalTexture
  14447. */
  14448. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14449. }
  14450. }
  14451. }
  14452. declare module "babylonjs/Shaders/procedural.vertex" {
  14453. /** @hidden */
  14454. export var proceduralVertexShader: {
  14455. name: string;
  14456. shader: string;
  14457. };
  14458. }
  14459. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14460. import { Observable } from "babylonjs/Misc/observable";
  14461. import { Nullable } from "babylonjs/types";
  14462. import { Scene } from "babylonjs/scene";
  14463. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14464. import { Effect } from "babylonjs/Materials/effect";
  14465. import { Texture } from "babylonjs/Materials/Textures/texture";
  14466. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14467. import "babylonjs/Shaders/procedural.vertex";
  14468. /**
  14469. * 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.
  14470. * This is the base class of any Procedural texture and contains most of the shareable code.
  14471. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14472. */
  14473. export class ProceduralTexture extends Texture {
  14474. isCube: boolean;
  14475. /**
  14476. * Define if the texture is enabled or not (disabled texture will not render)
  14477. */
  14478. isEnabled: boolean;
  14479. /**
  14480. * Define if the texture must be cleared before rendering (default is true)
  14481. */
  14482. autoClear: boolean;
  14483. /**
  14484. * Callback called when the texture is generated
  14485. */
  14486. onGenerated: () => void;
  14487. /**
  14488. * Event raised when the texture is generated
  14489. */
  14490. onGeneratedObservable: Observable<ProceduralTexture>;
  14491. /** @hidden */
  14492. _generateMipMaps: boolean;
  14493. /** @hidden **/
  14494. _effect: Effect;
  14495. /** @hidden */
  14496. _textures: {
  14497. [key: string]: Texture;
  14498. };
  14499. private _size;
  14500. private _currentRefreshId;
  14501. private _refreshRate;
  14502. private _vertexBuffers;
  14503. private _indexBuffer;
  14504. private _uniforms;
  14505. private _samplers;
  14506. private _fragment;
  14507. private _floats;
  14508. private _ints;
  14509. private _floatsArrays;
  14510. private _colors3;
  14511. private _colors4;
  14512. private _vectors2;
  14513. private _vectors3;
  14514. private _matrices;
  14515. private _fallbackTexture;
  14516. private _fallbackTextureUsed;
  14517. private _engine;
  14518. private _cachedDefines;
  14519. private _contentUpdateId;
  14520. private _contentData;
  14521. /**
  14522. * Instantiates a new procedural texture.
  14523. * 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.
  14524. * This is the base class of any Procedural texture and contains most of the shareable code.
  14525. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14526. * @param name Define the name of the texture
  14527. * @param size Define the size of the texture to create
  14528. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14529. * @param scene Define the scene the texture belongs to
  14530. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14531. * @param generateMipMaps Define if the texture should creates mip maps or not
  14532. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14533. */
  14534. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14535. /**
  14536. * The effect that is created when initializing the post process.
  14537. * @returns The created effect corrisponding the the postprocess.
  14538. */
  14539. getEffect(): Effect;
  14540. /**
  14541. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14542. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14543. */
  14544. getContent(): Nullable<ArrayBufferView>;
  14545. private _createIndexBuffer;
  14546. /** @hidden */
  14547. _rebuild(): void;
  14548. /**
  14549. * Resets the texture in order to recreate its associated resources.
  14550. * This can be called in case of context loss
  14551. */
  14552. reset(): void;
  14553. protected _getDefines(): string;
  14554. /**
  14555. * Is the texture ready to be used ? (rendered at least once)
  14556. * @returns true if ready, otherwise, false.
  14557. */
  14558. isReady(): boolean;
  14559. /**
  14560. * Resets the refresh counter of the texture and start bak from scratch.
  14561. * Could be useful to regenerate the texture if it is setup to render only once.
  14562. */
  14563. resetRefreshCounter(): void;
  14564. /**
  14565. * Set the fragment shader to use in order to render the texture.
  14566. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14567. */
  14568. setFragment(fragment: any): void;
  14569. /**
  14570. * Define the refresh rate of the texture or the rendering frequency.
  14571. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14572. */
  14573. refreshRate: number;
  14574. /** @hidden */
  14575. _shouldRender(): boolean;
  14576. /**
  14577. * Get the size the texture is rendering at.
  14578. * @returns the size (texture is always squared)
  14579. */
  14580. getRenderSize(): number;
  14581. /**
  14582. * Resize the texture to new value.
  14583. * @param size Define the new size the texture should have
  14584. * @param generateMipMaps Define whether the new texture should create mip maps
  14585. */
  14586. resize(size: number, generateMipMaps: boolean): void;
  14587. private _checkUniform;
  14588. /**
  14589. * Set a texture in the shader program used to render.
  14590. * @param name Define the name of the uniform samplers as defined in the shader
  14591. * @param texture Define the texture to bind to this sampler
  14592. * @return the texture itself allowing "fluent" like uniform updates
  14593. */
  14594. setTexture(name: string, texture: Texture): ProceduralTexture;
  14595. /**
  14596. * Set a float in the shader.
  14597. * @param name Define the name of the uniform as defined in the shader
  14598. * @param value Define the value to give to the uniform
  14599. * @return the texture itself allowing "fluent" like uniform updates
  14600. */
  14601. setFloat(name: string, value: number): ProceduralTexture;
  14602. /**
  14603. * Set a int in the shader.
  14604. * @param name Define the name of the uniform as defined in the shader
  14605. * @param value Define the value to give to the uniform
  14606. * @return the texture itself allowing "fluent" like uniform updates
  14607. */
  14608. setInt(name: string, value: number): ProceduralTexture;
  14609. /**
  14610. * Set an array of floats in the shader.
  14611. * @param name Define the name of the uniform as defined in the shader
  14612. * @param value Define the value to give to the uniform
  14613. * @return the texture itself allowing "fluent" like uniform updates
  14614. */
  14615. setFloats(name: string, value: number[]): ProceduralTexture;
  14616. /**
  14617. * Set a vec3 in the shader from a Color3.
  14618. * @param name Define the name of the uniform as defined in the shader
  14619. * @param value Define the value to give to the uniform
  14620. * @return the texture itself allowing "fluent" like uniform updates
  14621. */
  14622. setColor3(name: string, value: Color3): ProceduralTexture;
  14623. /**
  14624. * Set a vec4 in the shader from a Color4.
  14625. * @param name Define the name of the uniform as defined in the shader
  14626. * @param value Define the value to give to the uniform
  14627. * @return the texture itself allowing "fluent" like uniform updates
  14628. */
  14629. setColor4(name: string, value: Color4): ProceduralTexture;
  14630. /**
  14631. * Set a vec2 in the shader from a Vector2.
  14632. * @param name Define the name of the uniform as defined in the shader
  14633. * @param value Define the value to give to the uniform
  14634. * @return the texture itself allowing "fluent" like uniform updates
  14635. */
  14636. setVector2(name: string, value: Vector2): ProceduralTexture;
  14637. /**
  14638. * Set a vec3 in the shader from a Vector3.
  14639. * @param name Define the name of the uniform as defined in the shader
  14640. * @param value Define the value to give to the uniform
  14641. * @return the texture itself allowing "fluent" like uniform updates
  14642. */
  14643. setVector3(name: string, value: Vector3): ProceduralTexture;
  14644. /**
  14645. * Set a mat4 in the shader from a MAtrix.
  14646. * @param name Define the name of the uniform as defined in the shader
  14647. * @param value Define the value to give to the uniform
  14648. * @return the texture itself allowing "fluent" like uniform updates
  14649. */
  14650. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14651. /**
  14652. * Render the texture to its associated render target.
  14653. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14654. */
  14655. render(useCameraPostProcess?: boolean): void;
  14656. /**
  14657. * Clone the texture.
  14658. * @returns the cloned texture
  14659. */
  14660. clone(): ProceduralTexture;
  14661. /**
  14662. * Dispose the texture and release its asoociated resources.
  14663. */
  14664. dispose(): void;
  14665. }
  14666. }
  14667. declare module "babylonjs/Particles/baseParticleSystem" {
  14668. import { Nullable } from "babylonjs/types";
  14669. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14671. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14672. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14673. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14674. import { Scene } from "babylonjs/scene";
  14675. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14676. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14677. import { Texture } from "babylonjs/Materials/Textures/texture";
  14678. import { Animation } from "babylonjs/Animations/animation";
  14679. /**
  14680. * This represents the base class for particle system in Babylon.
  14681. * 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.
  14682. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14683. * @example https://doc.babylonjs.com/babylon101/particles
  14684. */
  14685. export class BaseParticleSystem {
  14686. /**
  14687. * Source color is added to the destination color without alpha affecting the result
  14688. */
  14689. static BLENDMODE_ONEONE: number;
  14690. /**
  14691. * Blend current color and particle color using particle’s alpha
  14692. */
  14693. static BLENDMODE_STANDARD: number;
  14694. /**
  14695. * Add current color and particle color multiplied by particle’s alpha
  14696. */
  14697. static BLENDMODE_ADD: number;
  14698. /**
  14699. * Multiply current color with particle color
  14700. */
  14701. static BLENDMODE_MULTIPLY: number;
  14702. /**
  14703. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14704. */
  14705. static BLENDMODE_MULTIPLYADD: number;
  14706. /**
  14707. * List of animations used by the particle system.
  14708. */
  14709. animations: Animation[];
  14710. /**
  14711. * The id of the Particle system.
  14712. */
  14713. id: string;
  14714. /**
  14715. * The friendly name of the Particle system.
  14716. */
  14717. name: string;
  14718. /**
  14719. * The rendering group used by the Particle system to chose when to render.
  14720. */
  14721. renderingGroupId: number;
  14722. /**
  14723. * The emitter represents the Mesh or position we are attaching the particle system to.
  14724. */
  14725. emitter: Nullable<AbstractMesh | Vector3>;
  14726. /**
  14727. * The maximum number of particles to emit per frame
  14728. */
  14729. emitRate: number;
  14730. /**
  14731. * If you want to launch only a few particles at once, that can be done, as well.
  14732. */
  14733. manualEmitCount: number;
  14734. /**
  14735. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14736. */
  14737. updateSpeed: number;
  14738. /**
  14739. * The amount of time the particle system is running (depends of the overall update speed).
  14740. */
  14741. targetStopDuration: number;
  14742. /**
  14743. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14744. */
  14745. disposeOnStop: boolean;
  14746. /**
  14747. * Minimum power of emitting particles.
  14748. */
  14749. minEmitPower: number;
  14750. /**
  14751. * Maximum power of emitting particles.
  14752. */
  14753. maxEmitPower: number;
  14754. /**
  14755. * Minimum life time of emitting particles.
  14756. */
  14757. minLifeTime: number;
  14758. /**
  14759. * Maximum life time of emitting particles.
  14760. */
  14761. maxLifeTime: number;
  14762. /**
  14763. * Minimum Size of emitting particles.
  14764. */
  14765. minSize: number;
  14766. /**
  14767. * Maximum Size of emitting particles.
  14768. */
  14769. maxSize: number;
  14770. /**
  14771. * Minimum scale of emitting particles on X axis.
  14772. */
  14773. minScaleX: number;
  14774. /**
  14775. * Maximum scale of emitting particles on X axis.
  14776. */
  14777. maxScaleX: number;
  14778. /**
  14779. * Minimum scale of emitting particles on Y axis.
  14780. */
  14781. minScaleY: number;
  14782. /**
  14783. * Maximum scale of emitting particles on Y axis.
  14784. */
  14785. maxScaleY: number;
  14786. /**
  14787. * Gets or sets the minimal initial rotation in radians.
  14788. */
  14789. minInitialRotation: number;
  14790. /**
  14791. * Gets or sets the maximal initial rotation in radians.
  14792. */
  14793. maxInitialRotation: number;
  14794. /**
  14795. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14796. */
  14797. minAngularSpeed: number;
  14798. /**
  14799. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14800. */
  14801. maxAngularSpeed: number;
  14802. /**
  14803. * The texture used to render each particle. (this can be a spritesheet)
  14804. */
  14805. particleTexture: Nullable<Texture>;
  14806. /**
  14807. * The layer mask we are rendering the particles through.
  14808. */
  14809. layerMask: number;
  14810. /**
  14811. * This can help using your own shader to render the particle system.
  14812. * The according effect will be created
  14813. */
  14814. customShader: any;
  14815. /**
  14816. * By default particle system starts as soon as they are created. This prevents the
  14817. * automatic start to happen and let you decide when to start emitting particles.
  14818. */
  14819. preventAutoStart: boolean;
  14820. private _noiseTexture;
  14821. /**
  14822. * Gets or sets a texture used to add random noise to particle positions
  14823. */
  14824. noiseTexture: Nullable<ProceduralTexture>;
  14825. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14826. noiseStrength: Vector3;
  14827. /**
  14828. * Callback triggered when the particle animation is ending.
  14829. */
  14830. onAnimationEnd: Nullable<() => void>;
  14831. /**
  14832. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14833. */
  14834. blendMode: number;
  14835. /**
  14836. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14837. * to override the particles.
  14838. */
  14839. forceDepthWrite: boolean;
  14840. /** 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 */
  14841. preWarmCycles: number;
  14842. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14843. preWarmStepOffset: number;
  14844. /**
  14845. * 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)
  14846. */
  14847. spriteCellChangeSpeed: number;
  14848. /**
  14849. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14850. */
  14851. startSpriteCellID: number;
  14852. /**
  14853. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14854. */
  14855. endSpriteCellID: number;
  14856. /**
  14857. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14858. */
  14859. spriteCellWidth: number;
  14860. /**
  14861. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14862. */
  14863. spriteCellHeight: number;
  14864. /**
  14865. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14866. */
  14867. spriteRandomStartCell: boolean;
  14868. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14869. translationPivot: Vector2;
  14870. /** @hidden */
  14871. protected _isAnimationSheetEnabled: boolean;
  14872. /**
  14873. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14874. */
  14875. beginAnimationOnStart: boolean;
  14876. /**
  14877. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14878. */
  14879. beginAnimationFrom: number;
  14880. /**
  14881. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14882. */
  14883. beginAnimationTo: number;
  14884. /**
  14885. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14886. */
  14887. beginAnimationLoop: boolean;
  14888. /**
  14889. * Gets or sets a world offset applied to all particles
  14890. */
  14891. worldOffset: Vector3;
  14892. /**
  14893. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14894. */
  14895. isAnimationSheetEnabled: boolean;
  14896. /**
  14897. * Get hosting scene
  14898. * @returns the scene
  14899. */
  14900. getScene(): Scene;
  14901. /**
  14902. * You can use gravity if you want to give an orientation to your particles.
  14903. */
  14904. gravity: Vector3;
  14905. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14906. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14907. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14908. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14909. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14910. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14911. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14912. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14913. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14914. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14915. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14916. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14917. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14918. /**
  14919. * Defines the delay in milliseconds before starting the system (0 by default)
  14920. */
  14921. startDelay: number;
  14922. /**
  14923. * Gets the current list of drag gradients.
  14924. * You must use addDragGradient and removeDragGradient to udpate this list
  14925. * @returns the list of drag gradients
  14926. */
  14927. getDragGradients(): Nullable<Array<FactorGradient>>;
  14928. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14929. limitVelocityDamping: number;
  14930. /**
  14931. * Gets the current list of limit velocity gradients.
  14932. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14933. * @returns the list of limit velocity gradients
  14934. */
  14935. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14936. /**
  14937. * Gets the current list of color gradients.
  14938. * You must use addColorGradient and removeColorGradient to udpate this list
  14939. * @returns the list of color gradients
  14940. */
  14941. getColorGradients(): Nullable<Array<ColorGradient>>;
  14942. /**
  14943. * Gets the current list of size gradients.
  14944. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14945. * @returns the list of size gradients
  14946. */
  14947. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14948. /**
  14949. * Gets the current list of color remap gradients.
  14950. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14951. * @returns the list of color remap gradients
  14952. */
  14953. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14954. /**
  14955. * Gets the current list of alpha remap gradients.
  14956. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14957. * @returns the list of alpha remap gradients
  14958. */
  14959. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14960. /**
  14961. * Gets the current list of life time gradients.
  14962. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14963. * @returns the list of life time gradients
  14964. */
  14965. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14966. /**
  14967. * Gets the current list of angular speed gradients.
  14968. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14969. * @returns the list of angular speed gradients
  14970. */
  14971. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14972. /**
  14973. * Gets the current list of velocity gradients.
  14974. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14975. * @returns the list of velocity gradients
  14976. */
  14977. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14978. /**
  14979. * Gets the current list of start size gradients.
  14980. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14981. * @returns the list of start size gradients
  14982. */
  14983. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14984. /**
  14985. * Gets the current list of emit rate gradients.
  14986. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14987. * @returns the list of emit rate gradients
  14988. */
  14989. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14990. /**
  14991. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14992. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14993. */
  14994. direction1: Vector3;
  14995. /**
  14996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14997. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14998. */
  14999. direction2: Vector3;
  15000. /**
  15001. * 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.
  15002. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15003. */
  15004. minEmitBox: Vector3;
  15005. /**
  15006. * 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.
  15007. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15008. */
  15009. maxEmitBox: Vector3;
  15010. /**
  15011. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15012. */
  15013. color1: Color4;
  15014. /**
  15015. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15016. */
  15017. color2: Color4;
  15018. /**
  15019. * Color the particle will have at the end of its lifetime
  15020. */
  15021. colorDead: Color4;
  15022. /**
  15023. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15024. */
  15025. textureMask: Color4;
  15026. /**
  15027. * The particle emitter type defines the emitter used by the particle system.
  15028. * It can be for example box, sphere, or cone...
  15029. */
  15030. particleEmitterType: IParticleEmitterType;
  15031. /** @hidden */
  15032. _isSubEmitter: boolean;
  15033. /**
  15034. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15035. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15036. */
  15037. billboardMode: number;
  15038. protected _isBillboardBased: boolean;
  15039. /**
  15040. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15041. */
  15042. isBillboardBased: boolean;
  15043. /**
  15044. * The scene the particle system belongs to.
  15045. */
  15046. protected _scene: Scene;
  15047. /**
  15048. * Local cache of defines for image processing.
  15049. */
  15050. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15051. /**
  15052. * Default configuration related to image processing available in the standard Material.
  15053. */
  15054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15055. /**
  15056. * Gets the image processing configuration used either in this material.
  15057. */
  15058. /**
  15059. * Sets the Default image processing configuration used either in the this material.
  15060. *
  15061. * If sets to null, the scene one is in use.
  15062. */
  15063. imageProcessingConfiguration: ImageProcessingConfiguration;
  15064. /**
  15065. * Attaches a new image processing configuration to the Standard Material.
  15066. * @param configuration
  15067. */
  15068. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15069. /** @hidden */
  15070. protected _reset(): void;
  15071. /** @hidden */
  15072. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15073. /**
  15074. * Instantiates a particle system.
  15075. * 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.
  15076. * @param name The name of the particle system
  15077. */
  15078. constructor(name: string);
  15079. /**
  15080. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15081. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15082. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15083. * @returns the emitter
  15084. */
  15085. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15086. /**
  15087. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15088. * @param radius The radius of the hemisphere to emit from
  15089. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15090. * @returns the emitter
  15091. */
  15092. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15093. /**
  15094. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15095. * @param radius The radius of the sphere to emit from
  15096. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15097. * @returns the emitter
  15098. */
  15099. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15100. /**
  15101. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15102. * @param radius The radius of the sphere to emit from
  15103. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15104. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15105. * @returns the emitter
  15106. */
  15107. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15108. /**
  15109. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15110. * @param radius The radius of the emission cylinder
  15111. * @param height The height of the emission cylinder
  15112. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15113. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15114. * @returns the emitter
  15115. */
  15116. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15117. /**
  15118. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15119. * @param radius The radius of the cylinder to emit from
  15120. * @param height The height of the emission cylinder
  15121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15124. * @returns the emitter
  15125. */
  15126. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15127. /**
  15128. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15129. * @param radius The radius of the cone to emit from
  15130. * @param angle The base angle of the cone
  15131. * @returns the emitter
  15132. */
  15133. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15134. /**
  15135. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15136. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15137. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15138. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15139. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15140. * @returns the emitter
  15141. */
  15142. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15143. }
  15144. }
  15145. declare module "babylonjs/Particles/subEmitter" {
  15146. import { Scene } from "babylonjs/scene";
  15147. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15148. /**
  15149. * Type of sub emitter
  15150. */
  15151. export enum SubEmitterType {
  15152. /**
  15153. * Attached to the particle over it's lifetime
  15154. */
  15155. ATTACHED = 0,
  15156. /**
  15157. * Created when the particle dies
  15158. */
  15159. END = 1
  15160. }
  15161. /**
  15162. * Sub emitter class used to emit particles from an existing particle
  15163. */
  15164. export class SubEmitter {
  15165. /**
  15166. * the particle system to be used by the sub emitter
  15167. */
  15168. particleSystem: ParticleSystem;
  15169. /**
  15170. * Type of the submitter (Default: END)
  15171. */
  15172. type: SubEmitterType;
  15173. /**
  15174. * 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)
  15175. * Note: This only is supported when using an emitter of type Mesh
  15176. */
  15177. inheritDirection: boolean;
  15178. /**
  15179. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15180. */
  15181. inheritedVelocityAmount: number;
  15182. /**
  15183. * Creates a sub emitter
  15184. * @param particleSystem the particle system to be used by the sub emitter
  15185. */
  15186. constructor(
  15187. /**
  15188. * the particle system to be used by the sub emitter
  15189. */
  15190. particleSystem: ParticleSystem);
  15191. /**
  15192. * Clones the sub emitter
  15193. * @returns the cloned sub emitter
  15194. */
  15195. clone(): SubEmitter;
  15196. /**
  15197. * Serialize current object to a JSON object
  15198. * @returns the serialized object
  15199. */
  15200. serialize(): any;
  15201. /** @hidden */
  15202. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15203. /**
  15204. * Creates a new SubEmitter from a serialized JSON version
  15205. * @param serializationObject defines the JSON object to read from
  15206. * @param scene defines the hosting scene
  15207. * @param rootUrl defines the rootUrl for data loading
  15208. * @returns a new SubEmitter
  15209. */
  15210. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15211. /** Release associated resources */
  15212. dispose(): void;
  15213. }
  15214. }
  15215. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15216. /** @hidden */
  15217. export var clipPlaneFragmentDeclaration: {
  15218. name: string;
  15219. shader: string;
  15220. };
  15221. }
  15222. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15223. /** @hidden */
  15224. export var imageProcessingDeclaration: {
  15225. name: string;
  15226. shader: string;
  15227. };
  15228. }
  15229. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15230. /** @hidden */
  15231. export var imageProcessingFunctions: {
  15232. name: string;
  15233. shader: string;
  15234. };
  15235. }
  15236. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15237. /** @hidden */
  15238. export var clipPlaneFragment: {
  15239. name: string;
  15240. shader: string;
  15241. };
  15242. }
  15243. declare module "babylonjs/Shaders/particles.fragment" {
  15244. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15245. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15246. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15247. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15248. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15249. /** @hidden */
  15250. export var particlesPixelShader: {
  15251. name: string;
  15252. shader: string;
  15253. };
  15254. }
  15255. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15256. /** @hidden */
  15257. export var clipPlaneVertexDeclaration: {
  15258. name: string;
  15259. shader: string;
  15260. };
  15261. }
  15262. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15263. /** @hidden */
  15264. export var clipPlaneVertex: {
  15265. name: string;
  15266. shader: string;
  15267. };
  15268. }
  15269. declare module "babylonjs/Shaders/particles.vertex" {
  15270. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15271. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15272. /** @hidden */
  15273. export var particlesVertexShader: {
  15274. name: string;
  15275. shader: string;
  15276. };
  15277. }
  15278. declare module "babylonjs/Particles/particleSystem" {
  15279. import { Nullable } from "babylonjs/types";
  15280. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15281. import { Observable } from "babylonjs/Misc/observable";
  15282. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15283. import { Effect } from "babylonjs/Materials/effect";
  15284. import { Scene, IDisposable } from "babylonjs/scene";
  15285. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15286. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15287. import { Particle } from "babylonjs/Particles/particle";
  15288. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15289. import "babylonjs/Shaders/particles.fragment";
  15290. import "babylonjs/Shaders/particles.vertex";
  15291. /**
  15292. * This represents a particle system in Babylon.
  15293. * 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.
  15294. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15295. * @example https://doc.babylonjs.com/babylon101/particles
  15296. */
  15297. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15298. /**
  15299. * Billboard mode will only apply to Y axis
  15300. */
  15301. static readonly BILLBOARDMODE_Y: number;
  15302. /**
  15303. * Billboard mode will apply to all axes
  15304. */
  15305. static readonly BILLBOARDMODE_ALL: number;
  15306. /**
  15307. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15308. */
  15309. static readonly BILLBOARDMODE_STRETCHED: number;
  15310. /**
  15311. * This function can be defined to provide custom update for active particles.
  15312. * This function will be called instead of regular update (age, position, color, etc.).
  15313. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15314. */
  15315. updateFunction: (particles: Particle[]) => void;
  15316. private _emitterWorldMatrix;
  15317. /**
  15318. * This function can be defined to specify initial direction for every new particle.
  15319. * It by default use the emitterType defined function
  15320. */
  15321. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15322. /**
  15323. * This function can be defined to specify initial position for every new particle.
  15324. * It by default use the emitterType defined function
  15325. */
  15326. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15327. /**
  15328. * @hidden
  15329. */
  15330. _inheritedVelocityOffset: Vector3;
  15331. /**
  15332. * An event triggered when the system is disposed
  15333. */
  15334. onDisposeObservable: Observable<ParticleSystem>;
  15335. private _onDisposeObserver;
  15336. /**
  15337. * Sets a callback that will be triggered when the system is disposed
  15338. */
  15339. onDispose: () => void;
  15340. private _particles;
  15341. private _epsilon;
  15342. private _capacity;
  15343. private _stockParticles;
  15344. private _newPartsExcess;
  15345. private _vertexData;
  15346. private _vertexBuffer;
  15347. private _vertexBuffers;
  15348. private _spriteBuffer;
  15349. private _indexBuffer;
  15350. private _effect;
  15351. private _customEffect;
  15352. private _cachedDefines;
  15353. private _scaledColorStep;
  15354. private _colorDiff;
  15355. private _scaledDirection;
  15356. private _scaledGravity;
  15357. private _currentRenderId;
  15358. private _alive;
  15359. private _useInstancing;
  15360. private _started;
  15361. private _stopped;
  15362. private _actualFrame;
  15363. private _scaledUpdateSpeed;
  15364. private _vertexBufferSize;
  15365. /** @hidden */
  15366. _currentEmitRateGradient: Nullable<FactorGradient>;
  15367. /** @hidden */
  15368. _currentEmitRate1: number;
  15369. /** @hidden */
  15370. _currentEmitRate2: number;
  15371. /** @hidden */
  15372. _currentStartSizeGradient: Nullable<FactorGradient>;
  15373. /** @hidden */
  15374. _currentStartSize1: number;
  15375. /** @hidden */
  15376. _currentStartSize2: number;
  15377. private readonly _rawTextureWidth;
  15378. private _rampGradientsTexture;
  15379. private _useRampGradients;
  15380. /** Gets or sets a boolean indicating that ramp gradients must be used
  15381. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15382. */
  15383. useRampGradients: boolean;
  15384. /**
  15385. * 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.
  15386. * 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: [])
  15387. */
  15388. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15389. private _subEmitters;
  15390. /**
  15391. * @hidden
  15392. * If the particle systems emitter should be disposed when the particle system is disposed
  15393. */
  15394. _disposeEmitterOnDispose: boolean;
  15395. /**
  15396. * The current active Sub-systems, this property is used by the root particle system only.
  15397. */
  15398. activeSubSystems: Array<ParticleSystem>;
  15399. private _rootParticleSystem;
  15400. /**
  15401. * Gets the current list of active particles
  15402. */
  15403. readonly particles: Particle[];
  15404. /**
  15405. * Returns the string "ParticleSystem"
  15406. * @returns a string containing the class name
  15407. */
  15408. getClassName(): string;
  15409. /**
  15410. * Instantiates a particle system.
  15411. * 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.
  15412. * @param name The name of the particle system
  15413. * @param capacity The max number of particles alive at the same time
  15414. * @param scene The scene the particle system belongs to
  15415. * @param customEffect a custom effect used to change the way particles are rendered by default
  15416. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15417. * @param epsilon Offset used to render the particles
  15418. */
  15419. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15420. private _addFactorGradient;
  15421. private _removeFactorGradient;
  15422. /**
  15423. * Adds a new life time gradient
  15424. * @param gradient defines the gradient to use (between 0 and 1)
  15425. * @param factor defines the life time factor to affect to the specified gradient
  15426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15427. * @returns the current particle system
  15428. */
  15429. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15430. /**
  15431. * Remove a specific life time gradient
  15432. * @param gradient defines the gradient to remove
  15433. * @returns the current particle system
  15434. */
  15435. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15436. /**
  15437. * Adds a new size gradient
  15438. * @param gradient defines the gradient to use (between 0 and 1)
  15439. * @param factor defines the size factor to affect to the specified gradient
  15440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15441. * @returns the current particle system
  15442. */
  15443. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15444. /**
  15445. * Remove a specific size gradient
  15446. * @param gradient defines the gradient to remove
  15447. * @returns the current particle system
  15448. */
  15449. removeSizeGradient(gradient: number): IParticleSystem;
  15450. /**
  15451. * Adds a new color remap gradient
  15452. * @param gradient defines the gradient to use (between 0 and 1)
  15453. * @param min defines the color remap minimal range
  15454. * @param max defines the color remap maximal range
  15455. * @returns the current particle system
  15456. */
  15457. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15458. /**
  15459. * Remove a specific color remap gradient
  15460. * @param gradient defines the gradient to remove
  15461. * @returns the current particle system
  15462. */
  15463. removeColorRemapGradient(gradient: number): IParticleSystem;
  15464. /**
  15465. * Adds a new alpha remap gradient
  15466. * @param gradient defines the gradient to use (between 0 and 1)
  15467. * @param min defines the alpha remap minimal range
  15468. * @param max defines the alpha remap maximal range
  15469. * @returns the current particle system
  15470. */
  15471. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15472. /**
  15473. * Remove a specific alpha remap gradient
  15474. * @param gradient defines the gradient to remove
  15475. * @returns the current particle system
  15476. */
  15477. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15478. /**
  15479. * Adds a new angular speed gradient
  15480. * @param gradient defines the gradient to use (between 0 and 1)
  15481. * @param factor defines the angular speed to affect to the specified gradient
  15482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15483. * @returns the current particle system
  15484. */
  15485. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15486. /**
  15487. * Remove a specific angular speed gradient
  15488. * @param gradient defines the gradient to remove
  15489. * @returns the current particle system
  15490. */
  15491. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15492. /**
  15493. * Adds a new velocity gradient
  15494. * @param gradient defines the gradient to use (between 0 and 1)
  15495. * @param factor defines the velocity to affect to the specified gradient
  15496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15497. * @returns the current particle system
  15498. */
  15499. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15500. /**
  15501. * Remove a specific velocity gradient
  15502. * @param gradient defines the gradient to remove
  15503. * @returns the current particle system
  15504. */
  15505. removeVelocityGradient(gradient: number): IParticleSystem;
  15506. /**
  15507. * Adds a new limit velocity gradient
  15508. * @param gradient defines the gradient to use (between 0 and 1)
  15509. * @param factor defines the limit velocity value to affect to the specified gradient
  15510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15511. * @returns the current particle system
  15512. */
  15513. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15514. /**
  15515. * Remove a specific limit velocity gradient
  15516. * @param gradient defines the gradient to remove
  15517. * @returns the current particle system
  15518. */
  15519. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15520. /**
  15521. * Adds a new drag gradient
  15522. * @param gradient defines the gradient to use (between 0 and 1)
  15523. * @param factor defines the drag value to affect to the specified gradient
  15524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15525. * @returns the current particle system
  15526. */
  15527. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15528. /**
  15529. * Remove a specific drag gradient
  15530. * @param gradient defines the gradient to remove
  15531. * @returns the current particle system
  15532. */
  15533. removeDragGradient(gradient: number): IParticleSystem;
  15534. /**
  15535. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15536. * @param gradient defines the gradient to use (between 0 and 1)
  15537. * @param factor defines the emit rate value to affect to the specified gradient
  15538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15539. * @returns the current particle system
  15540. */
  15541. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15542. /**
  15543. * Remove a specific emit rate gradient
  15544. * @param gradient defines the gradient to remove
  15545. * @returns the current particle system
  15546. */
  15547. removeEmitRateGradient(gradient: number): IParticleSystem;
  15548. /**
  15549. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15550. * @param gradient defines the gradient to use (between 0 and 1)
  15551. * @param factor defines the start size value to affect to the specified gradient
  15552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15553. * @returns the current particle system
  15554. */
  15555. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15556. /**
  15557. * Remove a specific start size gradient
  15558. * @param gradient defines the gradient to remove
  15559. * @returns the current particle system
  15560. */
  15561. removeStartSizeGradient(gradient: number): IParticleSystem;
  15562. private _createRampGradientTexture;
  15563. /**
  15564. * Gets the current list of ramp gradients.
  15565. * You must use addRampGradient and removeRampGradient to udpate this list
  15566. * @returns the list of ramp gradients
  15567. */
  15568. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15569. /**
  15570. * Adds a new ramp gradient used to remap particle colors
  15571. * @param gradient defines the gradient to use (between 0 and 1)
  15572. * @param color defines the color to affect to the specified gradient
  15573. * @returns the current particle system
  15574. */
  15575. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15576. /**
  15577. * Remove a specific ramp gradient
  15578. * @param gradient defines the gradient to remove
  15579. * @returns the current particle system
  15580. */
  15581. removeRampGradient(gradient: number): ParticleSystem;
  15582. /**
  15583. * Adds a new color gradient
  15584. * @param gradient defines the gradient to use (between 0 and 1)
  15585. * @param color1 defines the color to affect to the specified gradient
  15586. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15587. * @returns this particle system
  15588. */
  15589. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15590. /**
  15591. * Remove a specific color gradient
  15592. * @param gradient defines the gradient to remove
  15593. * @returns this particle system
  15594. */
  15595. removeColorGradient(gradient: number): IParticleSystem;
  15596. private _fetchR;
  15597. protected _reset(): void;
  15598. private _resetEffect;
  15599. private _createVertexBuffers;
  15600. private _createIndexBuffer;
  15601. /**
  15602. * Gets the maximum number of particles active at the same time.
  15603. * @returns The max number of active particles.
  15604. */
  15605. getCapacity(): number;
  15606. /**
  15607. * Gets whether there are still active particles in the system.
  15608. * @returns True if it is alive, otherwise false.
  15609. */
  15610. isAlive(): boolean;
  15611. /**
  15612. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15613. * @returns True if it has been started, otherwise false.
  15614. */
  15615. isStarted(): boolean;
  15616. private _prepareSubEmitterInternalArray;
  15617. /**
  15618. * Starts the particle system and begins to emit
  15619. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15620. */
  15621. start(delay?: number): void;
  15622. /**
  15623. * Stops the particle system.
  15624. * @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.
  15625. */
  15626. stop(stopSubEmitters?: boolean): void;
  15627. /**
  15628. * Remove all active particles
  15629. */
  15630. reset(): void;
  15631. /**
  15632. * @hidden (for internal use only)
  15633. */
  15634. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15635. /**
  15636. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15637. * Its lifetime will start back at 0.
  15638. */
  15639. recycleParticle: (particle: Particle) => void;
  15640. private _stopSubEmitters;
  15641. private _createParticle;
  15642. private _removeFromRoot;
  15643. private _emitFromParticle;
  15644. private _update;
  15645. /** @hidden */
  15646. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15647. /** @hidden */
  15648. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15649. /** @hidden */
  15650. private _getEffect;
  15651. /**
  15652. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15653. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15654. */
  15655. animate(preWarmOnly?: boolean): void;
  15656. private _appendParticleVertices;
  15657. /**
  15658. * Rebuilds the particle system.
  15659. */
  15660. rebuild(): void;
  15661. /**
  15662. * Is this system ready to be used/rendered
  15663. * @return true if the system is ready
  15664. */
  15665. isReady(): boolean;
  15666. private _render;
  15667. /**
  15668. * Renders the particle system in its current state.
  15669. * @returns the current number of particles
  15670. */
  15671. render(): number;
  15672. /**
  15673. * Disposes the particle system and free the associated resources
  15674. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15675. */
  15676. dispose(disposeTexture?: boolean): void;
  15677. /**
  15678. * Clones the particle system.
  15679. * @param name The name of the cloned object
  15680. * @param newEmitter The new emitter to use
  15681. * @returns the cloned particle system
  15682. */
  15683. clone(name: string, newEmitter: any): ParticleSystem;
  15684. /**
  15685. * Serializes the particle system to a JSON object.
  15686. * @returns the JSON object
  15687. */
  15688. serialize(): any;
  15689. /** @hidden */
  15690. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15691. /** @hidden */
  15692. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15693. /**
  15694. * Parses a JSON object to create a particle system.
  15695. * @param parsedParticleSystem The JSON object to parse
  15696. * @param scene The scene to create the particle system in
  15697. * @param rootUrl The root url to use to load external dependencies like texture
  15698. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15699. * @returns the Parsed particle system
  15700. */
  15701. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15702. }
  15703. }
  15704. declare module "babylonjs/Particles/particle" {
  15705. import { Nullable } from "babylonjs/types";
  15706. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15707. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15708. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15709. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15710. /**
  15711. * A particle represents one of the element emitted by a particle system.
  15712. * This is mainly define by its coordinates, direction, velocity and age.
  15713. */
  15714. export class Particle {
  15715. /**
  15716. * The particle system the particle belongs to.
  15717. */
  15718. particleSystem: ParticleSystem;
  15719. private static _Count;
  15720. /**
  15721. * Unique ID of the particle
  15722. */
  15723. id: number;
  15724. /**
  15725. * The world position of the particle in the scene.
  15726. */
  15727. position: Vector3;
  15728. /**
  15729. * The world direction of the particle in the scene.
  15730. */
  15731. direction: Vector3;
  15732. /**
  15733. * The color of the particle.
  15734. */
  15735. color: Color4;
  15736. /**
  15737. * The color change of the particle per step.
  15738. */
  15739. colorStep: Color4;
  15740. /**
  15741. * Defines how long will the life of the particle be.
  15742. */
  15743. lifeTime: number;
  15744. /**
  15745. * The current age of the particle.
  15746. */
  15747. age: number;
  15748. /**
  15749. * The current size of the particle.
  15750. */
  15751. size: number;
  15752. /**
  15753. * The current scale of the particle.
  15754. */
  15755. scale: Vector2;
  15756. /**
  15757. * The current angle of the particle.
  15758. */
  15759. angle: number;
  15760. /**
  15761. * Defines how fast is the angle changing.
  15762. */
  15763. angularSpeed: number;
  15764. /**
  15765. * Defines the cell index used by the particle to be rendered from a sprite.
  15766. */
  15767. cellIndex: number;
  15768. /**
  15769. * The information required to support color remapping
  15770. */
  15771. remapData: Vector4;
  15772. /** @hidden */
  15773. _randomCellOffset?: number;
  15774. /** @hidden */
  15775. _initialDirection: Nullable<Vector3>;
  15776. /** @hidden */
  15777. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15778. /** @hidden */
  15779. _initialStartSpriteCellID: number;
  15780. /** @hidden */
  15781. _initialEndSpriteCellID: number;
  15782. /** @hidden */
  15783. _currentColorGradient: Nullable<ColorGradient>;
  15784. /** @hidden */
  15785. _currentColor1: Color4;
  15786. /** @hidden */
  15787. _currentColor2: Color4;
  15788. /** @hidden */
  15789. _currentSizeGradient: Nullable<FactorGradient>;
  15790. /** @hidden */
  15791. _currentSize1: number;
  15792. /** @hidden */
  15793. _currentSize2: number;
  15794. /** @hidden */
  15795. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15796. /** @hidden */
  15797. _currentAngularSpeed1: number;
  15798. /** @hidden */
  15799. _currentAngularSpeed2: number;
  15800. /** @hidden */
  15801. _currentVelocityGradient: Nullable<FactorGradient>;
  15802. /** @hidden */
  15803. _currentVelocity1: number;
  15804. /** @hidden */
  15805. _currentVelocity2: number;
  15806. /** @hidden */
  15807. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15808. /** @hidden */
  15809. _currentLimitVelocity1: number;
  15810. /** @hidden */
  15811. _currentLimitVelocity2: number;
  15812. /** @hidden */
  15813. _currentDragGradient: Nullable<FactorGradient>;
  15814. /** @hidden */
  15815. _currentDrag1: number;
  15816. /** @hidden */
  15817. _currentDrag2: number;
  15818. /** @hidden */
  15819. _randomNoiseCoordinates1: Vector3;
  15820. /** @hidden */
  15821. _randomNoiseCoordinates2: Vector3;
  15822. /**
  15823. * Creates a new instance Particle
  15824. * @param particleSystem the particle system the particle belongs to
  15825. */
  15826. constructor(
  15827. /**
  15828. * The particle system the particle belongs to.
  15829. */
  15830. particleSystem: ParticleSystem);
  15831. private updateCellInfoFromSystem;
  15832. /**
  15833. * Defines how the sprite cell index is updated for the particle
  15834. */
  15835. updateCellIndex(): void;
  15836. /** @hidden */
  15837. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15838. /** @hidden */
  15839. _inheritParticleInfoToSubEmitters(): void;
  15840. /** @hidden */
  15841. _reset(): void;
  15842. /**
  15843. * Copy the properties of particle to another one.
  15844. * @param other the particle to copy the information to.
  15845. */
  15846. copyTo(other: Particle): void;
  15847. }
  15848. }
  15849. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15850. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15851. import { Effect } from "babylonjs/Materials/effect";
  15852. import { Particle } from "babylonjs/Particles/particle";
  15853. /**
  15854. * Particle emitter represents a volume emitting particles.
  15855. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15856. */
  15857. export interface IParticleEmitterType {
  15858. /**
  15859. * Called by the particle System when the direction is computed for the created particle.
  15860. * @param worldMatrix is the world matrix of the particle system
  15861. * @param directionToUpdate is the direction vector to update with the result
  15862. * @param particle is the particle we are computed the direction for
  15863. */
  15864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15865. /**
  15866. * Called by the particle System when the position is computed for the created particle.
  15867. * @param worldMatrix is the world matrix of the particle system
  15868. * @param positionToUpdate is the position vector to update with the result
  15869. * @param particle is the particle we are computed the position for
  15870. */
  15871. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15872. /**
  15873. * Clones the current emitter and returns a copy of it
  15874. * @returns the new emitter
  15875. */
  15876. clone(): IParticleEmitterType;
  15877. /**
  15878. * Called by the GPUParticleSystem to setup the update shader
  15879. * @param effect defines the update shader
  15880. */
  15881. applyToShader(effect: Effect): void;
  15882. /**
  15883. * Returns a string to use to update the GPU particles update shader
  15884. * @returns the effect defines string
  15885. */
  15886. getEffectDefines(): string;
  15887. /**
  15888. * Returns a string representing the class name
  15889. * @returns a string containing the class name
  15890. */
  15891. getClassName(): string;
  15892. /**
  15893. * Serializes the particle system to a JSON object.
  15894. * @returns the JSON object
  15895. */
  15896. serialize(): any;
  15897. /**
  15898. * Parse properties from a JSON object
  15899. * @param serializationObject defines the JSON object
  15900. */
  15901. parse(serializationObject: any): void;
  15902. }
  15903. }
  15904. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15905. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15906. import { Effect } from "babylonjs/Materials/effect";
  15907. import { Particle } from "babylonjs/Particles/particle";
  15908. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15909. /**
  15910. * Particle emitter emitting particles from the inside of a box.
  15911. * It emits the particles randomly between 2 given directions.
  15912. */
  15913. export class BoxParticleEmitter implements IParticleEmitterType {
  15914. /**
  15915. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15916. */
  15917. direction1: Vector3;
  15918. /**
  15919. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15920. */
  15921. direction2: Vector3;
  15922. /**
  15923. * 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.
  15924. */
  15925. minEmitBox: Vector3;
  15926. /**
  15927. * 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.
  15928. */
  15929. maxEmitBox: Vector3;
  15930. /**
  15931. * Creates a new instance BoxParticleEmitter
  15932. */
  15933. constructor();
  15934. /**
  15935. * Called by the particle System when the direction is computed for the created particle.
  15936. * @param worldMatrix is the world matrix of the particle system
  15937. * @param directionToUpdate is the direction vector to update with the result
  15938. * @param particle is the particle we are computed the direction for
  15939. */
  15940. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15941. /**
  15942. * Called by the particle System when the position is computed for the created particle.
  15943. * @param worldMatrix is the world matrix of the particle system
  15944. * @param positionToUpdate is the position vector to update with the result
  15945. * @param particle is the particle we are computed the position for
  15946. */
  15947. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15948. /**
  15949. * Clones the current emitter and returns a copy of it
  15950. * @returns the new emitter
  15951. */
  15952. clone(): BoxParticleEmitter;
  15953. /**
  15954. * Called by the GPUParticleSystem to setup the update shader
  15955. * @param effect defines the update shader
  15956. */
  15957. applyToShader(effect: Effect): void;
  15958. /**
  15959. * Returns a string to use to update the GPU particles update shader
  15960. * @returns a string containng the defines string
  15961. */
  15962. getEffectDefines(): string;
  15963. /**
  15964. * Returns the string "BoxParticleEmitter"
  15965. * @returns a string containing the class name
  15966. */
  15967. getClassName(): string;
  15968. /**
  15969. * Serializes the particle system to a JSON object.
  15970. * @returns the JSON object
  15971. */
  15972. serialize(): any;
  15973. /**
  15974. * Parse properties from a JSON object
  15975. * @param serializationObject defines the JSON object
  15976. */
  15977. parse(serializationObject: any): void;
  15978. }
  15979. }
  15980. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15981. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15982. import { Effect } from "babylonjs/Materials/effect";
  15983. import { Particle } from "babylonjs/Particles/particle";
  15984. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15985. /**
  15986. * Particle emitter emitting particles from the inside of a cone.
  15987. * It emits the particles alongside the cone volume from the base to the particle.
  15988. * The emission direction might be randomized.
  15989. */
  15990. export class ConeParticleEmitter implements IParticleEmitterType {
  15991. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15992. directionRandomizer: number;
  15993. private _radius;
  15994. private _angle;
  15995. private _height;
  15996. /**
  15997. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15998. */
  15999. radiusRange: number;
  16000. /**
  16001. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16002. */
  16003. heightRange: number;
  16004. /**
  16005. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16006. */
  16007. emitFromSpawnPointOnly: boolean;
  16008. /**
  16009. * Gets or sets the radius of the emission cone
  16010. */
  16011. radius: number;
  16012. /**
  16013. * Gets or sets the angle of the emission cone
  16014. */
  16015. angle: number;
  16016. private _buildHeight;
  16017. /**
  16018. * Creates a new instance ConeParticleEmitter
  16019. * @param radius the radius of the emission cone (1 by default)
  16020. * @param angle the cone base angle (PI by default)
  16021. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16022. */
  16023. constructor(radius?: number, angle?: number,
  16024. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16025. directionRandomizer?: number);
  16026. /**
  16027. * Called by the particle System when the direction is computed for the created particle.
  16028. * @param worldMatrix is the world matrix of the particle system
  16029. * @param directionToUpdate is the direction vector to update with the result
  16030. * @param particle is the particle we are computed the direction for
  16031. */
  16032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16033. /**
  16034. * Called by the particle System when the position is computed for the created particle.
  16035. * @param worldMatrix is the world matrix of the particle system
  16036. * @param positionToUpdate is the position vector to update with the result
  16037. * @param particle is the particle we are computed the position for
  16038. */
  16039. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16040. /**
  16041. * Clones the current emitter and returns a copy of it
  16042. * @returns the new emitter
  16043. */
  16044. clone(): ConeParticleEmitter;
  16045. /**
  16046. * Called by the GPUParticleSystem to setup the update shader
  16047. * @param effect defines the update shader
  16048. */
  16049. applyToShader(effect: Effect): void;
  16050. /**
  16051. * Returns a string to use to update the GPU particles update shader
  16052. * @returns a string containng the defines string
  16053. */
  16054. getEffectDefines(): string;
  16055. /**
  16056. * Returns the string "ConeParticleEmitter"
  16057. * @returns a string containing the class name
  16058. */
  16059. getClassName(): string;
  16060. /**
  16061. * Serializes the particle system to a JSON object.
  16062. * @returns the JSON object
  16063. */
  16064. serialize(): any;
  16065. /**
  16066. * Parse properties from a JSON object
  16067. * @param serializationObject defines the JSON object
  16068. */
  16069. parse(serializationObject: any): void;
  16070. }
  16071. }
  16072. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16073. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16074. import { Effect } from "babylonjs/Materials/effect";
  16075. import { Particle } from "babylonjs/Particles/particle";
  16076. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16077. /**
  16078. * Particle emitter emitting particles from the inside of a cylinder.
  16079. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16080. */
  16081. export class CylinderParticleEmitter implements IParticleEmitterType {
  16082. /**
  16083. * The radius of the emission cylinder.
  16084. */
  16085. radius: number;
  16086. /**
  16087. * The height of the emission cylinder.
  16088. */
  16089. height: number;
  16090. /**
  16091. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16092. */
  16093. radiusRange: number;
  16094. /**
  16095. * How much to randomize the particle direction [0-1].
  16096. */
  16097. directionRandomizer: number;
  16098. /**
  16099. * Creates a new instance CylinderParticleEmitter
  16100. * @param radius the radius of the emission cylinder (1 by default)
  16101. * @param height the height of the emission cylinder (1 by default)
  16102. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16103. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16104. */
  16105. constructor(
  16106. /**
  16107. * The radius of the emission cylinder.
  16108. */
  16109. radius?: number,
  16110. /**
  16111. * The height of the emission cylinder.
  16112. */
  16113. height?: number,
  16114. /**
  16115. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16116. */
  16117. radiusRange?: number,
  16118. /**
  16119. * How much to randomize the particle direction [0-1].
  16120. */
  16121. directionRandomizer?: number);
  16122. /**
  16123. * Called by the particle System when the direction is computed for the created particle.
  16124. * @param worldMatrix is the world matrix of the particle system
  16125. * @param directionToUpdate is the direction vector to update with the result
  16126. * @param particle is the particle we are computed the direction for
  16127. */
  16128. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16129. /**
  16130. * Called by the particle System when the position is computed for the created particle.
  16131. * @param worldMatrix is the world matrix of the particle system
  16132. * @param positionToUpdate is the position vector to update with the result
  16133. * @param particle is the particle we are computed the position for
  16134. */
  16135. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16136. /**
  16137. * Clones the current emitter and returns a copy of it
  16138. * @returns the new emitter
  16139. */
  16140. clone(): CylinderParticleEmitter;
  16141. /**
  16142. * Called by the GPUParticleSystem to setup the update shader
  16143. * @param effect defines the update shader
  16144. */
  16145. applyToShader(effect: Effect): void;
  16146. /**
  16147. * Returns a string to use to update the GPU particles update shader
  16148. * @returns a string containng the defines string
  16149. */
  16150. getEffectDefines(): string;
  16151. /**
  16152. * Returns the string "CylinderParticleEmitter"
  16153. * @returns a string containing the class name
  16154. */
  16155. getClassName(): string;
  16156. /**
  16157. * Serializes the particle system to a JSON object.
  16158. * @returns the JSON object
  16159. */
  16160. serialize(): any;
  16161. /**
  16162. * Parse properties from a JSON object
  16163. * @param serializationObject defines the JSON object
  16164. */
  16165. parse(serializationObject: any): void;
  16166. }
  16167. /**
  16168. * Particle emitter emitting particles from the inside of a cylinder.
  16169. * It emits the particles randomly between two vectors.
  16170. */
  16171. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16172. /**
  16173. * The min limit of the emission direction.
  16174. */
  16175. direction1: Vector3;
  16176. /**
  16177. * The max limit of the emission direction.
  16178. */
  16179. direction2: Vector3;
  16180. /**
  16181. * Creates a new instance CylinderDirectedParticleEmitter
  16182. * @param radius the radius of the emission cylinder (1 by default)
  16183. * @param height the height of the emission cylinder (1 by default)
  16184. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16185. * @param direction1 the min limit of the emission direction (up vector by default)
  16186. * @param direction2 the max limit of the emission direction (up vector by default)
  16187. */
  16188. constructor(radius?: number, height?: number, radiusRange?: number,
  16189. /**
  16190. * The min limit of the emission direction.
  16191. */
  16192. direction1?: Vector3,
  16193. /**
  16194. * The max limit of the emission direction.
  16195. */
  16196. direction2?: Vector3);
  16197. /**
  16198. * Called by the particle System when the direction is computed for the created particle.
  16199. * @param worldMatrix is the world matrix of the particle system
  16200. * @param directionToUpdate is the direction vector to update with the result
  16201. * @param particle is the particle we are computed the direction for
  16202. */
  16203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16204. /**
  16205. * Clones the current emitter and returns a copy of it
  16206. * @returns the new emitter
  16207. */
  16208. clone(): CylinderDirectedParticleEmitter;
  16209. /**
  16210. * Called by the GPUParticleSystem to setup the update shader
  16211. * @param effect defines the update shader
  16212. */
  16213. applyToShader(effect: Effect): void;
  16214. /**
  16215. * Returns a string to use to update the GPU particles update shader
  16216. * @returns a string containng the defines string
  16217. */
  16218. getEffectDefines(): string;
  16219. /**
  16220. * Returns the string "CylinderDirectedParticleEmitter"
  16221. * @returns a string containing the class name
  16222. */
  16223. getClassName(): string;
  16224. /**
  16225. * Serializes the particle system to a JSON object.
  16226. * @returns the JSON object
  16227. */
  16228. serialize(): any;
  16229. /**
  16230. * Parse properties from a JSON object
  16231. * @param serializationObject defines the JSON object
  16232. */
  16233. parse(serializationObject: any): void;
  16234. }
  16235. }
  16236. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16237. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16238. import { Effect } from "babylonjs/Materials/effect";
  16239. import { Particle } from "babylonjs/Particles/particle";
  16240. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16241. /**
  16242. * Particle emitter emitting particles from the inside of a hemisphere.
  16243. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16244. */
  16245. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16246. /**
  16247. * The radius of the emission hemisphere.
  16248. */
  16249. radius: number;
  16250. /**
  16251. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16252. */
  16253. radiusRange: number;
  16254. /**
  16255. * How much to randomize the particle direction [0-1].
  16256. */
  16257. directionRandomizer: number;
  16258. /**
  16259. * Creates a new instance HemisphericParticleEmitter
  16260. * @param radius the radius of the emission hemisphere (1 by default)
  16261. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16262. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16263. */
  16264. constructor(
  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. * Called by the particle System when the direction is computed for the created particle.
  16279. * @param worldMatrix is the world matrix of the particle system
  16280. * @param directionToUpdate is the direction vector to update with the result
  16281. * @param particle is the particle we are computed the direction for
  16282. */
  16283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16284. /**
  16285. * Called by the particle System when the position is computed for the created particle.
  16286. * @param worldMatrix is the world matrix of the particle system
  16287. * @param positionToUpdate is the position vector to update with the result
  16288. * @param particle is the particle we are computed the position for
  16289. */
  16290. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16291. /**
  16292. * Clones the current emitter and returns a copy of it
  16293. * @returns the new emitter
  16294. */
  16295. clone(): HemisphericParticleEmitter;
  16296. /**
  16297. * Called by the GPUParticleSystem to setup the update shader
  16298. * @param effect defines the update shader
  16299. */
  16300. applyToShader(effect: Effect): void;
  16301. /**
  16302. * Returns a string to use to update the GPU particles update shader
  16303. * @returns a string containng the defines string
  16304. */
  16305. getEffectDefines(): string;
  16306. /**
  16307. * Returns the string "HemisphericParticleEmitter"
  16308. * @returns a string containing the class name
  16309. */
  16310. getClassName(): string;
  16311. /**
  16312. * Serializes the particle system to a JSON object.
  16313. * @returns the JSON object
  16314. */
  16315. serialize(): any;
  16316. /**
  16317. * Parse properties from a JSON object
  16318. * @param serializationObject defines the JSON object
  16319. */
  16320. parse(serializationObject: any): void;
  16321. }
  16322. }
  16323. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16324. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16325. import { Effect } from "babylonjs/Materials/effect";
  16326. import { Particle } from "babylonjs/Particles/particle";
  16327. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16328. /**
  16329. * Particle emitter emitting particles from a point.
  16330. * It emits the particles randomly between 2 given directions.
  16331. */
  16332. export class PointParticleEmitter implements IParticleEmitterType {
  16333. /**
  16334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16335. */
  16336. direction1: Vector3;
  16337. /**
  16338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16339. */
  16340. direction2: Vector3;
  16341. /**
  16342. * Creates a new instance PointParticleEmitter
  16343. */
  16344. constructor();
  16345. /**
  16346. * Called by the particle System when the direction is computed for the created particle.
  16347. * @param worldMatrix is the world matrix of the particle system
  16348. * @param directionToUpdate is the direction vector to update with the result
  16349. * @param particle is the particle we are computed the direction for
  16350. */
  16351. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16352. /**
  16353. * Called by the particle System when the position is computed for the created particle.
  16354. * @param worldMatrix is the world matrix of the particle system
  16355. * @param positionToUpdate is the position vector to update with the result
  16356. * @param particle is the particle we are computed the position for
  16357. */
  16358. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16359. /**
  16360. * Clones the current emitter and returns a copy of it
  16361. * @returns the new emitter
  16362. */
  16363. clone(): PointParticleEmitter;
  16364. /**
  16365. * Called by the GPUParticleSystem to setup the update shader
  16366. * @param effect defines the update shader
  16367. */
  16368. applyToShader(effect: Effect): void;
  16369. /**
  16370. * Returns a string to use to update the GPU particles update shader
  16371. * @returns a string containng the defines string
  16372. */
  16373. getEffectDefines(): string;
  16374. /**
  16375. * Returns the string "PointParticleEmitter"
  16376. * @returns a string containing the class name
  16377. */
  16378. getClassName(): string;
  16379. /**
  16380. * Serializes the particle system to a JSON object.
  16381. * @returns the JSON object
  16382. */
  16383. serialize(): any;
  16384. /**
  16385. * Parse properties from a JSON object
  16386. * @param serializationObject defines the JSON object
  16387. */
  16388. parse(serializationObject: any): void;
  16389. }
  16390. }
  16391. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16392. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16393. import { Effect } from "babylonjs/Materials/effect";
  16394. import { Particle } from "babylonjs/Particles/particle";
  16395. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16396. /**
  16397. * Particle emitter emitting particles from the inside of a sphere.
  16398. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16399. */
  16400. export class SphereParticleEmitter implements IParticleEmitterType {
  16401. /**
  16402. * The radius of the emission sphere.
  16403. */
  16404. radius: number;
  16405. /**
  16406. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16407. */
  16408. radiusRange: number;
  16409. /**
  16410. * How much to randomize the particle direction [0-1].
  16411. */
  16412. directionRandomizer: number;
  16413. /**
  16414. * Creates a new instance SphereParticleEmitter
  16415. * @param radius the radius of the emission sphere (1 by default)
  16416. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16417. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16418. */
  16419. constructor(
  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. * Called by the particle System when the direction is computed for the created particle.
  16434. * @param worldMatrix is the world matrix of the particle system
  16435. * @param directionToUpdate is the direction vector to update with the result
  16436. * @param particle is the particle we are computed the direction for
  16437. */
  16438. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16439. /**
  16440. * Called by the particle System when the position is computed for the created particle.
  16441. * @param worldMatrix is the world matrix of the particle system
  16442. * @param positionToUpdate is the position vector to update with the result
  16443. * @param particle is the particle we are computed the position for
  16444. */
  16445. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16446. /**
  16447. * Clones the current emitter and returns a copy of it
  16448. * @returns the new emitter
  16449. */
  16450. clone(): SphereParticleEmitter;
  16451. /**
  16452. * Called by the GPUParticleSystem to setup the update shader
  16453. * @param effect defines the update shader
  16454. */
  16455. applyToShader(effect: Effect): void;
  16456. /**
  16457. * Returns a string to use to update the GPU particles update shader
  16458. * @returns a string containng the defines string
  16459. */
  16460. getEffectDefines(): string;
  16461. /**
  16462. * Returns the string "SphereParticleEmitter"
  16463. * @returns a string containing the class name
  16464. */
  16465. getClassName(): string;
  16466. /**
  16467. * Serializes the particle system to a JSON object.
  16468. * @returns the JSON object
  16469. */
  16470. serialize(): any;
  16471. /**
  16472. * Parse properties from a JSON object
  16473. * @param serializationObject defines the JSON object
  16474. */
  16475. parse(serializationObject: any): void;
  16476. }
  16477. /**
  16478. * Particle emitter emitting particles from the inside of a sphere.
  16479. * It emits the particles randomly between two vectors.
  16480. */
  16481. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16482. /**
  16483. * The min limit of the emission direction.
  16484. */
  16485. direction1: Vector3;
  16486. /**
  16487. * The max limit of the emission direction.
  16488. */
  16489. direction2: Vector3;
  16490. /**
  16491. * Creates a new instance SphereDirectedParticleEmitter
  16492. * @param radius the radius of the emission sphere (1 by default)
  16493. * @param direction1 the min limit of the emission direction (up vector by default)
  16494. * @param direction2 the max limit of the emission direction (up vector by default)
  16495. */
  16496. constructor(radius?: number,
  16497. /**
  16498. * The min limit of the emission direction.
  16499. */
  16500. direction1?: Vector3,
  16501. /**
  16502. * The max limit of the emission direction.
  16503. */
  16504. direction2?: Vector3);
  16505. /**
  16506. * Called by the particle System when the direction is computed for the created particle.
  16507. * @param worldMatrix is the world matrix of the particle system
  16508. * @param directionToUpdate is the direction vector to update with the result
  16509. * @param particle is the particle we are computed the direction for
  16510. */
  16511. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16512. /**
  16513. * Clones the current emitter and returns a copy of it
  16514. * @returns the new emitter
  16515. */
  16516. clone(): SphereDirectedParticleEmitter;
  16517. /**
  16518. * Called by the GPUParticleSystem to setup the update shader
  16519. * @param effect defines the update shader
  16520. */
  16521. applyToShader(effect: Effect): void;
  16522. /**
  16523. * Returns a string to use to update the GPU particles update shader
  16524. * @returns a string containng the defines string
  16525. */
  16526. getEffectDefines(): string;
  16527. /**
  16528. * Returns the string "SphereDirectedParticleEmitter"
  16529. * @returns a string containing the class name
  16530. */
  16531. getClassName(): string;
  16532. /**
  16533. * Serializes the particle system to a JSON object.
  16534. * @returns the JSON object
  16535. */
  16536. serialize(): any;
  16537. /**
  16538. * Parse properties from a JSON object
  16539. * @param serializationObject defines the JSON object
  16540. */
  16541. parse(serializationObject: any): void;
  16542. }
  16543. }
  16544. declare module "babylonjs/Particles/EmitterTypes/index" {
  16545. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16546. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16547. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16548. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16549. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16550. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16551. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16552. }
  16553. declare module "babylonjs/Particles/IParticleSystem" {
  16554. import { Nullable } from "babylonjs/types";
  16555. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16557. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16558. import { Texture } from "babylonjs/Materials/Textures/texture";
  16559. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16560. import { Scene } from "babylonjs/scene";
  16561. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16562. import { Animation } from "babylonjs/Animations/animation";
  16563. /**
  16564. * Interface representing a particle system in Babylon.js.
  16565. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16566. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16567. */
  16568. export interface IParticleSystem {
  16569. /**
  16570. * List of animations used by the particle system.
  16571. */
  16572. animations: Animation[];
  16573. /**
  16574. * The id of the Particle system.
  16575. */
  16576. id: string;
  16577. /**
  16578. * The name of the Particle system.
  16579. */
  16580. name: string;
  16581. /**
  16582. * The emitter represents the Mesh or position we are attaching the particle system to.
  16583. */
  16584. emitter: Nullable<AbstractMesh | Vector3>;
  16585. /**
  16586. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16587. */
  16588. isBillboardBased: boolean;
  16589. /**
  16590. * The rendering group used by the Particle system to chose when to render.
  16591. */
  16592. renderingGroupId: number;
  16593. /**
  16594. * The layer mask we are rendering the particles through.
  16595. */
  16596. layerMask: number;
  16597. /**
  16598. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16599. */
  16600. updateSpeed: number;
  16601. /**
  16602. * The amount of time the particle system is running (depends of the overall update speed).
  16603. */
  16604. targetStopDuration: number;
  16605. /**
  16606. * The texture used to render each particle. (this can be a spritesheet)
  16607. */
  16608. particleTexture: Nullable<Texture>;
  16609. /**
  16610. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16611. */
  16612. blendMode: number;
  16613. /**
  16614. * Minimum life time of emitting particles.
  16615. */
  16616. minLifeTime: number;
  16617. /**
  16618. * Maximum life time of emitting particles.
  16619. */
  16620. maxLifeTime: number;
  16621. /**
  16622. * Minimum Size of emitting particles.
  16623. */
  16624. minSize: number;
  16625. /**
  16626. * Maximum Size of emitting particles.
  16627. */
  16628. maxSize: number;
  16629. /**
  16630. * Minimum scale of emitting particles on X axis.
  16631. */
  16632. minScaleX: number;
  16633. /**
  16634. * Maximum scale of emitting particles on X axis.
  16635. */
  16636. maxScaleX: number;
  16637. /**
  16638. * Minimum scale of emitting particles on Y axis.
  16639. */
  16640. minScaleY: number;
  16641. /**
  16642. * Maximum scale of emitting particles on Y axis.
  16643. */
  16644. maxScaleY: number;
  16645. /**
  16646. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16647. */
  16648. color1: Color4;
  16649. /**
  16650. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16651. */
  16652. color2: Color4;
  16653. /**
  16654. * Color the particle will have at the end of its lifetime.
  16655. */
  16656. colorDead: Color4;
  16657. /**
  16658. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16659. */
  16660. emitRate: number;
  16661. /**
  16662. * You can use gravity if you want to give an orientation to your particles.
  16663. */
  16664. gravity: Vector3;
  16665. /**
  16666. * Minimum power of emitting particles.
  16667. */
  16668. minEmitPower: number;
  16669. /**
  16670. * Maximum power of emitting particles.
  16671. */
  16672. maxEmitPower: number;
  16673. /**
  16674. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16675. */
  16676. minAngularSpeed: number;
  16677. /**
  16678. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16679. */
  16680. maxAngularSpeed: number;
  16681. /**
  16682. * Gets or sets the minimal initial rotation in radians.
  16683. */
  16684. minInitialRotation: number;
  16685. /**
  16686. * Gets or sets the maximal initial rotation in radians.
  16687. */
  16688. maxInitialRotation: number;
  16689. /**
  16690. * The particle emitter type defines the emitter used by the particle system.
  16691. * It can be for example box, sphere, or cone...
  16692. */
  16693. particleEmitterType: Nullable<IParticleEmitterType>;
  16694. /**
  16695. * Defines the delay in milliseconds before starting the system (0 by default)
  16696. */
  16697. startDelay: number;
  16698. /**
  16699. * 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
  16700. */
  16701. preWarmCycles: number;
  16702. /**
  16703. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16704. */
  16705. preWarmStepOffset: number;
  16706. /**
  16707. * 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)
  16708. */
  16709. spriteCellChangeSpeed: number;
  16710. /**
  16711. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16712. */
  16713. startSpriteCellID: number;
  16714. /**
  16715. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16716. */
  16717. endSpriteCellID: number;
  16718. /**
  16719. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16720. */
  16721. spriteCellWidth: number;
  16722. /**
  16723. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16724. */
  16725. spriteCellHeight: number;
  16726. /**
  16727. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16728. */
  16729. spriteRandomStartCell: boolean;
  16730. /**
  16731. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16732. */
  16733. isAnimationSheetEnabled: boolean;
  16734. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16735. translationPivot: Vector2;
  16736. /**
  16737. * Gets or sets a texture used to add random noise to particle positions
  16738. */
  16739. noiseTexture: Nullable<BaseTexture>;
  16740. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16741. noiseStrength: Vector3;
  16742. /**
  16743. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16744. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16745. */
  16746. billboardMode: number;
  16747. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16748. limitVelocityDamping: number;
  16749. /**
  16750. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16751. */
  16752. beginAnimationOnStart: boolean;
  16753. /**
  16754. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16755. */
  16756. beginAnimationFrom: number;
  16757. /**
  16758. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16759. */
  16760. beginAnimationTo: number;
  16761. /**
  16762. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16763. */
  16764. beginAnimationLoop: boolean;
  16765. /**
  16766. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16767. */
  16768. disposeOnStop: boolean;
  16769. /**
  16770. * Gets the maximum number of particles active at the same time.
  16771. * @returns The max number of active particles.
  16772. */
  16773. getCapacity(): number;
  16774. /**
  16775. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16776. * @returns True if it has been started, otherwise false.
  16777. */
  16778. isStarted(): boolean;
  16779. /**
  16780. * Animates the particle system for this frame.
  16781. */
  16782. animate(): void;
  16783. /**
  16784. * Renders the particle system in its current state.
  16785. * @returns the current number of particles
  16786. */
  16787. render(): number;
  16788. /**
  16789. * Dispose the particle system and frees its associated resources.
  16790. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16791. */
  16792. dispose(disposeTexture?: boolean): void;
  16793. /**
  16794. * Clones the particle system.
  16795. * @param name The name of the cloned object
  16796. * @param newEmitter The new emitter to use
  16797. * @returns the cloned particle system
  16798. */
  16799. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16800. /**
  16801. * Serializes the particle system to a JSON object.
  16802. * @returns the JSON object
  16803. */
  16804. serialize(): any;
  16805. /**
  16806. * Rebuild the particle system
  16807. */
  16808. rebuild(): void;
  16809. /**
  16810. * Starts the particle system and begins to emit
  16811. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16812. */
  16813. start(delay?: number): void;
  16814. /**
  16815. * Stops the particle system.
  16816. */
  16817. stop(): void;
  16818. /**
  16819. * Remove all active particles
  16820. */
  16821. reset(): void;
  16822. /**
  16823. * Is this system ready to be used/rendered
  16824. * @return true if the system is ready
  16825. */
  16826. isReady(): boolean;
  16827. /**
  16828. * Adds a new color gradient
  16829. * @param gradient defines the gradient to use (between 0 and 1)
  16830. * @param color1 defines the color to affect to the specified gradient
  16831. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16832. * @returns the current particle system
  16833. */
  16834. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16835. /**
  16836. * Remove a specific color gradient
  16837. * @param gradient defines the gradient to remove
  16838. * @returns the current particle system
  16839. */
  16840. removeColorGradient(gradient: number): IParticleSystem;
  16841. /**
  16842. * Adds a new size gradient
  16843. * @param gradient defines the gradient to use (between 0 and 1)
  16844. * @param factor defines the size factor to affect to the specified gradient
  16845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16846. * @returns the current particle system
  16847. */
  16848. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16849. /**
  16850. * Remove a specific size gradient
  16851. * @param gradient defines the gradient to remove
  16852. * @returns the current particle system
  16853. */
  16854. removeSizeGradient(gradient: number): IParticleSystem;
  16855. /**
  16856. * Gets the current list of color gradients.
  16857. * You must use addColorGradient and removeColorGradient to udpate this list
  16858. * @returns the list of color gradients
  16859. */
  16860. getColorGradients(): Nullable<Array<ColorGradient>>;
  16861. /**
  16862. * Gets the current list of size gradients.
  16863. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16864. * @returns the list of size gradients
  16865. */
  16866. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16867. /**
  16868. * Gets the current list of angular speed gradients.
  16869. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16870. * @returns the list of angular speed gradients
  16871. */
  16872. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16873. /**
  16874. * Adds a new angular speed gradient
  16875. * @param gradient defines the gradient to use (between 0 and 1)
  16876. * @param factor defines the angular speed to affect to the specified gradient
  16877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16878. * @returns the current particle system
  16879. */
  16880. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16881. /**
  16882. * Remove a specific angular speed gradient
  16883. * @param gradient defines the gradient to remove
  16884. * @returns the current particle system
  16885. */
  16886. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16887. /**
  16888. * Gets the current list of velocity gradients.
  16889. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16890. * @returns the list of velocity gradients
  16891. */
  16892. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16893. /**
  16894. * Adds a new velocity gradient
  16895. * @param gradient defines the gradient to use (between 0 and 1)
  16896. * @param factor defines the velocity to affect to the specified gradient
  16897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16898. * @returns the current particle system
  16899. */
  16900. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16901. /**
  16902. * Remove a specific velocity gradient
  16903. * @param gradient defines the gradient to remove
  16904. * @returns the current particle system
  16905. */
  16906. removeVelocityGradient(gradient: number): IParticleSystem;
  16907. /**
  16908. * Gets the current list of limit velocity gradients.
  16909. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16910. * @returns the list of limit velocity gradients
  16911. */
  16912. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16913. /**
  16914. * Adds a new limit velocity gradient
  16915. * @param gradient defines the gradient to use (between 0 and 1)
  16916. * @param factor defines the limit velocity to affect to the specified gradient
  16917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16918. * @returns the current particle system
  16919. */
  16920. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16921. /**
  16922. * Remove a specific limit velocity gradient
  16923. * @param gradient defines the gradient to remove
  16924. * @returns the current particle system
  16925. */
  16926. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16927. /**
  16928. * Adds a new drag gradient
  16929. * @param gradient defines the gradient to use (between 0 and 1)
  16930. * @param factor defines the drag to affect to the specified gradient
  16931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16932. * @returns the current particle system
  16933. */
  16934. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16935. /**
  16936. * Remove a specific drag gradient
  16937. * @param gradient defines the gradient to remove
  16938. * @returns the current particle system
  16939. */
  16940. removeDragGradient(gradient: number): IParticleSystem;
  16941. /**
  16942. * Gets the current list of drag gradients.
  16943. * You must use addDragGradient and removeDragGradient to udpate this list
  16944. * @returns the list of drag gradients
  16945. */
  16946. getDragGradients(): Nullable<Array<FactorGradient>>;
  16947. /**
  16948. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16949. * @param gradient defines the gradient to use (between 0 and 1)
  16950. * @param factor defines the emit rate to affect to the specified gradient
  16951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16952. * @returns the current particle system
  16953. */
  16954. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16955. /**
  16956. * Remove a specific emit rate gradient
  16957. * @param gradient defines the gradient to remove
  16958. * @returns the current particle system
  16959. */
  16960. removeEmitRateGradient(gradient: number): IParticleSystem;
  16961. /**
  16962. * Gets the current list of emit rate gradients.
  16963. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16964. * @returns the list of emit rate gradients
  16965. */
  16966. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16967. /**
  16968. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16969. * @param gradient defines the gradient to use (between 0 and 1)
  16970. * @param factor defines the start size to affect to the specified gradient
  16971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16972. * @returns the current particle system
  16973. */
  16974. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16975. /**
  16976. * Remove a specific start size gradient
  16977. * @param gradient defines the gradient to remove
  16978. * @returns the current particle system
  16979. */
  16980. removeStartSizeGradient(gradient: number): IParticleSystem;
  16981. /**
  16982. * Gets the current list of start size gradients.
  16983. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16984. * @returns the list of start size gradients
  16985. */
  16986. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16987. /**
  16988. * Adds a new life time gradient
  16989. * @param gradient defines the gradient to use (between 0 and 1)
  16990. * @param factor defines the life time factor to affect to the specified gradient
  16991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16992. * @returns the current particle system
  16993. */
  16994. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16995. /**
  16996. * Remove a specific life time gradient
  16997. * @param gradient defines the gradient to remove
  16998. * @returns the current particle system
  16999. */
  17000. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17001. /**
  17002. * Gets the current list of life time gradients.
  17003. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17004. * @returns the list of life time gradients
  17005. */
  17006. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17007. /**
  17008. * Gets the current list of color gradients.
  17009. * You must use addColorGradient and removeColorGradient to udpate this list
  17010. * @returns the list of color gradients
  17011. */
  17012. getColorGradients(): Nullable<Array<ColorGradient>>;
  17013. /**
  17014. * Adds a new ramp gradient used to remap particle colors
  17015. * @param gradient defines the gradient to use (between 0 and 1)
  17016. * @param color defines the color to affect to the specified gradient
  17017. * @returns the current particle system
  17018. */
  17019. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17020. /**
  17021. * Gets the current list of ramp gradients.
  17022. * You must use addRampGradient and removeRampGradient to udpate this list
  17023. * @returns the list of ramp gradients
  17024. */
  17025. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17026. /** Gets or sets a boolean indicating that ramp gradients must be used
  17027. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17028. */
  17029. useRampGradients: boolean;
  17030. /**
  17031. * Adds a new color remap gradient
  17032. * @param gradient defines the gradient to use (between 0 and 1)
  17033. * @param min defines the color remap minimal range
  17034. * @param max defines the color remap maximal range
  17035. * @returns the current particle system
  17036. */
  17037. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17038. /**
  17039. * Gets the current list of color remap gradients.
  17040. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17041. * @returns the list of color remap gradients
  17042. */
  17043. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17044. /**
  17045. * Adds a new alpha remap gradient
  17046. * @param gradient defines the gradient to use (between 0 and 1)
  17047. * @param min defines the alpha remap minimal range
  17048. * @param max defines the alpha remap maximal range
  17049. * @returns the current particle system
  17050. */
  17051. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17052. /**
  17053. * Gets the current list of alpha remap gradients.
  17054. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17055. * @returns the list of alpha remap gradients
  17056. */
  17057. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17058. /**
  17059. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17060. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17061. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17062. * @returns the emitter
  17063. */
  17064. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17065. /**
  17066. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17067. * @param radius The radius of the hemisphere to emit from
  17068. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17069. * @returns the emitter
  17070. */
  17071. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17072. /**
  17073. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17074. * @param radius The radius of the sphere to emit from
  17075. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17076. * @returns the emitter
  17077. */
  17078. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17079. /**
  17080. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17081. * @param radius The radius of the sphere to emit from
  17082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17084. * @returns the emitter
  17085. */
  17086. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17087. /**
  17088. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17089. * @param radius The radius of the emission cylinder
  17090. * @param height The height of the emission cylinder
  17091. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17092. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17093. * @returns the emitter
  17094. */
  17095. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17096. /**
  17097. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17098. * @param radius The radius of the cylinder to emit from
  17099. * @param height The height of the emission cylinder
  17100. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17103. * @returns the emitter
  17104. */
  17105. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17106. /**
  17107. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17108. * @param radius The radius of the cone to emit from
  17109. * @param angle The base angle of the cone
  17110. * @returns the emitter
  17111. */
  17112. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17113. /**
  17114. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17117. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17118. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17119. * @returns the emitter
  17120. */
  17121. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17122. /**
  17123. * Get hosting scene
  17124. * @returns the scene
  17125. */
  17126. getScene(): Scene;
  17127. }
  17128. }
  17129. declare module "babylonjs/Meshes/instancedMesh" {
  17130. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17131. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17132. import { Camera } from "babylonjs/Cameras/camera";
  17133. import { Node } from "babylonjs/node";
  17134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17135. import { Mesh } from "babylonjs/Meshes/mesh";
  17136. import { Material } from "babylonjs/Materials/material";
  17137. import { Skeleton } from "babylonjs/Bones/skeleton";
  17138. import { Light } from "babylonjs/Lights/light";
  17139. /**
  17140. * Creates an instance based on a source mesh.
  17141. */
  17142. export class InstancedMesh extends AbstractMesh {
  17143. private _sourceMesh;
  17144. private _currentLOD;
  17145. /** @hidden */
  17146. _indexInSourceMeshInstanceArray: number;
  17147. constructor(name: string, source: Mesh);
  17148. /**
  17149. * Returns the string "InstancedMesh".
  17150. */
  17151. getClassName(): string;
  17152. /** Gets the list of lights affecting that mesh */
  17153. readonly lightSources: Light[];
  17154. _resyncLightSources(): void;
  17155. _resyncLighSource(light: Light): void;
  17156. _removeLightSource(light: Light): void;
  17157. /**
  17158. * If the source mesh receives shadows
  17159. */
  17160. readonly receiveShadows: boolean;
  17161. /**
  17162. * The material of the source mesh
  17163. */
  17164. readonly material: Nullable<Material>;
  17165. /**
  17166. * Visibility of the source mesh
  17167. */
  17168. readonly visibility: number;
  17169. /**
  17170. * Skeleton of the source mesh
  17171. */
  17172. readonly skeleton: Nullable<Skeleton>;
  17173. /**
  17174. * Rendering ground id of the source mesh
  17175. */
  17176. renderingGroupId: number;
  17177. /**
  17178. * Returns the total number of vertices (integer).
  17179. */
  17180. getTotalVertices(): number;
  17181. /**
  17182. * Returns a positive integer : the total number of indices in this mesh geometry.
  17183. * @returns the numner of indices or zero if the mesh has no geometry.
  17184. */
  17185. getTotalIndices(): number;
  17186. /**
  17187. * The source mesh of the instance
  17188. */
  17189. readonly sourceMesh: Mesh;
  17190. /**
  17191. * Is this node ready to be used/rendered
  17192. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17193. * @return {boolean} is it ready
  17194. */
  17195. isReady(completeCheck?: boolean): boolean;
  17196. /**
  17197. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17198. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17199. * @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.
  17200. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17201. */
  17202. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17203. /**
  17204. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17205. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17206. * The `data` are either a numeric array either a Float32Array.
  17207. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17208. * 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).
  17209. * Note that a new underlying VertexBuffer object is created each call.
  17210. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17211. *
  17212. * Possible `kind` values :
  17213. * - VertexBuffer.PositionKind
  17214. * - VertexBuffer.UVKind
  17215. * - VertexBuffer.UV2Kind
  17216. * - VertexBuffer.UV3Kind
  17217. * - VertexBuffer.UV4Kind
  17218. * - VertexBuffer.UV5Kind
  17219. * - VertexBuffer.UV6Kind
  17220. * - VertexBuffer.ColorKind
  17221. * - VertexBuffer.MatricesIndicesKind
  17222. * - VertexBuffer.MatricesIndicesExtraKind
  17223. * - VertexBuffer.MatricesWeightsKind
  17224. * - VertexBuffer.MatricesWeightsExtraKind
  17225. *
  17226. * Returns the Mesh.
  17227. */
  17228. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17229. /**
  17230. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17231. * If the mesh has no geometry, it is simply returned as it is.
  17232. * The `data` are either a numeric array either a Float32Array.
  17233. * No new underlying VertexBuffer object is created.
  17234. * 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.
  17235. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17236. *
  17237. * Possible `kind` values :
  17238. * - VertexBuffer.PositionKind
  17239. * - VertexBuffer.UVKind
  17240. * - VertexBuffer.UV2Kind
  17241. * - VertexBuffer.UV3Kind
  17242. * - VertexBuffer.UV4Kind
  17243. * - VertexBuffer.UV5Kind
  17244. * - VertexBuffer.UV6Kind
  17245. * - VertexBuffer.ColorKind
  17246. * - VertexBuffer.MatricesIndicesKind
  17247. * - VertexBuffer.MatricesIndicesExtraKind
  17248. * - VertexBuffer.MatricesWeightsKind
  17249. * - VertexBuffer.MatricesWeightsExtraKind
  17250. *
  17251. * Returns the Mesh.
  17252. */
  17253. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17254. /**
  17255. * Sets the mesh indices.
  17256. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17257. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17258. * This method creates a new index buffer each call.
  17259. * Returns the Mesh.
  17260. */
  17261. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17262. /**
  17263. * Boolean : True if the mesh owns the requested kind of data.
  17264. */
  17265. isVerticesDataPresent(kind: string): boolean;
  17266. /**
  17267. * Returns an array of indices (IndicesArray).
  17268. */
  17269. getIndices(): Nullable<IndicesArray>;
  17270. readonly _positions: Nullable<Vector3[]>;
  17271. /**
  17272. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17273. * This means the mesh underlying bounding box and sphere are recomputed.
  17274. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17275. * @returns the current mesh
  17276. */
  17277. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17278. /** @hidden */
  17279. _preActivate(): InstancedMesh;
  17280. /** @hidden */
  17281. _activate(renderId: number): boolean;
  17282. getWorldMatrix(): Matrix;
  17283. /**
  17284. * Returns the current associated LOD AbstractMesh.
  17285. */
  17286. getLOD(camera: Camera): AbstractMesh;
  17287. /** @hidden */
  17288. _syncSubMeshes(): InstancedMesh;
  17289. /** @hidden */
  17290. _generatePointsArray(): boolean;
  17291. /**
  17292. * Creates a new InstancedMesh from the current mesh.
  17293. * - name (string) : the cloned mesh name
  17294. * - newParent (optional Node) : the optional Node to parent the clone to.
  17295. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17296. *
  17297. * Returns the clone.
  17298. */
  17299. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17300. /**
  17301. * Disposes the InstancedMesh.
  17302. * Returns nothing.
  17303. */
  17304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17305. }
  17306. }
  17307. declare module "babylonjs/Materials/shaderMaterial" {
  17308. import { Scene } from "babylonjs/scene";
  17309. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17311. import { Mesh } from "babylonjs/Meshes/mesh";
  17312. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17314. import { Texture } from "babylonjs/Materials/Textures/texture";
  17315. import { Material } from "babylonjs/Materials/material";
  17316. /**
  17317. * Defines the options associated with the creation of a shader material.
  17318. */
  17319. export interface IShaderMaterialOptions {
  17320. /**
  17321. * Does the material work in alpha blend mode
  17322. */
  17323. needAlphaBlending: boolean;
  17324. /**
  17325. * Does the material work in alpha test mode
  17326. */
  17327. needAlphaTesting: boolean;
  17328. /**
  17329. * The list of attribute names used in the shader
  17330. */
  17331. attributes: string[];
  17332. /**
  17333. * The list of unifrom names used in the shader
  17334. */
  17335. uniforms: string[];
  17336. /**
  17337. * The list of UBO names used in the shader
  17338. */
  17339. uniformBuffers: string[];
  17340. /**
  17341. * The list of sampler names used in the shader
  17342. */
  17343. samplers: string[];
  17344. /**
  17345. * The list of defines used in the shader
  17346. */
  17347. defines: string[];
  17348. }
  17349. /**
  17350. * 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.
  17351. *
  17352. * This returned material effects how the mesh will look based on the code in the shaders.
  17353. *
  17354. * @see http://doc.babylonjs.com/how_to/shader_material
  17355. */
  17356. export class ShaderMaterial extends Material {
  17357. private _shaderPath;
  17358. private _options;
  17359. private _textures;
  17360. private _textureArrays;
  17361. private _floats;
  17362. private _ints;
  17363. private _floatsArrays;
  17364. private _colors3;
  17365. private _colors3Arrays;
  17366. private _colors4;
  17367. private _vectors2;
  17368. private _vectors3;
  17369. private _vectors4;
  17370. private _matrices;
  17371. private _matrices3x3;
  17372. private _matrices2x2;
  17373. private _vectors2Arrays;
  17374. private _vectors3Arrays;
  17375. private _cachedWorldViewMatrix;
  17376. private _renderId;
  17377. /**
  17378. * Instantiate a new shader material.
  17379. * 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.
  17380. * This returned material effects how the mesh will look based on the code in the shaders.
  17381. * @see http://doc.babylonjs.com/how_to/shader_material
  17382. * @param name Define the name of the material in the scene
  17383. * @param scene Define the scene the material belongs to
  17384. * @param shaderPath Defines the route to the shader code in one of three ways:
  17385. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17386. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17387. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17388. * @param options Define the options used to create the shader
  17389. */
  17390. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17391. /**
  17392. * Gets the options used to compile the shader.
  17393. * They can be modified to trigger a new compilation
  17394. */
  17395. readonly options: IShaderMaterialOptions;
  17396. /**
  17397. * Gets the current class name of the material e.g. "ShaderMaterial"
  17398. * Mainly use in serialization.
  17399. * @returns the class name
  17400. */
  17401. getClassName(): string;
  17402. /**
  17403. * Specifies if the material will require alpha blending
  17404. * @returns a boolean specifying if alpha blending is needed
  17405. */
  17406. needAlphaBlending(): boolean;
  17407. /**
  17408. * Specifies if this material should be rendered in alpha test mode
  17409. * @returns a boolean specifying if an alpha test is needed.
  17410. */
  17411. needAlphaTesting(): boolean;
  17412. private _checkUniform;
  17413. /**
  17414. * Set a texture in the shader.
  17415. * @param name Define the name of the uniform samplers as defined in the shader
  17416. * @param texture Define the texture to bind to this sampler
  17417. * @return the material itself allowing "fluent" like uniform updates
  17418. */
  17419. setTexture(name: string, texture: Texture): ShaderMaterial;
  17420. /**
  17421. * Set a texture array in the shader.
  17422. * @param name Define the name of the uniform sampler array as defined in the shader
  17423. * @param textures Define the list of textures to bind to this sampler
  17424. * @return the material itself allowing "fluent" like uniform updates
  17425. */
  17426. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17427. /**
  17428. * Set a float in the shader.
  17429. * @param name Define the name of the uniform as defined in the shader
  17430. * @param value Define the value to give to the uniform
  17431. * @return the material itself allowing "fluent" like uniform updates
  17432. */
  17433. setFloat(name: string, value: number): ShaderMaterial;
  17434. /**
  17435. * Set a int in the shader.
  17436. * @param name Define the name of the uniform as defined in the shader
  17437. * @param value Define the value to give to the uniform
  17438. * @return the material itself allowing "fluent" like uniform updates
  17439. */
  17440. setInt(name: string, value: number): ShaderMaterial;
  17441. /**
  17442. * Set an array of floats in the shader.
  17443. * @param name Define the name of the uniform as defined in the shader
  17444. * @param value Define the value to give to the uniform
  17445. * @return the material itself allowing "fluent" like uniform updates
  17446. */
  17447. setFloats(name: string, value: number[]): ShaderMaterial;
  17448. /**
  17449. * Set a vec3 in the shader from a Color3.
  17450. * @param name Define the name of the uniform as defined in the shader
  17451. * @param value Define the value to give to the uniform
  17452. * @return the material itself allowing "fluent" like uniform updates
  17453. */
  17454. setColor3(name: string, value: Color3): ShaderMaterial;
  17455. /**
  17456. * Set a vec3 array in the shader from a Color3 array.
  17457. * @param name Define the name of the uniform as defined in the shader
  17458. * @param value Define the value to give to the uniform
  17459. * @return the material itself allowing "fluent" like uniform updates
  17460. */
  17461. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17462. /**
  17463. * Set a vec4 in the shader from a Color4.
  17464. * @param name Define the name of the uniform as defined in the shader
  17465. * @param value Define the value to give to the uniform
  17466. * @return the material itself allowing "fluent" like uniform updates
  17467. */
  17468. setColor4(name: string, value: Color4): ShaderMaterial;
  17469. /**
  17470. * Set a vec2 in the shader from a Vector2.
  17471. * @param name Define the name of the uniform as defined in the shader
  17472. * @param value Define the value to give to the uniform
  17473. * @return the material itself allowing "fluent" like uniform updates
  17474. */
  17475. setVector2(name: string, value: Vector2): ShaderMaterial;
  17476. /**
  17477. * Set a vec3 in the shader from a Vector3.
  17478. * @param name Define the name of the uniform as defined in the shader
  17479. * @param value Define the value to give to the uniform
  17480. * @return the material itself allowing "fluent" like uniform updates
  17481. */
  17482. setVector3(name: string, value: Vector3): ShaderMaterial;
  17483. /**
  17484. * Set a vec4 in the shader from a Vector4.
  17485. * @param name Define the name of the uniform as defined in the shader
  17486. * @param value Define the value to give to the uniform
  17487. * @return the material itself allowing "fluent" like uniform updates
  17488. */
  17489. setVector4(name: string, value: Vector4): ShaderMaterial;
  17490. /**
  17491. * Set a mat4 in the shader from a Matrix.
  17492. * @param name Define the name of the uniform as defined in the shader
  17493. * @param value Define the value to give to the uniform
  17494. * @return the material itself allowing "fluent" like uniform updates
  17495. */
  17496. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17497. /**
  17498. * Set a mat3 in the shader from a Float32Array.
  17499. * @param name Define the name of the uniform as defined in the shader
  17500. * @param value Define the value to give to the uniform
  17501. * @return the material itself allowing "fluent" like uniform updates
  17502. */
  17503. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17504. /**
  17505. * Set a mat2 in the shader from a Float32Array.
  17506. * @param name Define the name of the uniform as defined in the shader
  17507. * @param value Define the value to give to the uniform
  17508. * @return the material itself allowing "fluent" like uniform updates
  17509. */
  17510. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17511. /**
  17512. * Set a vec2 array in the shader from a number array.
  17513. * @param name Define the name of the uniform as defined in the shader
  17514. * @param value Define the value to give to the uniform
  17515. * @return the material itself allowing "fluent" like uniform updates
  17516. */
  17517. setArray2(name: string, value: number[]): ShaderMaterial;
  17518. /**
  17519. * Set a vec3 array in the shader from a number array.
  17520. * @param name Define the name of the uniform as defined in the shader
  17521. * @param value Define the value to give to the uniform
  17522. * @return the material itself allowing "fluent" like uniform updates
  17523. */
  17524. setArray3(name: string, value: number[]): ShaderMaterial;
  17525. private _checkCache;
  17526. /**
  17527. * Specifies that the submesh is ready to be used
  17528. * @param mesh defines the mesh to check
  17529. * @param subMesh defines which submesh to check
  17530. * @param useInstances specifies that instances should be used
  17531. * @returns a boolean indicating that the submesh is ready or not
  17532. */
  17533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17534. /**
  17535. * Checks if the material is ready to render the requested mesh
  17536. * @param mesh Define the mesh to render
  17537. * @param useInstances Define whether or not the material is used with instances
  17538. * @returns true if ready, otherwise false
  17539. */
  17540. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17541. /**
  17542. * Binds the world matrix to the material
  17543. * @param world defines the world transformation matrix
  17544. */
  17545. bindOnlyWorldMatrix(world: Matrix): void;
  17546. /**
  17547. * Binds the material to the mesh
  17548. * @param world defines the world transformation matrix
  17549. * @param mesh defines the mesh to bind the material to
  17550. */
  17551. bind(world: Matrix, mesh?: Mesh): void;
  17552. /**
  17553. * Gets the active textures from the material
  17554. * @returns an array of textures
  17555. */
  17556. getActiveTextures(): BaseTexture[];
  17557. /**
  17558. * Specifies if the material uses a texture
  17559. * @param texture defines the texture to check against the material
  17560. * @returns a boolean specifying if the material uses the texture
  17561. */
  17562. hasTexture(texture: BaseTexture): boolean;
  17563. /**
  17564. * Makes a duplicate of the material, and gives it a new name
  17565. * @param name defines the new name for the duplicated material
  17566. * @returns the cloned material
  17567. */
  17568. clone(name: string): ShaderMaterial;
  17569. /**
  17570. * Disposes the material
  17571. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17572. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17573. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17574. */
  17575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17576. /**
  17577. * Serializes this material in a JSON representation
  17578. * @returns the serialized material object
  17579. */
  17580. serialize(): any;
  17581. /**
  17582. * Creates a shader material from parsed shader material data
  17583. * @param source defines the JSON represnetation of the material
  17584. * @param scene defines the hosting scene
  17585. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17586. * @returns a new material
  17587. */
  17588. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17589. }
  17590. }
  17591. declare module "babylonjs/Shaders/color.fragment" {
  17592. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17593. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17594. /** @hidden */
  17595. export var colorPixelShader: {
  17596. name: string;
  17597. shader: string;
  17598. };
  17599. }
  17600. declare module "babylonjs/Shaders/color.vertex" {
  17601. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17602. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17603. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17604. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17605. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17606. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17607. /** @hidden */
  17608. export var colorVertexShader: {
  17609. name: string;
  17610. shader: string;
  17611. };
  17612. }
  17613. declare module "babylonjs/Meshes/linesMesh" {
  17614. import { Nullable } from "babylonjs/types";
  17615. import { Scene } from "babylonjs/scene";
  17616. import { Color3 } from "babylonjs/Maths/math";
  17617. import { Node } from "babylonjs/node";
  17618. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17619. import { Mesh } from "babylonjs/Meshes/mesh";
  17620. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17621. import { Effect } from "babylonjs/Materials/effect";
  17622. import { Material } from "babylonjs/Materials/material";
  17623. import "babylonjs/Shaders/color.fragment";
  17624. import "babylonjs/Shaders/color.vertex";
  17625. /**
  17626. * Line mesh
  17627. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17628. */
  17629. export class LinesMesh extends Mesh {
  17630. /**
  17631. * If vertex color should be applied to the mesh
  17632. */
  17633. useVertexColor?: boolean | undefined;
  17634. /**
  17635. * If vertex alpha should be applied to the mesh
  17636. */
  17637. useVertexAlpha?: boolean | undefined;
  17638. /**
  17639. * Color of the line (Default: White)
  17640. */
  17641. color: Color3;
  17642. /**
  17643. * Alpha of the line (Default: 1)
  17644. */
  17645. alpha: number;
  17646. /**
  17647. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17648. * This margin is expressed in world space coordinates, so its value may vary.
  17649. * Default value is 0.1
  17650. */
  17651. intersectionThreshold: number;
  17652. private _colorShader;
  17653. /**
  17654. * Creates a new LinesMesh
  17655. * @param name defines the name
  17656. * @param scene defines the hosting scene
  17657. * @param parent defines the parent mesh if any
  17658. * @param source defines the optional source LinesMesh used to clone data from
  17659. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17660. * When false, achieved by calling a clone(), also passing False.
  17661. * This will make creation of children, recursive.
  17662. * @param useVertexColor defines if this LinesMesh supports vertex color
  17663. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17664. */
  17665. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17666. /**
  17667. * If vertex color should be applied to the mesh
  17668. */
  17669. useVertexColor?: boolean | undefined,
  17670. /**
  17671. * If vertex alpha should be applied to the mesh
  17672. */
  17673. useVertexAlpha?: boolean | undefined);
  17674. private _addClipPlaneDefine;
  17675. private _removeClipPlaneDefine;
  17676. isReady(): boolean;
  17677. /**
  17678. * Returns the string "LineMesh"
  17679. */
  17680. getClassName(): string;
  17681. /**
  17682. * @hidden
  17683. */
  17684. /**
  17685. * @hidden
  17686. */
  17687. material: Material;
  17688. /**
  17689. * @hidden
  17690. */
  17691. readonly checkCollisions: boolean;
  17692. /** @hidden */
  17693. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17694. /** @hidden */
  17695. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17696. /**
  17697. * Disposes of the line mesh
  17698. * @param doNotRecurse If children should be disposed
  17699. */
  17700. dispose(doNotRecurse?: boolean): void;
  17701. /**
  17702. * Returns a new LineMesh object cloned from the current one.
  17703. */
  17704. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17705. /**
  17706. * Creates a new InstancedLinesMesh object from the mesh model.
  17707. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17708. * @param name defines the name of the new instance
  17709. * @returns a new InstancedLinesMesh
  17710. */
  17711. createInstance(name: string): InstancedLinesMesh;
  17712. }
  17713. /**
  17714. * Creates an instance based on a source LinesMesh
  17715. */
  17716. export class InstancedLinesMesh extends InstancedMesh {
  17717. /**
  17718. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17719. * This margin is expressed in world space coordinates, so its value may vary.
  17720. * Initilized with the intersectionThreshold value of the source LinesMesh
  17721. */
  17722. intersectionThreshold: number;
  17723. constructor(name: string, source: LinesMesh);
  17724. /**
  17725. * Returns the string "InstancedLinesMesh".
  17726. */
  17727. getClassName(): string;
  17728. }
  17729. }
  17730. declare module "babylonjs/Shaders/line.fragment" {
  17731. /** @hidden */
  17732. export var linePixelShader: {
  17733. name: string;
  17734. shader: string;
  17735. };
  17736. }
  17737. declare module "babylonjs/Shaders/line.vertex" {
  17738. /** @hidden */
  17739. export var lineVertexShader: {
  17740. name: string;
  17741. shader: string;
  17742. };
  17743. }
  17744. declare module "babylonjs/Rendering/edgesRenderer" {
  17745. import { Nullable } from "babylonjs/types";
  17746. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17748. import { Vector3 } from "babylonjs/Maths/math";
  17749. import { IDisposable } from "babylonjs/scene";
  17750. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17751. import "babylonjs/Shaders/line.fragment";
  17752. import "babylonjs/Shaders/line.vertex";
  17753. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17754. module "babylonjs/Meshes/abstractMesh" {
  17755. interface AbstractMesh {
  17756. /**
  17757. * Disables the mesh edge rendering mode
  17758. * @returns the currentAbstractMesh
  17759. */
  17760. disableEdgesRendering(): AbstractMesh;
  17761. /**
  17762. * Enables the edge rendering mode on the mesh.
  17763. * This mode makes the mesh edges visible
  17764. * @param epsilon defines the maximal distance between two angles to detect a face
  17765. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17766. * @returns the currentAbstractMesh
  17767. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17768. */
  17769. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17770. /**
  17771. * Gets the edgesRenderer associated with the mesh
  17772. */
  17773. edgesRenderer: Nullable<EdgesRenderer>;
  17774. }
  17775. }
  17776. module "babylonjs/Meshes/linesMesh" {
  17777. interface LinesMesh {
  17778. /**
  17779. * Enables the edge rendering mode on the mesh.
  17780. * This mode makes the mesh edges visible
  17781. * @param epsilon defines the maximal distance between two angles to detect a face
  17782. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17783. * @returns the currentAbstractMesh
  17784. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17785. */
  17786. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17787. }
  17788. }
  17789. module "babylonjs/Meshes/linesMesh" {
  17790. interface InstancedLinesMesh {
  17791. /**
  17792. * Enables the edge rendering mode on the mesh.
  17793. * This mode makes the mesh edges visible
  17794. * @param epsilon defines the maximal distance between two angles to detect a face
  17795. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17796. * @returns the current InstancedLinesMesh
  17797. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17798. */
  17799. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17800. }
  17801. }
  17802. /**
  17803. * Defines the minimum contract an Edges renderer should follow.
  17804. */
  17805. export interface IEdgesRenderer extends IDisposable {
  17806. /**
  17807. * Gets or sets a boolean indicating if the edgesRenderer is active
  17808. */
  17809. isEnabled: boolean;
  17810. /**
  17811. * Renders the edges of the attached mesh,
  17812. */
  17813. render(): void;
  17814. /**
  17815. * Checks wether or not the edges renderer is ready to render.
  17816. * @return true if ready, otherwise false.
  17817. */
  17818. isReady(): boolean;
  17819. }
  17820. /**
  17821. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17822. */
  17823. export class EdgesRenderer implements IEdgesRenderer {
  17824. /**
  17825. * Define the size of the edges with an orthographic camera
  17826. */
  17827. edgesWidthScalerForOrthographic: number;
  17828. /**
  17829. * Define the size of the edges with a perspective camera
  17830. */
  17831. edgesWidthScalerForPerspective: number;
  17832. protected _source: AbstractMesh;
  17833. protected _linesPositions: number[];
  17834. protected _linesNormals: number[];
  17835. protected _linesIndices: number[];
  17836. protected _epsilon: number;
  17837. protected _indicesCount: number;
  17838. protected _lineShader: ShaderMaterial;
  17839. protected _ib: DataBuffer;
  17840. protected _buffers: {
  17841. [key: string]: Nullable<VertexBuffer>;
  17842. };
  17843. protected _checkVerticesInsteadOfIndices: boolean;
  17844. private _meshRebuildObserver;
  17845. private _meshDisposeObserver;
  17846. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17847. isEnabled: boolean;
  17848. /**
  17849. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17850. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17851. * @param source Mesh used to create edges
  17852. * @param epsilon sum of angles in adjacency to check for edge
  17853. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17854. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17855. */
  17856. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17857. protected _prepareRessources(): void;
  17858. /** @hidden */
  17859. _rebuild(): void;
  17860. /**
  17861. * Releases the required resources for the edges renderer
  17862. */
  17863. dispose(): void;
  17864. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17865. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17866. /**
  17867. * Checks if the pair of p0 and p1 is en edge
  17868. * @param faceIndex
  17869. * @param edge
  17870. * @param faceNormals
  17871. * @param p0
  17872. * @param p1
  17873. * @private
  17874. */
  17875. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17876. /**
  17877. * push line into the position, normal and index buffer
  17878. * @protected
  17879. */
  17880. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17881. /**
  17882. * Generates lines edges from adjacencjes
  17883. * @private
  17884. */
  17885. _generateEdgesLines(): void;
  17886. /**
  17887. * Checks wether or not the edges renderer is ready to render.
  17888. * @return true if ready, otherwise false.
  17889. */
  17890. isReady(): boolean;
  17891. /**
  17892. * Renders the edges of the attached mesh,
  17893. */
  17894. render(): void;
  17895. }
  17896. /**
  17897. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17898. */
  17899. export class LineEdgesRenderer extends EdgesRenderer {
  17900. /**
  17901. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17902. * @param source LineMesh used to generate edges
  17903. * @param epsilon not important (specified angle for edge detection)
  17904. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17905. */
  17906. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17907. /**
  17908. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17909. */
  17910. _generateEdgesLines(): void;
  17911. }
  17912. }
  17913. declare module "babylonjs/Rendering/renderingGroup" {
  17914. import { SmartArray } from "babylonjs/Misc/smartArray";
  17915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17917. import { Nullable } from "babylonjs/types";
  17918. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17919. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17920. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17921. import { Material } from "babylonjs/Materials/material";
  17922. import { Scene } from "babylonjs/scene";
  17923. /**
  17924. * This represents the object necessary to create a rendering group.
  17925. * This is exclusively used and created by the rendering manager.
  17926. * To modify the behavior, you use the available helpers in your scene or meshes.
  17927. * @hidden
  17928. */
  17929. export class RenderingGroup {
  17930. index: number;
  17931. private _scene;
  17932. private _opaqueSubMeshes;
  17933. private _transparentSubMeshes;
  17934. private _alphaTestSubMeshes;
  17935. private _depthOnlySubMeshes;
  17936. private _particleSystems;
  17937. private _spriteManagers;
  17938. private _opaqueSortCompareFn;
  17939. private _alphaTestSortCompareFn;
  17940. private _transparentSortCompareFn;
  17941. private _renderOpaque;
  17942. private _renderAlphaTest;
  17943. private _renderTransparent;
  17944. /** @hidden */
  17945. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17946. onBeforeTransparentRendering: () => void;
  17947. /**
  17948. * Set the opaque sort comparison function.
  17949. * If null the sub meshes will be render in the order they were created
  17950. */
  17951. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17952. /**
  17953. * Set the alpha test sort comparison function.
  17954. * If null the sub meshes will be render in the order they were created
  17955. */
  17956. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17957. /**
  17958. * Set the transparent sort comparison function.
  17959. * If null the sub meshes will be render in the order they were created
  17960. */
  17961. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17962. /**
  17963. * Creates a new rendering group.
  17964. * @param index The rendering group index
  17965. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17966. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17967. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17968. */
  17969. 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>);
  17970. /**
  17971. * Render all the sub meshes contained in the group.
  17972. * @param customRenderFunction Used to override the default render behaviour of the group.
  17973. * @returns true if rendered some submeshes.
  17974. */
  17975. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17976. /**
  17977. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17978. * @param subMeshes The submeshes to render
  17979. */
  17980. private renderOpaqueSorted;
  17981. /**
  17982. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17983. * @param subMeshes The submeshes to render
  17984. */
  17985. private renderAlphaTestSorted;
  17986. /**
  17987. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17988. * @param subMeshes The submeshes to render
  17989. */
  17990. private renderTransparentSorted;
  17991. /**
  17992. * Renders the submeshes in a specified order.
  17993. * @param subMeshes The submeshes to sort before render
  17994. * @param sortCompareFn The comparison function use to sort
  17995. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17996. * @param transparent Specifies to activate blending if true
  17997. */
  17998. private static renderSorted;
  17999. /**
  18000. * Renders the submeshes in the order they were dispatched (no sort applied).
  18001. * @param subMeshes The submeshes to render
  18002. */
  18003. private static renderUnsorted;
  18004. /**
  18005. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18006. * are rendered back to front if in the same alpha index.
  18007. *
  18008. * @param a The first submesh
  18009. * @param b The second submesh
  18010. * @returns The result of the comparison
  18011. */
  18012. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18013. /**
  18014. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18015. * are rendered back to front.
  18016. *
  18017. * @param a The first submesh
  18018. * @param b The second submesh
  18019. * @returns The result of the comparison
  18020. */
  18021. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18022. /**
  18023. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18024. * are rendered front to back (prevent overdraw).
  18025. *
  18026. * @param a The first submesh
  18027. * @param b The second submesh
  18028. * @returns The result of the comparison
  18029. */
  18030. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18031. /**
  18032. * Resets the different lists of submeshes to prepare a new frame.
  18033. */
  18034. prepare(): void;
  18035. dispose(): void;
  18036. /**
  18037. * Inserts the submesh in its correct queue depending on its material.
  18038. * @param subMesh The submesh to dispatch
  18039. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18040. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18041. */
  18042. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18043. dispatchSprites(spriteManager: ISpriteManager): void;
  18044. dispatchParticles(particleSystem: IParticleSystem): void;
  18045. private _renderParticles;
  18046. private _renderSprites;
  18047. }
  18048. }
  18049. declare module "babylonjs/Rendering/renderingManager" {
  18050. import { Nullable } from "babylonjs/types";
  18051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18052. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18053. import { SmartArray } from "babylonjs/Misc/smartArray";
  18054. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18055. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18056. import { Material } from "babylonjs/Materials/material";
  18057. import { Scene } from "babylonjs/scene";
  18058. import { Camera } from "babylonjs/Cameras/camera";
  18059. /**
  18060. * Interface describing the different options available in the rendering manager
  18061. * regarding Auto Clear between groups.
  18062. */
  18063. export interface IRenderingManagerAutoClearSetup {
  18064. /**
  18065. * Defines whether or not autoclear is enable.
  18066. */
  18067. autoClear: boolean;
  18068. /**
  18069. * Defines whether or not to autoclear the depth buffer.
  18070. */
  18071. depth: boolean;
  18072. /**
  18073. * Defines whether or not to autoclear the stencil buffer.
  18074. */
  18075. stencil: boolean;
  18076. }
  18077. /**
  18078. * This class is used by the onRenderingGroupObservable
  18079. */
  18080. export class RenderingGroupInfo {
  18081. /**
  18082. * The Scene that being rendered
  18083. */
  18084. scene: Scene;
  18085. /**
  18086. * The camera currently used for the rendering pass
  18087. */
  18088. camera: Nullable<Camera>;
  18089. /**
  18090. * The ID of the renderingGroup being processed
  18091. */
  18092. renderingGroupId: number;
  18093. }
  18094. /**
  18095. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18096. * It is enable to manage the different groups as well as the different necessary sort functions.
  18097. * This should not be used directly aside of the few static configurations
  18098. */
  18099. export class RenderingManager {
  18100. /**
  18101. * The max id used for rendering groups (not included)
  18102. */
  18103. static MAX_RENDERINGGROUPS: number;
  18104. /**
  18105. * The min id used for rendering groups (included)
  18106. */
  18107. static MIN_RENDERINGGROUPS: number;
  18108. /**
  18109. * Used to globally prevent autoclearing scenes.
  18110. */
  18111. static AUTOCLEAR: boolean;
  18112. /**
  18113. * @hidden
  18114. */
  18115. _useSceneAutoClearSetup: boolean;
  18116. private _scene;
  18117. private _renderingGroups;
  18118. private _depthStencilBufferAlreadyCleaned;
  18119. private _autoClearDepthStencil;
  18120. private _customOpaqueSortCompareFn;
  18121. private _customAlphaTestSortCompareFn;
  18122. private _customTransparentSortCompareFn;
  18123. private _renderingGroupInfo;
  18124. /**
  18125. * Instantiates a new rendering group for a particular scene
  18126. * @param scene Defines the scene the groups belongs to
  18127. */
  18128. constructor(scene: Scene);
  18129. private _clearDepthStencilBuffer;
  18130. /**
  18131. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18132. * @hidden
  18133. */
  18134. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18135. /**
  18136. * Resets the different information of the group to prepare a new frame
  18137. * @hidden
  18138. */
  18139. reset(): void;
  18140. /**
  18141. * Dispose and release the group and its associated resources.
  18142. * @hidden
  18143. */
  18144. dispose(): void;
  18145. /**
  18146. * Clear the info related to rendering groups preventing retention points during dispose.
  18147. */
  18148. freeRenderingGroups(): void;
  18149. private _prepareRenderingGroup;
  18150. /**
  18151. * Add a sprite manager to the rendering manager in order to render it this frame.
  18152. * @param spriteManager Define the sprite manager to render
  18153. */
  18154. dispatchSprites(spriteManager: ISpriteManager): void;
  18155. /**
  18156. * Add a particle system to the rendering manager in order to render it this frame.
  18157. * @param particleSystem Define the particle system to render
  18158. */
  18159. dispatchParticles(particleSystem: IParticleSystem): void;
  18160. /**
  18161. * Add a submesh to the manager in order to render it this frame
  18162. * @param subMesh The submesh to dispatch
  18163. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18164. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18165. */
  18166. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18167. /**
  18168. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18169. * This allowed control for front to back rendering or reversly depending of the special needs.
  18170. *
  18171. * @param renderingGroupId The rendering group id corresponding to its index
  18172. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18173. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18174. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18175. */
  18176. 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;
  18177. /**
  18178. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18179. *
  18180. * @param renderingGroupId The rendering group id corresponding to its index
  18181. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18182. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18183. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18184. */
  18185. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18186. /**
  18187. * Gets the current auto clear configuration for one rendering group of the rendering
  18188. * manager.
  18189. * @param index the rendering group index to get the information for
  18190. * @returns The auto clear setup for the requested rendering group
  18191. */
  18192. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18193. }
  18194. }
  18195. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18196. import { Observable } from "babylonjs/Misc/observable";
  18197. import { SmartArray } from "babylonjs/Misc/smartArray";
  18198. import { Nullable } from "babylonjs/types";
  18199. import { Camera } from "babylonjs/Cameras/camera";
  18200. import { Scene } from "babylonjs/scene";
  18201. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18202. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18204. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18205. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18206. import { Texture } from "babylonjs/Materials/Textures/texture";
  18207. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18208. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18209. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18210. import { Engine } from "babylonjs/Engines/engine";
  18211. /**
  18212. * This Helps creating a texture that will be created from a camera in your scene.
  18213. * It is basically a dynamic texture that could be used to create special effects for instance.
  18214. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18215. */
  18216. export class RenderTargetTexture extends Texture {
  18217. isCube: boolean;
  18218. /**
  18219. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18220. */
  18221. static readonly REFRESHRATE_RENDER_ONCE: number;
  18222. /**
  18223. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18224. */
  18225. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18226. /**
  18227. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18228. * the central point of your effect and can save a lot of performances.
  18229. */
  18230. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18231. /**
  18232. * Use this predicate to dynamically define the list of mesh you want to render.
  18233. * If set, the renderList property will be overwritten.
  18234. */
  18235. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18236. private _renderList;
  18237. /**
  18238. * Use this list to define the list of mesh you want to render.
  18239. */
  18240. renderList: Nullable<Array<AbstractMesh>>;
  18241. private _hookArray;
  18242. /**
  18243. * Define if particles should be rendered in your texture.
  18244. */
  18245. renderParticles: boolean;
  18246. /**
  18247. * Define if sprites should be rendered in your texture.
  18248. */
  18249. renderSprites: boolean;
  18250. /**
  18251. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18252. */
  18253. coordinatesMode: number;
  18254. /**
  18255. * Define the camera used to render the texture.
  18256. */
  18257. activeCamera: Nullable<Camera>;
  18258. /**
  18259. * Override the render function of the texture with your own one.
  18260. */
  18261. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18262. /**
  18263. * Define if camera post processes should be use while rendering the texture.
  18264. */
  18265. useCameraPostProcesses: boolean;
  18266. /**
  18267. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18268. */
  18269. ignoreCameraViewport: boolean;
  18270. private _postProcessManager;
  18271. private _postProcesses;
  18272. private _resizeObserver;
  18273. /**
  18274. * An event triggered when the texture is unbind.
  18275. */
  18276. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18277. /**
  18278. * An event triggered when the texture is unbind.
  18279. */
  18280. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18281. private _onAfterUnbindObserver;
  18282. /**
  18283. * Set a after unbind callback in the texture.
  18284. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18285. */
  18286. onAfterUnbind: () => void;
  18287. /**
  18288. * An event triggered before rendering the texture
  18289. */
  18290. onBeforeRenderObservable: Observable<number>;
  18291. private _onBeforeRenderObserver;
  18292. /**
  18293. * Set a before render callback in the texture.
  18294. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18295. */
  18296. onBeforeRender: (faceIndex: number) => void;
  18297. /**
  18298. * An event triggered after rendering the texture
  18299. */
  18300. onAfterRenderObservable: Observable<number>;
  18301. private _onAfterRenderObserver;
  18302. /**
  18303. * Set a after render callback in the texture.
  18304. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18305. */
  18306. onAfterRender: (faceIndex: number) => void;
  18307. /**
  18308. * An event triggered after the texture clear
  18309. */
  18310. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18311. private _onClearObserver;
  18312. /**
  18313. * Set a clear callback in the texture.
  18314. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18315. */
  18316. onClear: (Engine: Engine) => void;
  18317. /**
  18318. * Define the clear color of the Render Target if it should be different from the scene.
  18319. */
  18320. clearColor: Color4;
  18321. protected _size: number | {
  18322. width: number;
  18323. height: number;
  18324. };
  18325. protected _initialSizeParameter: number | {
  18326. width: number;
  18327. height: number;
  18328. } | {
  18329. ratio: number;
  18330. };
  18331. protected _sizeRatio: Nullable<number>;
  18332. /** @hidden */
  18333. _generateMipMaps: boolean;
  18334. protected _renderingManager: RenderingManager;
  18335. /** @hidden */
  18336. _waitingRenderList: string[];
  18337. protected _doNotChangeAspectRatio: boolean;
  18338. protected _currentRefreshId: number;
  18339. protected _refreshRate: number;
  18340. protected _textureMatrix: Matrix;
  18341. protected _samples: number;
  18342. protected _renderTargetOptions: RenderTargetCreationOptions;
  18343. /**
  18344. * Gets render target creation options that were used.
  18345. */
  18346. readonly renderTargetOptions: RenderTargetCreationOptions;
  18347. protected _engine: Engine;
  18348. protected _onRatioRescale(): void;
  18349. /**
  18350. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18351. * It must define where the camera used to render the texture is set
  18352. */
  18353. boundingBoxPosition: Vector3;
  18354. private _boundingBoxSize;
  18355. /**
  18356. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18357. * When defined, the cubemap will switch to local mode
  18358. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18359. * @example https://www.babylonjs-playground.com/#RNASML
  18360. */
  18361. boundingBoxSize: Vector3;
  18362. /**
  18363. * In case the RTT has been created with a depth texture, get the associated
  18364. * depth texture.
  18365. * Otherwise, return null.
  18366. */
  18367. depthStencilTexture: Nullable<InternalTexture>;
  18368. /**
  18369. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18370. * or used a shadow, depth texture...
  18371. * @param name The friendly name of the texture
  18372. * @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)
  18373. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18374. * @param generateMipMaps True if mip maps need to be generated after render.
  18375. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18376. * @param type The type of the buffer in the RTT (int, half float, float...)
  18377. * @param isCube True if a cube texture needs to be created
  18378. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18379. * @param generateDepthBuffer True to generate a depth buffer
  18380. * @param generateStencilBuffer True to generate a stencil buffer
  18381. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18382. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18383. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18384. */
  18385. constructor(name: string, size: number | {
  18386. width: number;
  18387. height: number;
  18388. } | {
  18389. ratio: number;
  18390. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18391. /**
  18392. * Creates a depth stencil texture.
  18393. * This is only available in WebGL 2 or with the depth texture extension available.
  18394. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18395. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18396. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18397. */
  18398. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18399. private _processSizeParameter;
  18400. /**
  18401. * Define the number of samples to use in case of MSAA.
  18402. * It defaults to one meaning no MSAA has been enabled.
  18403. */
  18404. samples: number;
  18405. /**
  18406. * Resets the refresh counter of the texture and start bak from scratch.
  18407. * Could be useful to regenerate the texture if it is setup to render only once.
  18408. */
  18409. resetRefreshCounter(): void;
  18410. /**
  18411. * Define the refresh rate of the texture or the rendering frequency.
  18412. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18413. */
  18414. refreshRate: number;
  18415. /**
  18416. * Adds a post process to the render target rendering passes.
  18417. * @param postProcess define the post process to add
  18418. */
  18419. addPostProcess(postProcess: PostProcess): void;
  18420. /**
  18421. * Clear all the post processes attached to the render target
  18422. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18423. */
  18424. clearPostProcesses(dispose?: boolean): void;
  18425. /**
  18426. * Remove one of the post process from the list of attached post processes to the texture
  18427. * @param postProcess define the post process to remove from the list
  18428. */
  18429. removePostProcess(postProcess: PostProcess): void;
  18430. /** @hidden */
  18431. _shouldRender(): boolean;
  18432. /**
  18433. * Gets the actual render size of the texture.
  18434. * @returns the width of the render size
  18435. */
  18436. getRenderSize(): number;
  18437. /**
  18438. * Gets the actual render width of the texture.
  18439. * @returns the width of the render size
  18440. */
  18441. getRenderWidth(): number;
  18442. /**
  18443. * Gets the actual render height of the texture.
  18444. * @returns the height of the render size
  18445. */
  18446. getRenderHeight(): number;
  18447. /**
  18448. * Get if the texture can be rescaled or not.
  18449. */
  18450. readonly canRescale: boolean;
  18451. /**
  18452. * Resize the texture using a ratio.
  18453. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18454. */
  18455. scale(ratio: number): void;
  18456. /**
  18457. * Get the texture reflection matrix used to rotate/transform the reflection.
  18458. * @returns the reflection matrix
  18459. */
  18460. getReflectionTextureMatrix(): Matrix;
  18461. /**
  18462. * Resize the texture to a new desired size.
  18463. * Be carrefull as it will recreate all the data in the new texture.
  18464. * @param size Define the new size. It can be:
  18465. * - a number for squared texture,
  18466. * - an object containing { width: number, height: number }
  18467. * - or an object containing a ratio { ratio: number }
  18468. */
  18469. resize(size: number | {
  18470. width: number;
  18471. height: number;
  18472. } | {
  18473. ratio: number;
  18474. }): void;
  18475. /**
  18476. * Renders all the objects from the render list into the texture.
  18477. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18478. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18479. */
  18480. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18481. private _bestReflectionRenderTargetDimension;
  18482. /**
  18483. * @hidden
  18484. * @param faceIndex face index to bind to if this is a cubetexture
  18485. */
  18486. _bindFrameBuffer(faceIndex?: number): void;
  18487. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18488. private renderToTarget;
  18489. /**
  18490. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18491. * This allowed control for front to back rendering or reversly depending of the special needs.
  18492. *
  18493. * @param renderingGroupId The rendering group id corresponding to its index
  18494. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18495. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18496. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18497. */
  18498. 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;
  18499. /**
  18500. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18501. *
  18502. * @param renderingGroupId The rendering group id corresponding to its index
  18503. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18504. */
  18505. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18506. /**
  18507. * Clones the texture.
  18508. * @returns the cloned texture
  18509. */
  18510. clone(): RenderTargetTexture;
  18511. /**
  18512. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18513. * @returns The JSON representation of the texture
  18514. */
  18515. serialize(): any;
  18516. /**
  18517. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18518. */
  18519. disposeFramebufferObjects(): void;
  18520. /**
  18521. * Dispose the texture and release its associated resources.
  18522. */
  18523. dispose(): void;
  18524. /** @hidden */
  18525. _rebuild(): void;
  18526. /**
  18527. * Clear the info related to rendering groups preventing retention point in material dispose.
  18528. */
  18529. freeRenderingGroups(): void;
  18530. /**
  18531. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18532. * @returns the view count
  18533. */
  18534. getViewCount(): number;
  18535. }
  18536. }
  18537. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18538. import { Scene } from "babylonjs/scene";
  18539. import { Plane } from "babylonjs/Maths/math";
  18540. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18541. /**
  18542. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18543. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18544. * You can then easily use it as a reflectionTexture on a flat surface.
  18545. * In case the surface is not a plane, please consider relying on reflection probes.
  18546. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18547. */
  18548. export class MirrorTexture extends RenderTargetTexture {
  18549. private scene;
  18550. /**
  18551. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18552. * 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.
  18553. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18554. */
  18555. mirrorPlane: Plane;
  18556. /**
  18557. * Define the blur ratio used to blur the reflection if needed.
  18558. */
  18559. blurRatio: number;
  18560. /**
  18561. * Define the adaptive blur kernel used to blur the reflection if needed.
  18562. * This will autocompute the closest best match for the `blurKernel`
  18563. */
  18564. adaptiveBlurKernel: number;
  18565. /**
  18566. * Define the blur kernel used to blur the reflection if needed.
  18567. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18568. */
  18569. blurKernel: number;
  18570. /**
  18571. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18572. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18573. */
  18574. blurKernelX: number;
  18575. /**
  18576. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18577. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18578. */
  18579. blurKernelY: number;
  18580. private _autoComputeBlurKernel;
  18581. protected _onRatioRescale(): void;
  18582. private _updateGammaSpace;
  18583. private _imageProcessingConfigChangeObserver;
  18584. private _transformMatrix;
  18585. private _mirrorMatrix;
  18586. private _savedViewMatrix;
  18587. private _blurX;
  18588. private _blurY;
  18589. private _adaptiveBlurKernel;
  18590. private _blurKernelX;
  18591. private _blurKernelY;
  18592. private _blurRatio;
  18593. /**
  18594. * Instantiates a Mirror Texture.
  18595. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18596. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18597. * You can then easily use it as a reflectionTexture on a flat surface.
  18598. * In case the surface is not a plane, please consider relying on reflection probes.
  18599. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18600. * @param name
  18601. * @param size
  18602. * @param scene
  18603. * @param generateMipMaps
  18604. * @param type
  18605. * @param samplingMode
  18606. * @param generateDepthBuffer
  18607. */
  18608. constructor(name: string, size: number | {
  18609. width: number;
  18610. height: number;
  18611. } | {
  18612. ratio: number;
  18613. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18614. private _preparePostProcesses;
  18615. /**
  18616. * Clone the mirror texture.
  18617. * @returns the cloned texture
  18618. */
  18619. clone(): MirrorTexture;
  18620. /**
  18621. * Serialize the texture to a JSON representation you could use in Parse later on
  18622. * @returns the serialized JSON representation
  18623. */
  18624. serialize(): any;
  18625. /**
  18626. * Dispose the texture and release its associated resources.
  18627. */
  18628. dispose(): void;
  18629. }
  18630. }
  18631. declare module "babylonjs/Materials/Textures/texture" {
  18632. import { Observable } from "babylonjs/Misc/observable";
  18633. import { Nullable } from "babylonjs/types";
  18634. import { Scene } from "babylonjs/scene";
  18635. import { Matrix } from "babylonjs/Maths/math";
  18636. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18637. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18638. /**
  18639. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18640. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18641. */
  18642. export class Texture extends BaseTexture {
  18643. /** @hidden */
  18644. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18645. /** @hidden */
  18646. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18647. /** @hidden */
  18648. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18649. /** nearest is mag = nearest and min = nearest and mip = linear */
  18650. static readonly NEAREST_SAMPLINGMODE: number;
  18651. /** nearest is mag = nearest and min = nearest and mip = linear */
  18652. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18653. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18654. static readonly BILINEAR_SAMPLINGMODE: number;
  18655. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18656. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18657. /** Trilinear is mag = linear and min = linear and mip = linear */
  18658. static readonly TRILINEAR_SAMPLINGMODE: number;
  18659. /** Trilinear is mag = linear and min = linear and mip = linear */
  18660. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18661. /** mag = nearest and min = nearest and mip = nearest */
  18662. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18663. /** mag = nearest and min = linear and mip = nearest */
  18664. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18665. /** mag = nearest and min = linear and mip = linear */
  18666. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18667. /** mag = nearest and min = linear and mip = none */
  18668. static readonly NEAREST_LINEAR: number;
  18669. /** mag = nearest and min = nearest and mip = none */
  18670. static readonly NEAREST_NEAREST: number;
  18671. /** mag = linear and min = nearest and mip = nearest */
  18672. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18673. /** mag = linear and min = nearest and mip = linear */
  18674. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18675. /** mag = linear and min = linear and mip = none */
  18676. static readonly LINEAR_LINEAR: number;
  18677. /** mag = linear and min = nearest and mip = none */
  18678. static readonly LINEAR_NEAREST: number;
  18679. /** Explicit coordinates mode */
  18680. static readonly EXPLICIT_MODE: number;
  18681. /** Spherical coordinates mode */
  18682. static readonly SPHERICAL_MODE: number;
  18683. /** Planar coordinates mode */
  18684. static readonly PLANAR_MODE: number;
  18685. /** Cubic coordinates mode */
  18686. static readonly CUBIC_MODE: number;
  18687. /** Projection coordinates mode */
  18688. static readonly PROJECTION_MODE: number;
  18689. /** Inverse Cubic coordinates mode */
  18690. static readonly SKYBOX_MODE: number;
  18691. /** Inverse Cubic coordinates mode */
  18692. static readonly INVCUBIC_MODE: number;
  18693. /** Equirectangular coordinates mode */
  18694. static readonly EQUIRECTANGULAR_MODE: number;
  18695. /** Equirectangular Fixed coordinates mode */
  18696. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18697. /** Equirectangular Fixed Mirrored coordinates mode */
  18698. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18699. /** Texture is not repeating outside of 0..1 UVs */
  18700. static readonly CLAMP_ADDRESSMODE: number;
  18701. /** Texture is repeating outside of 0..1 UVs */
  18702. static readonly WRAP_ADDRESSMODE: number;
  18703. /** Texture is repeating and mirrored */
  18704. static readonly MIRROR_ADDRESSMODE: number;
  18705. /**
  18706. * 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
  18707. */
  18708. static UseSerializedUrlIfAny: boolean;
  18709. /**
  18710. * Define the url of the texture.
  18711. */
  18712. url: Nullable<string>;
  18713. /**
  18714. * Define an offset on the texture to offset the u coordinates of the UVs
  18715. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18716. */
  18717. uOffset: number;
  18718. /**
  18719. * Define an offset on the texture to offset the v coordinates of the UVs
  18720. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18721. */
  18722. vOffset: number;
  18723. /**
  18724. * Define an offset on the texture to scale the u coordinates of the UVs
  18725. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18726. */
  18727. uScale: number;
  18728. /**
  18729. * Define an offset on the texture to scale the v coordinates of the UVs
  18730. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18731. */
  18732. vScale: number;
  18733. /**
  18734. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18735. * @see http://doc.babylonjs.com/how_to/more_materials
  18736. */
  18737. uAng: number;
  18738. /**
  18739. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18740. * @see http://doc.babylonjs.com/how_to/more_materials
  18741. */
  18742. vAng: number;
  18743. /**
  18744. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18745. * @see http://doc.babylonjs.com/how_to/more_materials
  18746. */
  18747. wAng: number;
  18748. /**
  18749. * Defines the center of rotation (U)
  18750. */
  18751. uRotationCenter: number;
  18752. /**
  18753. * Defines the center of rotation (V)
  18754. */
  18755. vRotationCenter: number;
  18756. /**
  18757. * Defines the center of rotation (W)
  18758. */
  18759. wRotationCenter: number;
  18760. /**
  18761. * Are mip maps generated for this texture or not.
  18762. */
  18763. readonly noMipmap: boolean;
  18764. /**
  18765. * List of inspectable custom properties (used by the Inspector)
  18766. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18767. */
  18768. inspectableCustomProperties: Nullable<IInspectable[]>;
  18769. private _noMipmap;
  18770. /** @hidden */
  18771. _invertY: boolean;
  18772. private _rowGenerationMatrix;
  18773. private _cachedTextureMatrix;
  18774. private _projectionModeMatrix;
  18775. private _t0;
  18776. private _t1;
  18777. private _t2;
  18778. private _cachedUOffset;
  18779. private _cachedVOffset;
  18780. private _cachedUScale;
  18781. private _cachedVScale;
  18782. private _cachedUAng;
  18783. private _cachedVAng;
  18784. private _cachedWAng;
  18785. private _cachedProjectionMatrixId;
  18786. private _cachedCoordinatesMode;
  18787. /** @hidden */
  18788. protected _initialSamplingMode: number;
  18789. /** @hidden */
  18790. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18791. private _deleteBuffer;
  18792. protected _format: Nullable<number>;
  18793. private _delayedOnLoad;
  18794. private _delayedOnError;
  18795. /**
  18796. * Observable triggered once the texture has been loaded.
  18797. */
  18798. onLoadObservable: Observable<Texture>;
  18799. protected _isBlocking: boolean;
  18800. /**
  18801. * Is the texture preventing material to render while loading.
  18802. * If false, a default texture will be used instead of the loading one during the preparation step.
  18803. */
  18804. isBlocking: boolean;
  18805. /**
  18806. * Get the current sampling mode associated with the texture.
  18807. */
  18808. readonly samplingMode: number;
  18809. /**
  18810. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18811. */
  18812. readonly invertY: boolean;
  18813. /**
  18814. * Instantiates a new texture.
  18815. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18816. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18817. * @param url define the url of the picture to load as a texture
  18818. * @param scene define the scene the texture will belong to
  18819. * @param noMipmap define if the texture will require mip maps or not
  18820. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18821. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18822. * @param onLoad define a callback triggered when the texture has been loaded
  18823. * @param onError define a callback triggered when an error occurred during the loading session
  18824. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18825. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18826. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18827. */
  18828. 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);
  18829. /**
  18830. * Update the url (and optional buffer) of this texture if url was null during construction.
  18831. * @param url the url of the texture
  18832. * @param buffer the buffer of the texture (defaults to null)
  18833. * @param onLoad callback called when the texture is loaded (defaults to null)
  18834. */
  18835. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18836. /**
  18837. * Finish the loading sequence of a texture flagged as delayed load.
  18838. * @hidden
  18839. */
  18840. delayLoad(): void;
  18841. private _prepareRowForTextureGeneration;
  18842. /**
  18843. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18844. * @returns the transform matrix of the texture.
  18845. */
  18846. getTextureMatrix(): Matrix;
  18847. /**
  18848. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18849. * @returns The reflection texture transform
  18850. */
  18851. getReflectionTextureMatrix(): Matrix;
  18852. /**
  18853. * Clones the texture.
  18854. * @returns the cloned texture
  18855. */
  18856. clone(): Texture;
  18857. /**
  18858. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18859. * @returns The JSON representation of the texture
  18860. */
  18861. serialize(): any;
  18862. /**
  18863. * Get the current class name of the texture useful for serialization or dynamic coding.
  18864. * @returns "Texture"
  18865. */
  18866. getClassName(): string;
  18867. /**
  18868. * Dispose the texture and release its associated resources.
  18869. */
  18870. dispose(): void;
  18871. /**
  18872. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18873. * @param parsedTexture Define the JSON representation of the texture
  18874. * @param scene Define the scene the parsed texture should be instantiated in
  18875. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18876. * @returns The parsed texture if successful
  18877. */
  18878. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18879. /**
  18880. * Creates a texture from its base 64 representation.
  18881. * @param data Define the base64 payload without the data: prefix
  18882. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18883. * @param scene Define the scene the texture should belong to
  18884. * @param noMipmap Forces the texture to not create mip map information if true
  18885. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18886. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18887. * @param onLoad define a callback triggered when the texture has been loaded
  18888. * @param onError define a callback triggered when an error occurred during the loading session
  18889. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18890. * @returns the created texture
  18891. */
  18892. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18893. /**
  18894. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18895. * @param data Define the base64 payload without the data: prefix
  18896. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18897. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18898. * @param scene Define the scene the texture should belong to
  18899. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18900. * @param noMipmap Forces the texture to not create mip map information if true
  18901. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18902. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18903. * @param onLoad define a callback triggered when the texture has been loaded
  18904. * @param onError define a callback triggered when an error occurred during the loading session
  18905. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18906. * @returns the created texture
  18907. */
  18908. 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;
  18909. }
  18910. }
  18911. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18912. import { Nullable } from "babylonjs/types";
  18913. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18914. import { Scene } from "babylonjs/scene";
  18915. module "babylonjs/Engines/engine" {
  18916. interface Engine {
  18917. /**
  18918. * Creates a raw texture
  18919. * @param data defines the data to store in the texture
  18920. * @param width defines the width of the texture
  18921. * @param height defines the height of the texture
  18922. * @param format defines the format of the data
  18923. * @param generateMipMaps defines if the engine should generate the mip levels
  18924. * @param invertY defines if data must be stored with Y axis inverted
  18925. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18926. * @param compression defines the compression used (null by default)
  18927. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18928. * @returns the raw texture inside an InternalTexture
  18929. */
  18930. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18931. /**
  18932. * Update a raw texture
  18933. * @param texture defines the texture to update
  18934. * @param data defines the data to store in the texture
  18935. * @param format defines the format of the data
  18936. * @param invertY defines if data must be stored with Y axis inverted
  18937. */
  18938. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18939. /**
  18940. * Update a raw texture
  18941. * @param texture defines the texture to update
  18942. * @param data defines the data to store in the texture
  18943. * @param format defines the format of the data
  18944. * @param invertY defines if data must be stored with Y axis inverted
  18945. * @param compression defines the compression used (null by default)
  18946. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18947. */
  18948. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18949. /**
  18950. * Creates a new raw cube texture
  18951. * @param data defines the array of data to use to create each face
  18952. * @param size defines the size of the textures
  18953. * @param format defines the format of the data
  18954. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18955. * @param generateMipMaps defines if the engine should generate the mip levels
  18956. * @param invertY defines if data must be stored with Y axis inverted
  18957. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18958. * @param compression defines the compression used (null by default)
  18959. * @returns the cube texture as an InternalTexture
  18960. */
  18961. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18962. /**
  18963. * Update a raw cube texture
  18964. * @param texture defines the texture to udpdate
  18965. * @param data defines the data to store
  18966. * @param format defines the data format
  18967. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18968. * @param invertY defines if data must be stored with Y axis inverted
  18969. */
  18970. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18971. /**
  18972. * Update a raw cube texture
  18973. * @param texture defines the texture to udpdate
  18974. * @param data defines the data to store
  18975. * @param format defines the data format
  18976. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18977. * @param invertY defines if data must be stored with Y axis inverted
  18978. * @param compression defines the compression used (null by default)
  18979. */
  18980. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18981. /**
  18982. * Update a raw cube texture
  18983. * @param texture defines the texture to udpdate
  18984. * @param data defines the data to store
  18985. * @param format defines the data format
  18986. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18987. * @param invertY defines if data must be stored with Y axis inverted
  18988. * @param compression defines the compression used (null by default)
  18989. * @param level defines which level of the texture to update
  18990. */
  18991. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18992. /**
  18993. * Creates a new raw cube texture from a specified url
  18994. * @param url defines the url where the data is located
  18995. * @param scene defines the current scene
  18996. * @param size defines the size of the textures
  18997. * @param format defines the format of the data
  18998. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18999. * @param noMipmap defines if the engine should avoid generating the mip levels
  19000. * @param callback defines a callback used to extract texture data from loaded data
  19001. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19002. * @param onLoad defines a callback called when texture is loaded
  19003. * @param onError defines a callback called if there is an error
  19004. * @returns the cube texture as an InternalTexture
  19005. */
  19006. 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;
  19007. /**
  19008. * Creates a new raw cube texture from a specified url
  19009. * @param url defines the url where the data is located
  19010. * @param scene defines the current scene
  19011. * @param size defines the size of the textures
  19012. * @param format defines the format of the data
  19013. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19014. * @param noMipmap defines if the engine should avoid generating the mip levels
  19015. * @param callback defines a callback used to extract texture data from loaded data
  19016. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19017. * @param onLoad defines a callback called when texture is loaded
  19018. * @param onError defines a callback called if there is an error
  19019. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19020. * @param invertY defines if data must be stored with Y axis inverted
  19021. * @returns the cube texture as an InternalTexture
  19022. */
  19023. 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;
  19024. /**
  19025. * Creates a new raw 3D texture
  19026. * @param data defines the data used to create the texture
  19027. * @param width defines the width of the texture
  19028. * @param height defines the height of the texture
  19029. * @param depth defines the depth of the texture
  19030. * @param format defines the format of the texture
  19031. * @param generateMipMaps defines if the engine must generate mip levels
  19032. * @param invertY defines if data must be stored with Y axis inverted
  19033. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19034. * @param compression defines the compressed used (can be null)
  19035. * @param textureType defines the compressed used (can be null)
  19036. * @returns a new raw 3D texture (stored in an InternalTexture)
  19037. */
  19038. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19039. /**
  19040. * Update a raw 3D texture
  19041. * @param texture defines the texture to update
  19042. * @param data defines the data to store
  19043. * @param format defines the data format
  19044. * @param invertY defines if data must be stored with Y axis inverted
  19045. */
  19046. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19047. /**
  19048. * Update a raw 3D texture
  19049. * @param texture defines the texture to update
  19050. * @param data defines the data to store
  19051. * @param format defines the data format
  19052. * @param invertY defines if data must be stored with Y axis inverted
  19053. * @param compression defines the used compression (can be null)
  19054. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19055. */
  19056. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19057. }
  19058. }
  19059. }
  19060. declare module "babylonjs/Materials/Textures/rawTexture" {
  19061. import { Scene } from "babylonjs/scene";
  19062. import { Texture } from "babylonjs/Materials/Textures/texture";
  19063. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19064. /**
  19065. * Raw texture can help creating a texture directly from an array of data.
  19066. * This can be super useful if you either get the data from an uncompressed source or
  19067. * if you wish to create your texture pixel by pixel.
  19068. */
  19069. export class RawTexture extends Texture {
  19070. /**
  19071. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19072. */
  19073. format: number;
  19074. private _engine;
  19075. /**
  19076. * Instantiates a new RawTexture.
  19077. * Raw texture can help creating a texture directly from an array of data.
  19078. * This can be super useful if you either get the data from an uncompressed source or
  19079. * if you wish to create your texture pixel by pixel.
  19080. * @param data define the array of data to use to create the texture
  19081. * @param width define the width of the texture
  19082. * @param height define the height of the texture
  19083. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19084. * @param scene define the scene the texture belongs to
  19085. * @param generateMipMaps define whether mip maps should be generated or not
  19086. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19087. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19088. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19089. */
  19090. constructor(data: ArrayBufferView, width: number, height: number,
  19091. /**
  19092. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19093. */
  19094. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19095. /**
  19096. * Updates the texture underlying data.
  19097. * @param data Define the new data of the texture
  19098. */
  19099. update(data: ArrayBufferView): void;
  19100. /**
  19101. * Creates a luminance texture from some data.
  19102. * @param data Define the texture data
  19103. * @param width Define the width of the texture
  19104. * @param height Define the height of the texture
  19105. * @param scene Define the scene the texture belongs to
  19106. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19107. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19108. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19109. * @returns the luminance texture
  19110. */
  19111. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19112. /**
  19113. * Creates a luminance alpha texture from some data.
  19114. * @param data Define the texture data
  19115. * @param width Define the width of the texture
  19116. * @param height Define the height of the texture
  19117. * @param scene Define the scene the texture belongs to
  19118. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19119. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19120. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19121. * @returns the luminance alpha texture
  19122. */
  19123. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19124. /**
  19125. * Creates an alpha texture from some data.
  19126. * @param data Define the texture data
  19127. * @param width Define the width of the texture
  19128. * @param height Define the height of the texture
  19129. * @param scene Define the scene the texture belongs to
  19130. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19131. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19132. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19133. * @returns the alpha texture
  19134. */
  19135. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19136. /**
  19137. * Creates a RGB texture from some data.
  19138. * @param data Define the texture data
  19139. * @param width Define the width of the texture
  19140. * @param height Define the height of the texture
  19141. * @param scene Define the scene the texture belongs to
  19142. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19143. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19144. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19145. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19146. * @returns the RGB alpha texture
  19147. */
  19148. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19149. /**
  19150. * Creates a RGBA texture from some data.
  19151. * @param data Define the texture data
  19152. * @param width Define the width of the texture
  19153. * @param height Define the height of the texture
  19154. * @param scene Define the scene the texture belongs to
  19155. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19156. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19157. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19158. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19159. * @returns the RGBA texture
  19160. */
  19161. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19162. /**
  19163. * Creates a R texture from some data.
  19164. * @param data Define the texture data
  19165. * @param width Define the width of the texture
  19166. * @param height Define the height of the texture
  19167. * @param scene Define the scene the texture belongs to
  19168. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19169. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19170. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19171. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19172. * @returns the R texture
  19173. */
  19174. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19175. }
  19176. }
  19177. declare module "babylonjs/Animations/runtimeAnimation" {
  19178. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19179. import { Animatable } from "babylonjs/Animations/animatable";
  19180. import { Scene } from "babylonjs/scene";
  19181. /**
  19182. * Defines a runtime animation
  19183. */
  19184. export class RuntimeAnimation {
  19185. private _events;
  19186. /**
  19187. * The current frame of the runtime animation
  19188. */
  19189. private _currentFrame;
  19190. /**
  19191. * The animation used by the runtime animation
  19192. */
  19193. private _animation;
  19194. /**
  19195. * The target of the runtime animation
  19196. */
  19197. private _target;
  19198. /**
  19199. * The initiating animatable
  19200. */
  19201. private _host;
  19202. /**
  19203. * The original value of the runtime animation
  19204. */
  19205. private _originalValue;
  19206. /**
  19207. * The original blend value of the runtime animation
  19208. */
  19209. private _originalBlendValue;
  19210. /**
  19211. * The offsets cache of the runtime animation
  19212. */
  19213. private _offsetsCache;
  19214. /**
  19215. * The high limits cache of the runtime animation
  19216. */
  19217. private _highLimitsCache;
  19218. /**
  19219. * Specifies if the runtime animation has been stopped
  19220. */
  19221. private _stopped;
  19222. /**
  19223. * The blending factor of the runtime animation
  19224. */
  19225. private _blendingFactor;
  19226. /**
  19227. * The BabylonJS scene
  19228. */
  19229. private _scene;
  19230. /**
  19231. * The current value of the runtime animation
  19232. */
  19233. private _currentValue;
  19234. /** @hidden */
  19235. _animationState: _IAnimationState;
  19236. /**
  19237. * The active target of the runtime animation
  19238. */
  19239. private _activeTargets;
  19240. private _currentActiveTarget;
  19241. private _directTarget;
  19242. /**
  19243. * The target path of the runtime animation
  19244. */
  19245. private _targetPath;
  19246. /**
  19247. * The weight of the runtime animation
  19248. */
  19249. private _weight;
  19250. /**
  19251. * The ratio offset of the runtime animation
  19252. */
  19253. private _ratioOffset;
  19254. /**
  19255. * The previous delay of the runtime animation
  19256. */
  19257. private _previousDelay;
  19258. /**
  19259. * The previous ratio of the runtime animation
  19260. */
  19261. private _previousRatio;
  19262. private _enableBlending;
  19263. private _keys;
  19264. private _minFrame;
  19265. private _maxFrame;
  19266. private _minValue;
  19267. private _maxValue;
  19268. private _targetIsArray;
  19269. /**
  19270. * Gets the current frame of the runtime animation
  19271. */
  19272. readonly currentFrame: number;
  19273. /**
  19274. * Gets the weight of the runtime animation
  19275. */
  19276. readonly weight: number;
  19277. /**
  19278. * Gets the current value of the runtime animation
  19279. */
  19280. readonly currentValue: any;
  19281. /**
  19282. * Gets the target path of the runtime animation
  19283. */
  19284. readonly targetPath: string;
  19285. /**
  19286. * Gets the actual target of the runtime animation
  19287. */
  19288. readonly target: any;
  19289. /** @hidden */
  19290. _onLoop: () => void;
  19291. /**
  19292. * Create a new RuntimeAnimation object
  19293. * @param target defines the target of the animation
  19294. * @param animation defines the source animation object
  19295. * @param scene defines the hosting scene
  19296. * @param host defines the initiating Animatable
  19297. */
  19298. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19299. private _preparePath;
  19300. /**
  19301. * Gets the animation from the runtime animation
  19302. */
  19303. readonly animation: Animation;
  19304. /**
  19305. * Resets the runtime animation to the beginning
  19306. * @param restoreOriginal defines whether to restore the target property to the original value
  19307. */
  19308. reset(restoreOriginal?: boolean): void;
  19309. /**
  19310. * Specifies if the runtime animation is stopped
  19311. * @returns Boolean specifying if the runtime animation is stopped
  19312. */
  19313. isStopped(): boolean;
  19314. /**
  19315. * Disposes of the runtime animation
  19316. */
  19317. dispose(): void;
  19318. /**
  19319. * Apply the interpolated value to the target
  19320. * @param currentValue defines the value computed by the animation
  19321. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19322. */
  19323. setValue(currentValue: any, weight: number): void;
  19324. private _getOriginalValues;
  19325. private _setValue;
  19326. /**
  19327. * Gets the loop pmode of the runtime animation
  19328. * @returns Loop Mode
  19329. */
  19330. private _getCorrectLoopMode;
  19331. /**
  19332. * Move the current animation to a given frame
  19333. * @param frame defines the frame to move to
  19334. */
  19335. goToFrame(frame: number): void;
  19336. /**
  19337. * @hidden Internal use only
  19338. */
  19339. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19340. /**
  19341. * Execute the current animation
  19342. * @param delay defines the delay to add to the current frame
  19343. * @param from defines the lower bound of the animation range
  19344. * @param to defines the upper bound of the animation range
  19345. * @param loop defines if the current animation must loop
  19346. * @param speedRatio defines the current speed ratio
  19347. * @param weight defines the weight of the animation (default is -1 so no weight)
  19348. * @param onLoop optional callback called when animation loops
  19349. * @returns a boolean indicating if the animation is running
  19350. */
  19351. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19352. }
  19353. }
  19354. declare module "babylonjs/Animations/animatable" {
  19355. import { Animation } from "babylonjs/Animations/animation";
  19356. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19357. import { Nullable } from "babylonjs/types";
  19358. import { Observable } from "babylonjs/Misc/observable";
  19359. import { Scene } from "babylonjs/scene";
  19360. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19361. import { Node } from "babylonjs/node";
  19362. /**
  19363. * Class used to store an actual running animation
  19364. */
  19365. export class Animatable {
  19366. /** defines the target object */
  19367. target: any;
  19368. /** defines the starting frame number (default is 0) */
  19369. fromFrame: number;
  19370. /** defines the ending frame number (default is 100) */
  19371. toFrame: number;
  19372. /** defines if the animation must loop (default is false) */
  19373. loopAnimation: boolean;
  19374. /** defines a callback to call when animation ends if it is not looping */
  19375. onAnimationEnd?: (() => void) | null | undefined;
  19376. /** defines a callback to call when animation loops */
  19377. onAnimationLoop?: (() => void) | null | undefined;
  19378. private _localDelayOffset;
  19379. private _pausedDelay;
  19380. private _runtimeAnimations;
  19381. private _paused;
  19382. private _scene;
  19383. private _speedRatio;
  19384. private _weight;
  19385. private _syncRoot;
  19386. /**
  19387. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19388. * This will only apply for non looping animation (default is true)
  19389. */
  19390. disposeOnEnd: boolean;
  19391. /**
  19392. * Gets a boolean indicating if the animation has started
  19393. */
  19394. animationStarted: boolean;
  19395. /**
  19396. * Observer raised when the animation ends
  19397. */
  19398. onAnimationEndObservable: Observable<Animatable>;
  19399. /**
  19400. * Observer raised when the animation loops
  19401. */
  19402. onAnimationLoopObservable: Observable<Animatable>;
  19403. /**
  19404. * Gets the root Animatable used to synchronize and normalize animations
  19405. */
  19406. readonly syncRoot: Nullable<Animatable>;
  19407. /**
  19408. * Gets the current frame of the first RuntimeAnimation
  19409. * Used to synchronize Animatables
  19410. */
  19411. readonly masterFrame: number;
  19412. /**
  19413. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19414. */
  19415. weight: number;
  19416. /**
  19417. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19418. */
  19419. speedRatio: number;
  19420. /**
  19421. * Creates a new Animatable
  19422. * @param scene defines the hosting scene
  19423. * @param target defines the target object
  19424. * @param fromFrame defines the starting frame number (default is 0)
  19425. * @param toFrame defines the ending frame number (default is 100)
  19426. * @param loopAnimation defines if the animation must loop (default is false)
  19427. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19428. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19429. * @param animations defines a group of animation to add to the new Animatable
  19430. * @param onAnimationLoop defines a callback to call when animation loops
  19431. */
  19432. constructor(scene: Scene,
  19433. /** defines the target object */
  19434. target: any,
  19435. /** defines the starting frame number (default is 0) */
  19436. fromFrame?: number,
  19437. /** defines the ending frame number (default is 100) */
  19438. toFrame?: number,
  19439. /** defines if the animation must loop (default is false) */
  19440. loopAnimation?: boolean, speedRatio?: number,
  19441. /** defines a callback to call when animation ends if it is not looping */
  19442. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19443. /** defines a callback to call when animation loops */
  19444. onAnimationLoop?: (() => void) | null | undefined);
  19445. /**
  19446. * Synchronize and normalize current Animatable with a source Animatable
  19447. * This is useful when using animation weights and when animations are not of the same length
  19448. * @param root defines the root Animatable to synchronize with
  19449. * @returns the current Animatable
  19450. */
  19451. syncWith(root: Animatable): Animatable;
  19452. /**
  19453. * Gets the list of runtime animations
  19454. * @returns an array of RuntimeAnimation
  19455. */
  19456. getAnimations(): RuntimeAnimation[];
  19457. /**
  19458. * Adds more animations to the current animatable
  19459. * @param target defines the target of the animations
  19460. * @param animations defines the new animations to add
  19461. */
  19462. appendAnimations(target: any, animations: Animation[]): void;
  19463. /**
  19464. * Gets the source animation for a specific property
  19465. * @param property defines the propertyu to look for
  19466. * @returns null or the source animation for the given property
  19467. */
  19468. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19469. /**
  19470. * Gets the runtime animation for a specific property
  19471. * @param property defines the propertyu to look for
  19472. * @returns null or the runtime animation for the given property
  19473. */
  19474. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19475. /**
  19476. * Resets the animatable to its original state
  19477. */
  19478. reset(): void;
  19479. /**
  19480. * Allows the animatable to blend with current running animations
  19481. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19482. * @param blendingSpeed defines the blending speed to use
  19483. */
  19484. enableBlending(blendingSpeed: number): void;
  19485. /**
  19486. * Disable animation blending
  19487. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19488. */
  19489. disableBlending(): void;
  19490. /**
  19491. * Jump directly to a given frame
  19492. * @param frame defines the frame to jump to
  19493. */
  19494. goToFrame(frame: number): void;
  19495. /**
  19496. * Pause the animation
  19497. */
  19498. pause(): void;
  19499. /**
  19500. * Restart the animation
  19501. */
  19502. restart(): void;
  19503. private _raiseOnAnimationEnd;
  19504. /**
  19505. * Stop and delete the current animation
  19506. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19507. * @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)
  19508. */
  19509. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19510. /**
  19511. * Wait asynchronously for the animation to end
  19512. * @returns a promise which will be fullfilled when the animation ends
  19513. */
  19514. waitAsync(): Promise<Animatable>;
  19515. /** @hidden */
  19516. _animate(delay: number): boolean;
  19517. }
  19518. module "babylonjs/scene" {
  19519. interface Scene {
  19520. /** @hidden */
  19521. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19522. /** @hidden */
  19523. _processLateAnimationBindingsForMatrices(holder: {
  19524. totalWeight: number;
  19525. animations: RuntimeAnimation[];
  19526. originalValue: Matrix;
  19527. }): any;
  19528. /** @hidden */
  19529. _processLateAnimationBindingsForQuaternions(holder: {
  19530. totalWeight: number;
  19531. animations: RuntimeAnimation[];
  19532. originalValue: Quaternion;
  19533. }, refQuaternion: Quaternion): Quaternion;
  19534. /** @hidden */
  19535. _processLateAnimationBindings(): void;
  19536. /**
  19537. * Will start the animation sequence of a given target
  19538. * @param target defines the target
  19539. * @param from defines from which frame should animation start
  19540. * @param to defines until which frame should animation run.
  19541. * @param weight defines the weight to apply to the animation (1.0 by default)
  19542. * @param loop defines if the animation loops
  19543. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19544. * @param onAnimationEnd defines the function to be executed when the animation ends
  19545. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19546. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19547. * @param onAnimationLoop defines the callback to call when an animation loops
  19548. * @returns the animatable object created for this animation
  19549. */
  19550. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19551. /**
  19552. * Will start the animation sequence of a given target
  19553. * @param target defines the target
  19554. * @param from defines from which frame should animation start
  19555. * @param to defines until which frame should animation run.
  19556. * @param loop defines if the animation loops
  19557. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19558. * @param onAnimationEnd defines the function to be executed when the animation ends
  19559. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19560. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19561. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19562. * @param onAnimationLoop defines the callback to call when an animation loops
  19563. * @returns the animatable object created for this animation
  19564. */
  19565. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19566. /**
  19567. * Will start the animation sequence of a given target and its hierarchy
  19568. * @param target defines the target
  19569. * @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.
  19570. * @param from defines from which frame should animation start
  19571. * @param to defines until which frame should animation run.
  19572. * @param loop defines if the animation loops
  19573. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19574. * @param onAnimationEnd defines the function to be executed when the animation ends
  19575. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19576. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19577. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19578. * @param onAnimationLoop defines the callback to call when an animation loops
  19579. * @returns the list of created animatables
  19580. */
  19581. 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[];
  19582. /**
  19583. * Begin a new animation on a given node
  19584. * @param target defines the target where the animation will take place
  19585. * @param animations defines the list of animations to start
  19586. * @param from defines the initial value
  19587. * @param to defines the final value
  19588. * @param loop defines if you want animation to loop (off by default)
  19589. * @param speedRatio defines the speed ratio to apply to all animations
  19590. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19591. * @param onAnimationLoop defines the callback to call when an animation loops
  19592. * @returns the list of created animatables
  19593. */
  19594. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19595. /**
  19596. * Begin a new animation on a given node and its hierarchy
  19597. * @param target defines the root node where the animation will take place
  19598. * @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.
  19599. * @param animations defines the list of animations to start
  19600. * @param from defines the initial value
  19601. * @param to defines the final value
  19602. * @param loop defines if you want animation to loop (off by default)
  19603. * @param speedRatio defines the speed ratio to apply to all animations
  19604. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19605. * @param onAnimationLoop defines the callback to call when an animation loops
  19606. * @returns the list of animatables created for all nodes
  19607. */
  19608. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19609. /**
  19610. * Gets the animatable associated with a specific target
  19611. * @param target defines the target of the animatable
  19612. * @returns the required animatable if found
  19613. */
  19614. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19615. /**
  19616. * Gets all animatables associated with a given target
  19617. * @param target defines the target to look animatables for
  19618. * @returns an array of Animatables
  19619. */
  19620. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19621. /**
  19622. * Will stop the animation of the given target
  19623. * @param target - the target
  19624. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19625. * @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)
  19626. */
  19627. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19628. /**
  19629. * Stops and removes all animations that have been applied to the scene
  19630. */
  19631. stopAllAnimations(): void;
  19632. }
  19633. }
  19634. module "babylonjs/Bones/bone" {
  19635. interface Bone {
  19636. /**
  19637. * Copy an animation range from another bone
  19638. * @param source defines the source bone
  19639. * @param rangeName defines the range name to copy
  19640. * @param frameOffset defines the frame offset
  19641. * @param rescaleAsRequired defines if rescaling must be applied if required
  19642. * @param skelDimensionsRatio defines the scaling ratio
  19643. * @returns true if operation was successful
  19644. */
  19645. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19646. }
  19647. }
  19648. }
  19649. declare module "babylonjs/Bones/skeleton" {
  19650. import { Bone } from "babylonjs/Bones/bone";
  19651. import { IAnimatable } from "babylonjs/Misc/tools";
  19652. import { Observable } from "babylonjs/Misc/observable";
  19653. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19654. import { Scene } from "babylonjs/scene";
  19655. import { Nullable } from "babylonjs/types";
  19656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19657. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19658. import { Animatable } from "babylonjs/Animations/animatable";
  19659. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19660. import { Animation } from "babylonjs/Animations/animation";
  19661. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19662. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19663. /**
  19664. * Class used to handle skinning animations
  19665. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19666. */
  19667. export class Skeleton implements IAnimatable {
  19668. /** defines the skeleton name */
  19669. name: string;
  19670. /** defines the skeleton Id */
  19671. id: string;
  19672. /**
  19673. * Defines the list of child bones
  19674. */
  19675. bones: Bone[];
  19676. /**
  19677. * Defines an estimate of the dimension of the skeleton at rest
  19678. */
  19679. dimensionsAtRest: Vector3;
  19680. /**
  19681. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19682. */
  19683. needInitialSkinMatrix: boolean;
  19684. /**
  19685. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19686. */
  19687. overrideMesh: Nullable<AbstractMesh>;
  19688. /**
  19689. * Gets the list of animations attached to this skeleton
  19690. */
  19691. animations: Array<Animation>;
  19692. private _scene;
  19693. private _isDirty;
  19694. private _transformMatrices;
  19695. private _transformMatrixTexture;
  19696. private _meshesWithPoseMatrix;
  19697. private _animatables;
  19698. private _identity;
  19699. private _synchronizedWithMesh;
  19700. private _ranges;
  19701. private _lastAbsoluteTransformsUpdateId;
  19702. private _canUseTextureForBones;
  19703. private _uniqueId;
  19704. /** @hidden */
  19705. _numBonesWithLinkedTransformNode: number;
  19706. /**
  19707. * Specifies if the skeleton should be serialized
  19708. */
  19709. doNotSerialize: boolean;
  19710. private _useTextureToStoreBoneMatrices;
  19711. /**
  19712. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19713. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19714. */
  19715. useTextureToStoreBoneMatrices: boolean;
  19716. private _animationPropertiesOverride;
  19717. /**
  19718. * Gets or sets the animation properties override
  19719. */
  19720. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19721. /**
  19722. * List of inspectable custom properties (used by the Inspector)
  19723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19724. */
  19725. inspectableCustomProperties: IInspectable[];
  19726. /**
  19727. * An observable triggered before computing the skeleton's matrices
  19728. */
  19729. onBeforeComputeObservable: Observable<Skeleton>;
  19730. /**
  19731. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19732. */
  19733. readonly isUsingTextureForMatrices: boolean;
  19734. /**
  19735. * Gets the unique ID of this skeleton
  19736. */
  19737. readonly uniqueId: number;
  19738. /**
  19739. * Creates a new skeleton
  19740. * @param name defines the skeleton name
  19741. * @param id defines the skeleton Id
  19742. * @param scene defines the hosting scene
  19743. */
  19744. constructor(
  19745. /** defines the skeleton name */
  19746. name: string,
  19747. /** defines the skeleton Id */
  19748. id: string, scene: Scene);
  19749. /**
  19750. * Gets the current object class name.
  19751. * @return the class name
  19752. */
  19753. getClassName(): string;
  19754. /**
  19755. * Returns an array containing the root bones
  19756. * @returns an array containing the root bones
  19757. */
  19758. getChildren(): Array<Bone>;
  19759. /**
  19760. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19761. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19762. * @returns a Float32Array containing matrices data
  19763. */
  19764. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19765. /**
  19766. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19767. * @returns a raw texture containing the data
  19768. */
  19769. getTransformMatrixTexture(): Nullable<RawTexture>;
  19770. /**
  19771. * Gets the current hosting scene
  19772. * @returns a scene object
  19773. */
  19774. getScene(): Scene;
  19775. /**
  19776. * Gets a string representing the current skeleton data
  19777. * @param fullDetails defines a boolean indicating if we want a verbose version
  19778. * @returns a string representing the current skeleton data
  19779. */
  19780. toString(fullDetails?: boolean): string;
  19781. /**
  19782. * Get bone's index searching by name
  19783. * @param name defines bone's name to search for
  19784. * @return the indice of the bone. Returns -1 if not found
  19785. */
  19786. getBoneIndexByName(name: string): number;
  19787. /**
  19788. * Creater a new animation range
  19789. * @param name defines the name of the range
  19790. * @param from defines the start key
  19791. * @param to defines the end key
  19792. */
  19793. createAnimationRange(name: string, from: number, to: number): void;
  19794. /**
  19795. * Delete a specific animation range
  19796. * @param name defines the name of the range
  19797. * @param deleteFrames defines if frames must be removed as well
  19798. */
  19799. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19800. /**
  19801. * Gets a specific animation range
  19802. * @param name defines the name of the range to look for
  19803. * @returns the requested animation range or null if not found
  19804. */
  19805. getAnimationRange(name: string): Nullable<AnimationRange>;
  19806. /**
  19807. * Gets the list of all animation ranges defined on this skeleton
  19808. * @returns an array
  19809. */
  19810. getAnimationRanges(): Nullable<AnimationRange>[];
  19811. /**
  19812. * Copy animation range from a source skeleton.
  19813. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19814. * @param source defines the source skeleton
  19815. * @param name defines the name of the range to copy
  19816. * @param rescaleAsRequired defines if rescaling must be applied if required
  19817. * @returns true if operation was successful
  19818. */
  19819. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19820. /**
  19821. * Forces the skeleton to go to rest pose
  19822. */
  19823. returnToRest(): void;
  19824. private _getHighestAnimationFrame;
  19825. /**
  19826. * Begin a specific animation range
  19827. * @param name defines the name of the range to start
  19828. * @param loop defines if looping must be turned on (false by default)
  19829. * @param speedRatio defines the speed ratio to apply (1 by default)
  19830. * @param onAnimationEnd defines a callback which will be called when animation will end
  19831. * @returns a new animatable
  19832. */
  19833. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19834. /** @hidden */
  19835. _markAsDirty(): void;
  19836. /** @hidden */
  19837. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19838. /** @hidden */
  19839. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19840. private _computeTransformMatrices;
  19841. /**
  19842. * Build all resources required to render a skeleton
  19843. */
  19844. prepare(): void;
  19845. /**
  19846. * Gets the list of animatables currently running for this skeleton
  19847. * @returns an array of animatables
  19848. */
  19849. getAnimatables(): IAnimatable[];
  19850. /**
  19851. * Clone the current skeleton
  19852. * @param name defines the name of the new skeleton
  19853. * @param id defines the id of the new skeleton
  19854. * @returns the new skeleton
  19855. */
  19856. clone(name: string, id: string): Skeleton;
  19857. /**
  19858. * Enable animation blending for this skeleton
  19859. * @param blendingSpeed defines the blending speed to apply
  19860. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19861. */
  19862. enableBlending(blendingSpeed?: number): void;
  19863. /**
  19864. * Releases all resources associated with the current skeleton
  19865. */
  19866. dispose(): void;
  19867. /**
  19868. * Serialize the skeleton in a JSON object
  19869. * @returns a JSON object
  19870. */
  19871. serialize(): any;
  19872. /**
  19873. * Creates a new skeleton from serialized data
  19874. * @param parsedSkeleton defines the serialized data
  19875. * @param scene defines the hosting scene
  19876. * @returns a new skeleton
  19877. */
  19878. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19879. /**
  19880. * Compute all node absolute transforms
  19881. * @param forceUpdate defines if computation must be done even if cache is up to date
  19882. */
  19883. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19884. /**
  19885. * Gets the root pose matrix
  19886. * @returns a matrix
  19887. */
  19888. getPoseMatrix(): Nullable<Matrix>;
  19889. /**
  19890. * Sorts bones per internal index
  19891. */
  19892. sortBones(): void;
  19893. private _sortBones;
  19894. }
  19895. }
  19896. declare module "babylonjs/Morph/morphTarget" {
  19897. import { IAnimatable } from "babylonjs/Misc/tools";
  19898. import { Observable } from "babylonjs/Misc/observable";
  19899. import { Nullable, FloatArray } from "babylonjs/types";
  19900. import { Scene } from "babylonjs/scene";
  19901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19902. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19903. /**
  19904. * Defines a target to use with MorphTargetManager
  19905. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19906. */
  19907. export class MorphTarget implements IAnimatable {
  19908. /** defines the name of the target */
  19909. name: string;
  19910. /**
  19911. * Gets or sets the list of animations
  19912. */
  19913. animations: import("babylonjs/Animations/animation").Animation[];
  19914. private _scene;
  19915. private _positions;
  19916. private _normals;
  19917. private _tangents;
  19918. private _influence;
  19919. /**
  19920. * Observable raised when the influence changes
  19921. */
  19922. onInfluenceChanged: Observable<boolean>;
  19923. /** @hidden */
  19924. _onDataLayoutChanged: Observable<void>;
  19925. /**
  19926. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19927. */
  19928. influence: number;
  19929. /**
  19930. * Gets or sets the id of the morph Target
  19931. */
  19932. id: string;
  19933. private _animationPropertiesOverride;
  19934. /**
  19935. * Gets or sets the animation properties override
  19936. */
  19937. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19938. /**
  19939. * Creates a new MorphTarget
  19940. * @param name defines the name of the target
  19941. * @param influence defines the influence to use
  19942. * @param scene defines the scene the morphtarget belongs to
  19943. */
  19944. constructor(
  19945. /** defines the name of the target */
  19946. name: string, influence?: number, scene?: Nullable<Scene>);
  19947. /**
  19948. * Gets a boolean defining if the target contains position data
  19949. */
  19950. readonly hasPositions: boolean;
  19951. /**
  19952. * Gets a boolean defining if the target contains normal data
  19953. */
  19954. readonly hasNormals: boolean;
  19955. /**
  19956. * Gets a boolean defining if the target contains tangent data
  19957. */
  19958. readonly hasTangents: boolean;
  19959. /**
  19960. * Affects position data to this target
  19961. * @param data defines the position data to use
  19962. */
  19963. setPositions(data: Nullable<FloatArray>): void;
  19964. /**
  19965. * Gets the position data stored in this target
  19966. * @returns a FloatArray containing the position data (or null if not present)
  19967. */
  19968. getPositions(): Nullable<FloatArray>;
  19969. /**
  19970. * Affects normal data to this target
  19971. * @param data defines the normal data to use
  19972. */
  19973. setNormals(data: Nullable<FloatArray>): void;
  19974. /**
  19975. * Gets the normal data stored in this target
  19976. * @returns a FloatArray containing the normal data (or null if not present)
  19977. */
  19978. getNormals(): Nullable<FloatArray>;
  19979. /**
  19980. * Affects tangent data to this target
  19981. * @param data defines the tangent data to use
  19982. */
  19983. setTangents(data: Nullable<FloatArray>): void;
  19984. /**
  19985. * Gets the tangent data stored in this target
  19986. * @returns a FloatArray containing the tangent data (or null if not present)
  19987. */
  19988. getTangents(): Nullable<FloatArray>;
  19989. /**
  19990. * Serializes the current target into a Serialization object
  19991. * @returns the serialized object
  19992. */
  19993. serialize(): any;
  19994. /**
  19995. * Returns the string "MorphTarget"
  19996. * @returns "MorphTarget"
  19997. */
  19998. getClassName(): string;
  19999. /**
  20000. * Creates a new target from serialized data
  20001. * @param serializationObject defines the serialized data to use
  20002. * @returns a new MorphTarget
  20003. */
  20004. static Parse(serializationObject: any): MorphTarget;
  20005. /**
  20006. * Creates a MorphTarget from mesh data
  20007. * @param mesh defines the source mesh
  20008. * @param name defines the name to use for the new target
  20009. * @param influence defines the influence to attach to the target
  20010. * @returns a new MorphTarget
  20011. */
  20012. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20013. }
  20014. }
  20015. declare module "babylonjs/Morph/morphTargetManager" {
  20016. import { Nullable } from "babylonjs/types";
  20017. import { Scene } from "babylonjs/scene";
  20018. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20019. /**
  20020. * This class is used to deform meshes using morphing between different targets
  20021. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20022. */
  20023. export class MorphTargetManager {
  20024. private _targets;
  20025. private _targetInfluenceChangedObservers;
  20026. private _targetDataLayoutChangedObservers;
  20027. private _activeTargets;
  20028. private _scene;
  20029. private _influences;
  20030. private _supportsNormals;
  20031. private _supportsTangents;
  20032. private _vertexCount;
  20033. private _uniqueId;
  20034. private _tempInfluences;
  20035. /**
  20036. * Creates a new MorphTargetManager
  20037. * @param scene defines the current scene
  20038. */
  20039. constructor(scene?: Nullable<Scene>);
  20040. /**
  20041. * Gets the unique ID of this manager
  20042. */
  20043. readonly uniqueId: number;
  20044. /**
  20045. * Gets the number of vertices handled by this manager
  20046. */
  20047. readonly vertexCount: number;
  20048. /**
  20049. * Gets a boolean indicating if this manager supports morphing of normals
  20050. */
  20051. readonly supportsNormals: boolean;
  20052. /**
  20053. * Gets a boolean indicating if this manager supports morphing of tangents
  20054. */
  20055. readonly supportsTangents: boolean;
  20056. /**
  20057. * Gets the number of targets stored in this manager
  20058. */
  20059. readonly numTargets: number;
  20060. /**
  20061. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20062. */
  20063. readonly numInfluencers: number;
  20064. /**
  20065. * Gets the list of influences (one per target)
  20066. */
  20067. readonly influences: Float32Array;
  20068. /**
  20069. * Gets the active target at specified index. An active target is a target with an influence > 0
  20070. * @param index defines the index to check
  20071. * @returns the requested target
  20072. */
  20073. getActiveTarget(index: number): MorphTarget;
  20074. /**
  20075. * Gets the target at specified index
  20076. * @param index defines the index to check
  20077. * @returns the requested target
  20078. */
  20079. getTarget(index: number): MorphTarget;
  20080. /**
  20081. * Add a new target to this manager
  20082. * @param target defines the target to add
  20083. */
  20084. addTarget(target: MorphTarget): void;
  20085. /**
  20086. * Removes a target from the manager
  20087. * @param target defines the target to remove
  20088. */
  20089. removeTarget(target: MorphTarget): void;
  20090. /**
  20091. * Serializes the current manager into a Serialization object
  20092. * @returns the serialized object
  20093. */
  20094. serialize(): any;
  20095. private _syncActiveTargets;
  20096. /**
  20097. * Syncrhonize the targets with all the meshes using this morph target manager
  20098. */
  20099. synchronize(): void;
  20100. /**
  20101. * Creates a new MorphTargetManager from serialized data
  20102. * @param serializationObject defines the serialized data
  20103. * @param scene defines the hosting scene
  20104. * @returns the new MorphTargetManager
  20105. */
  20106. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20107. }
  20108. }
  20109. declare module "babylonjs/Meshes/meshLODLevel" {
  20110. import { Mesh } from "babylonjs/Meshes/mesh";
  20111. import { Nullable } from "babylonjs/types";
  20112. /**
  20113. * Class used to represent a specific level of detail of a mesh
  20114. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20115. */
  20116. export class MeshLODLevel {
  20117. /** Defines the distance where this level should star being displayed */
  20118. distance: number;
  20119. /** Defines the mesh to use to render this level */
  20120. mesh: Nullable<Mesh>;
  20121. /**
  20122. * Creates a new LOD level
  20123. * @param distance defines the distance where this level should star being displayed
  20124. * @param mesh defines the mesh to use to render this level
  20125. */
  20126. constructor(
  20127. /** Defines the distance where this level should star being displayed */
  20128. distance: number,
  20129. /** Defines the mesh to use to render this level */
  20130. mesh: Nullable<Mesh>);
  20131. }
  20132. }
  20133. declare module "babylonjs/Meshes/groundMesh" {
  20134. import { Scene } from "babylonjs/scene";
  20135. import { Vector3 } from "babylonjs/Maths/math";
  20136. import { Mesh } from "babylonjs/Meshes/mesh";
  20137. /**
  20138. * Mesh representing the gorund
  20139. */
  20140. export class GroundMesh extends Mesh {
  20141. /** If octree should be generated */
  20142. generateOctree: boolean;
  20143. private _heightQuads;
  20144. /** @hidden */
  20145. _subdivisionsX: number;
  20146. /** @hidden */
  20147. _subdivisionsY: number;
  20148. /** @hidden */
  20149. _width: number;
  20150. /** @hidden */
  20151. _height: number;
  20152. /** @hidden */
  20153. _minX: number;
  20154. /** @hidden */
  20155. _maxX: number;
  20156. /** @hidden */
  20157. _minZ: number;
  20158. /** @hidden */
  20159. _maxZ: number;
  20160. constructor(name: string, scene: Scene);
  20161. /**
  20162. * "GroundMesh"
  20163. * @returns "GroundMesh"
  20164. */
  20165. getClassName(): string;
  20166. /**
  20167. * The minimum of x and y subdivisions
  20168. */
  20169. readonly subdivisions: number;
  20170. /**
  20171. * X subdivisions
  20172. */
  20173. readonly subdivisionsX: number;
  20174. /**
  20175. * Y subdivisions
  20176. */
  20177. readonly subdivisionsY: number;
  20178. /**
  20179. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20180. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20181. * @param chunksCount the number of subdivisions for x and y
  20182. * @param octreeBlocksSize (Default: 32)
  20183. */
  20184. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20185. /**
  20186. * Returns a height (y) value in the Worl system :
  20187. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20188. * @param x x coordinate
  20189. * @param z z coordinate
  20190. * @returns the ground y position if (x, z) are outside the ground surface.
  20191. */
  20192. getHeightAtCoordinates(x: number, z: number): number;
  20193. /**
  20194. * Returns a normalized vector (Vector3) orthogonal to the ground
  20195. * at the ground coordinates (x, z) expressed in the World system.
  20196. * @param x x coordinate
  20197. * @param z z coordinate
  20198. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20199. */
  20200. getNormalAtCoordinates(x: number, z: number): Vector3;
  20201. /**
  20202. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20203. * at the ground coordinates (x, z) expressed in the World system.
  20204. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20205. * @param x x coordinate
  20206. * @param z z coordinate
  20207. * @param ref vector to store the result
  20208. * @returns the GroundMesh.
  20209. */
  20210. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20211. /**
  20212. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20213. * if the ground has been updated.
  20214. * This can be used in the render loop.
  20215. * @returns the GroundMesh.
  20216. */
  20217. updateCoordinateHeights(): GroundMesh;
  20218. private _getFacetAt;
  20219. private _initHeightQuads;
  20220. private _computeHeightQuads;
  20221. /**
  20222. * Serializes this ground mesh
  20223. * @param serializationObject object to write serialization to
  20224. */
  20225. serialize(serializationObject: any): void;
  20226. /**
  20227. * Parses a serialized ground mesh
  20228. * @param parsedMesh the serialized mesh
  20229. * @param scene the scene to create the ground mesh in
  20230. * @returns the created ground mesh
  20231. */
  20232. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20233. }
  20234. }
  20235. declare module "babylonjs/Physics/physicsJoint" {
  20236. import { Vector3 } from "babylonjs/Maths/math";
  20237. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20238. /**
  20239. * Interface for Physics-Joint data
  20240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20241. */
  20242. export interface PhysicsJointData {
  20243. /**
  20244. * The main pivot of the joint
  20245. */
  20246. mainPivot?: Vector3;
  20247. /**
  20248. * The connected pivot of the joint
  20249. */
  20250. connectedPivot?: Vector3;
  20251. /**
  20252. * The main axis of the joint
  20253. */
  20254. mainAxis?: Vector3;
  20255. /**
  20256. * The connected axis of the joint
  20257. */
  20258. connectedAxis?: Vector3;
  20259. /**
  20260. * The collision of the joint
  20261. */
  20262. collision?: boolean;
  20263. /**
  20264. * Native Oimo/Cannon/Energy data
  20265. */
  20266. nativeParams?: any;
  20267. }
  20268. /**
  20269. * This is a holder class for the physics joint created by the physics plugin
  20270. * It holds a set of functions to control the underlying joint
  20271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20272. */
  20273. export class PhysicsJoint {
  20274. /**
  20275. * The type of the physics joint
  20276. */
  20277. type: number;
  20278. /**
  20279. * The data for the physics joint
  20280. */
  20281. jointData: PhysicsJointData;
  20282. private _physicsJoint;
  20283. protected _physicsPlugin: IPhysicsEnginePlugin;
  20284. /**
  20285. * Initializes the physics joint
  20286. * @param type The type of the physics joint
  20287. * @param jointData The data for the physics joint
  20288. */
  20289. constructor(
  20290. /**
  20291. * The type of the physics joint
  20292. */
  20293. type: number,
  20294. /**
  20295. * The data for the physics joint
  20296. */
  20297. jointData: PhysicsJointData);
  20298. /**
  20299. * Gets the physics joint
  20300. */
  20301. /**
  20302. * Sets the physics joint
  20303. */
  20304. physicsJoint: any;
  20305. /**
  20306. * Sets the physics plugin
  20307. */
  20308. physicsPlugin: IPhysicsEnginePlugin;
  20309. /**
  20310. * Execute a function that is physics-plugin specific.
  20311. * @param {Function} func the function that will be executed.
  20312. * It accepts two parameters: the physics world and the physics joint
  20313. */
  20314. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20315. /**
  20316. * Distance-Joint type
  20317. */
  20318. static DistanceJoint: number;
  20319. /**
  20320. * Hinge-Joint type
  20321. */
  20322. static HingeJoint: number;
  20323. /**
  20324. * Ball-and-Socket joint type
  20325. */
  20326. static BallAndSocketJoint: number;
  20327. /**
  20328. * Wheel-Joint type
  20329. */
  20330. static WheelJoint: number;
  20331. /**
  20332. * Slider-Joint type
  20333. */
  20334. static SliderJoint: number;
  20335. /**
  20336. * Prismatic-Joint type
  20337. */
  20338. static PrismaticJoint: number;
  20339. /**
  20340. * Universal-Joint type
  20341. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20342. */
  20343. static UniversalJoint: number;
  20344. /**
  20345. * Hinge-Joint 2 type
  20346. */
  20347. static Hinge2Joint: number;
  20348. /**
  20349. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20350. */
  20351. static PointToPointJoint: number;
  20352. /**
  20353. * Spring-Joint type
  20354. */
  20355. static SpringJoint: number;
  20356. /**
  20357. * Lock-Joint type
  20358. */
  20359. static LockJoint: number;
  20360. }
  20361. /**
  20362. * A class representing a physics distance joint
  20363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20364. */
  20365. export class DistanceJoint extends PhysicsJoint {
  20366. /**
  20367. *
  20368. * @param jointData The data for the Distance-Joint
  20369. */
  20370. constructor(jointData: DistanceJointData);
  20371. /**
  20372. * Update the predefined distance.
  20373. * @param maxDistance The maximum preferred distance
  20374. * @param minDistance The minimum preferred distance
  20375. */
  20376. updateDistance(maxDistance: number, minDistance?: number): void;
  20377. }
  20378. /**
  20379. * Represents a Motor-Enabled Joint
  20380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20381. */
  20382. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20383. /**
  20384. * Initializes the Motor-Enabled Joint
  20385. * @param type The type of the joint
  20386. * @param jointData The physica joint data for the joint
  20387. */
  20388. constructor(type: number, jointData: PhysicsJointData);
  20389. /**
  20390. * Set the motor values.
  20391. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20392. * @param force the force to apply
  20393. * @param maxForce max force for this motor.
  20394. */
  20395. setMotor(force?: number, maxForce?: number): void;
  20396. /**
  20397. * Set the motor's limits.
  20398. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20399. * @param upperLimit The upper limit of the motor
  20400. * @param lowerLimit The lower limit of the motor
  20401. */
  20402. setLimit(upperLimit: number, lowerLimit?: number): void;
  20403. }
  20404. /**
  20405. * This class represents a single physics Hinge-Joint
  20406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20407. */
  20408. export class HingeJoint extends MotorEnabledJoint {
  20409. /**
  20410. * Initializes the Hinge-Joint
  20411. * @param jointData The joint data for the Hinge-Joint
  20412. */
  20413. constructor(jointData: PhysicsJointData);
  20414. /**
  20415. * Set the motor values.
  20416. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20417. * @param {number} force the force to apply
  20418. * @param {number} maxForce max force for this motor.
  20419. */
  20420. setMotor(force?: number, maxForce?: number): void;
  20421. /**
  20422. * Set the motor's limits.
  20423. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20424. * @param upperLimit The upper limit of the motor
  20425. * @param lowerLimit The lower limit of the motor
  20426. */
  20427. setLimit(upperLimit: number, lowerLimit?: number): void;
  20428. }
  20429. /**
  20430. * This class represents a dual hinge physics joint (same as wheel joint)
  20431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20432. */
  20433. export class Hinge2Joint extends MotorEnabledJoint {
  20434. /**
  20435. * Initializes the Hinge2-Joint
  20436. * @param jointData The joint data for the Hinge2-Joint
  20437. */
  20438. constructor(jointData: PhysicsJointData);
  20439. /**
  20440. * Set the motor values.
  20441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20442. * @param {number} targetSpeed the speed the motor is to reach
  20443. * @param {number} maxForce max force for this motor.
  20444. * @param {motorIndex} the motor's index, 0 or 1.
  20445. */
  20446. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20447. /**
  20448. * Set the motor limits.
  20449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20450. * @param {number} upperLimit the upper limit
  20451. * @param {number} lowerLimit lower limit
  20452. * @param {motorIndex} the motor's index, 0 or 1.
  20453. */
  20454. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20455. }
  20456. /**
  20457. * Interface for a motor enabled joint
  20458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20459. */
  20460. export interface IMotorEnabledJoint {
  20461. /**
  20462. * Physics joint
  20463. */
  20464. physicsJoint: any;
  20465. /**
  20466. * Sets the motor of the motor-enabled joint
  20467. * @param force The force of the motor
  20468. * @param maxForce The maximum force of the motor
  20469. * @param motorIndex The index of the motor
  20470. */
  20471. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20472. /**
  20473. * Sets the limit of the motor
  20474. * @param upperLimit The upper limit of the motor
  20475. * @param lowerLimit The lower limit of the motor
  20476. * @param motorIndex The index of the motor
  20477. */
  20478. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20479. }
  20480. /**
  20481. * Joint data for a Distance-Joint
  20482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20483. */
  20484. export interface DistanceJointData extends PhysicsJointData {
  20485. /**
  20486. * Max distance the 2 joint objects can be apart
  20487. */
  20488. maxDistance: number;
  20489. }
  20490. /**
  20491. * Joint data from a spring joint
  20492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20493. */
  20494. export interface SpringJointData extends PhysicsJointData {
  20495. /**
  20496. * Length of the spring
  20497. */
  20498. length: number;
  20499. /**
  20500. * Stiffness of the spring
  20501. */
  20502. stiffness: number;
  20503. /**
  20504. * Damping of the spring
  20505. */
  20506. damping: number;
  20507. /** this callback will be called when applying the force to the impostors. */
  20508. forceApplicationCallback: () => void;
  20509. }
  20510. }
  20511. declare module "babylonjs/Physics/physicsRaycastResult" {
  20512. import { Vector3 } from "babylonjs/Maths/math";
  20513. /**
  20514. * Holds the data for the raycast result
  20515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20516. */
  20517. export class PhysicsRaycastResult {
  20518. private _hasHit;
  20519. private _hitDistance;
  20520. private _hitNormalWorld;
  20521. private _hitPointWorld;
  20522. private _rayFromWorld;
  20523. private _rayToWorld;
  20524. /**
  20525. * Gets if there was a hit
  20526. */
  20527. readonly hasHit: boolean;
  20528. /**
  20529. * Gets the distance from the hit
  20530. */
  20531. readonly hitDistance: number;
  20532. /**
  20533. * Gets the hit normal/direction in the world
  20534. */
  20535. readonly hitNormalWorld: Vector3;
  20536. /**
  20537. * Gets the hit point in the world
  20538. */
  20539. readonly hitPointWorld: Vector3;
  20540. /**
  20541. * Gets the ray "start point" of the ray in the world
  20542. */
  20543. readonly rayFromWorld: Vector3;
  20544. /**
  20545. * Gets the ray "end point" of the ray in the world
  20546. */
  20547. readonly rayToWorld: Vector3;
  20548. /**
  20549. * Sets the hit data (normal & point in world space)
  20550. * @param hitNormalWorld defines the normal in world space
  20551. * @param hitPointWorld defines the point in world space
  20552. */
  20553. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20554. /**
  20555. * Sets the distance from the start point to the hit point
  20556. * @param distance
  20557. */
  20558. setHitDistance(distance: number): void;
  20559. /**
  20560. * Calculates the distance manually
  20561. */
  20562. calculateHitDistance(): void;
  20563. /**
  20564. * Resets all the values to default
  20565. * @param from The from point on world space
  20566. * @param to The to point on world space
  20567. */
  20568. reset(from?: Vector3, to?: Vector3): void;
  20569. }
  20570. /**
  20571. * Interface for the size containing width and height
  20572. */
  20573. interface IXYZ {
  20574. /**
  20575. * X
  20576. */
  20577. x: number;
  20578. /**
  20579. * Y
  20580. */
  20581. y: number;
  20582. /**
  20583. * Z
  20584. */
  20585. z: number;
  20586. }
  20587. }
  20588. declare module "babylonjs/Physics/IPhysicsEngine" {
  20589. import { Nullable } from "babylonjs/types";
  20590. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20592. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20593. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20594. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20595. /**
  20596. * Interface used to describe a physics joint
  20597. */
  20598. export interface PhysicsImpostorJoint {
  20599. /** Defines the main impostor to which the joint is linked */
  20600. mainImpostor: PhysicsImpostor;
  20601. /** Defines the impostor that is connected to the main impostor using this joint */
  20602. connectedImpostor: PhysicsImpostor;
  20603. /** Defines the joint itself */
  20604. joint: PhysicsJoint;
  20605. }
  20606. /** @hidden */
  20607. export interface IPhysicsEnginePlugin {
  20608. world: any;
  20609. name: string;
  20610. setGravity(gravity: Vector3): void;
  20611. setTimeStep(timeStep: number): void;
  20612. getTimeStep(): number;
  20613. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20615. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20617. removePhysicsBody(impostor: PhysicsImpostor): void;
  20618. generateJoint(joint: PhysicsImpostorJoint): void;
  20619. removeJoint(joint: PhysicsImpostorJoint): void;
  20620. isSupported(): boolean;
  20621. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20622. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20623. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20624. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20625. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20626. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20627. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20628. getBodyMass(impostor: PhysicsImpostor): number;
  20629. getBodyFriction(impostor: PhysicsImpostor): number;
  20630. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20631. getBodyRestitution(impostor: PhysicsImpostor): number;
  20632. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20633. getBodyPressure?(impostor: PhysicsImpostor): number;
  20634. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20635. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20636. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20637. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20638. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20639. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20640. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20641. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20642. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20643. sleepBody(impostor: PhysicsImpostor): void;
  20644. wakeUpBody(impostor: PhysicsImpostor): void;
  20645. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20646. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20647. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20649. getRadius(impostor: PhysicsImpostor): number;
  20650. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20651. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20652. dispose(): void;
  20653. }
  20654. /**
  20655. * Interface used to define a physics engine
  20656. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20657. */
  20658. export interface IPhysicsEngine {
  20659. /**
  20660. * Gets the gravity vector used by the simulation
  20661. */
  20662. gravity: Vector3;
  20663. /**
  20664. * Sets the gravity vector used by the simulation
  20665. * @param gravity defines the gravity vector to use
  20666. */
  20667. setGravity(gravity: Vector3): void;
  20668. /**
  20669. * Set the time step of the physics engine.
  20670. * Default is 1/60.
  20671. * To slow it down, enter 1/600 for example.
  20672. * To speed it up, 1/30
  20673. * @param newTimeStep the new timestep to apply to this world.
  20674. */
  20675. setTimeStep(newTimeStep: number): void;
  20676. /**
  20677. * Get the time step of the physics engine.
  20678. * @returns the current time step
  20679. */
  20680. getTimeStep(): number;
  20681. /**
  20682. * Release all resources
  20683. */
  20684. dispose(): void;
  20685. /**
  20686. * Gets the name of the current physics plugin
  20687. * @returns the name of the plugin
  20688. */
  20689. getPhysicsPluginName(): string;
  20690. /**
  20691. * Adding a new impostor for the impostor tracking.
  20692. * This will be done by the impostor itself.
  20693. * @param impostor the impostor to add
  20694. */
  20695. addImpostor(impostor: PhysicsImpostor): void;
  20696. /**
  20697. * Remove an impostor from the engine.
  20698. * This impostor and its mesh will not longer be updated by the physics engine.
  20699. * @param impostor the impostor to remove
  20700. */
  20701. removeImpostor(impostor: PhysicsImpostor): void;
  20702. /**
  20703. * Add a joint to the physics engine
  20704. * @param mainImpostor defines the main impostor to which the joint is added.
  20705. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20706. * @param joint defines the joint that will connect both impostors.
  20707. */
  20708. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20709. /**
  20710. * Removes a joint from the simulation
  20711. * @param mainImpostor defines the impostor used with the joint
  20712. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20713. * @param joint defines the joint to remove
  20714. */
  20715. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20716. /**
  20717. * Gets the current plugin used to run the simulation
  20718. * @returns current plugin
  20719. */
  20720. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20721. /**
  20722. * Gets the list of physic impostors
  20723. * @returns an array of PhysicsImpostor
  20724. */
  20725. getImpostors(): Array<PhysicsImpostor>;
  20726. /**
  20727. * Gets the impostor for a physics enabled object
  20728. * @param object defines the object impersonated by the impostor
  20729. * @returns the PhysicsImpostor or null if not found
  20730. */
  20731. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20732. /**
  20733. * Gets the impostor for a physics body object
  20734. * @param body defines physics body used by the impostor
  20735. * @returns the PhysicsImpostor or null if not found
  20736. */
  20737. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20738. /**
  20739. * Does a raycast in the physics world
  20740. * @param from when should the ray start?
  20741. * @param to when should the ray end?
  20742. * @returns PhysicsRaycastResult
  20743. */
  20744. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20745. /**
  20746. * Called by the scene. No need to call it.
  20747. * @param delta defines the timespam between frames
  20748. */
  20749. _step(delta: number): void;
  20750. }
  20751. }
  20752. declare module "babylonjs/Physics/physicsImpostor" {
  20753. import { Nullable, IndicesArray } from "babylonjs/types";
  20754. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20755. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20757. import { Scene } from "babylonjs/scene";
  20758. import { Bone } from "babylonjs/Bones/bone";
  20759. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20760. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20761. /**
  20762. * The interface for the physics imposter parameters
  20763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20764. */
  20765. export interface PhysicsImpostorParameters {
  20766. /**
  20767. * The mass of the physics imposter
  20768. */
  20769. mass: number;
  20770. /**
  20771. * The friction of the physics imposter
  20772. */
  20773. friction?: number;
  20774. /**
  20775. * The coefficient of restitution of the physics imposter
  20776. */
  20777. restitution?: number;
  20778. /**
  20779. * The native options of the physics imposter
  20780. */
  20781. nativeOptions?: any;
  20782. /**
  20783. * Specifies if the parent should be ignored
  20784. */
  20785. ignoreParent?: boolean;
  20786. /**
  20787. * Specifies if bi-directional transformations should be disabled
  20788. */
  20789. disableBidirectionalTransformation?: boolean;
  20790. /**
  20791. * The pressure inside the physics imposter, soft object only
  20792. */
  20793. pressure?: number;
  20794. /**
  20795. * The stiffness the physics imposter, soft object only
  20796. */
  20797. stiffness?: number;
  20798. /**
  20799. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20800. */
  20801. velocityIterations?: number;
  20802. /**
  20803. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20804. */
  20805. positionIterations?: number;
  20806. /**
  20807. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20808. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20809. * Add to fix multiple points
  20810. */
  20811. fixedPoints?: number;
  20812. /**
  20813. * The collision margin around a soft object
  20814. */
  20815. margin?: number;
  20816. /**
  20817. * The collision margin around a soft object
  20818. */
  20819. damping?: number;
  20820. /**
  20821. * The path for a rope based on an extrusion
  20822. */
  20823. path?: any;
  20824. /**
  20825. * The shape of an extrusion used for a rope based on an extrusion
  20826. */
  20827. shape?: any;
  20828. }
  20829. /**
  20830. * Interface for a physics-enabled object
  20831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20832. */
  20833. export interface IPhysicsEnabledObject {
  20834. /**
  20835. * The position of the physics-enabled object
  20836. */
  20837. position: Vector3;
  20838. /**
  20839. * The rotation of the physics-enabled object
  20840. */
  20841. rotationQuaternion: Nullable<Quaternion>;
  20842. /**
  20843. * The scale of the physics-enabled object
  20844. */
  20845. scaling: Vector3;
  20846. /**
  20847. * The rotation of the physics-enabled object
  20848. */
  20849. rotation?: Vector3;
  20850. /**
  20851. * The parent of the physics-enabled object
  20852. */
  20853. parent?: any;
  20854. /**
  20855. * The bounding info of the physics-enabled object
  20856. * @returns The bounding info of the physics-enabled object
  20857. */
  20858. getBoundingInfo(): BoundingInfo;
  20859. /**
  20860. * Computes the world matrix
  20861. * @param force Specifies if the world matrix should be computed by force
  20862. * @returns A world matrix
  20863. */
  20864. computeWorldMatrix(force: boolean): Matrix;
  20865. /**
  20866. * Gets the world matrix
  20867. * @returns A world matrix
  20868. */
  20869. getWorldMatrix?(): Matrix;
  20870. /**
  20871. * Gets the child meshes
  20872. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20873. * @returns An array of abstract meshes
  20874. */
  20875. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20876. /**
  20877. * Gets the vertex data
  20878. * @param kind The type of vertex data
  20879. * @returns A nullable array of numbers, or a float32 array
  20880. */
  20881. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20882. /**
  20883. * Gets the indices from the mesh
  20884. * @returns A nullable array of index arrays
  20885. */
  20886. getIndices?(): Nullable<IndicesArray>;
  20887. /**
  20888. * Gets the scene from the mesh
  20889. * @returns the indices array or null
  20890. */
  20891. getScene?(): Scene;
  20892. /**
  20893. * Gets the absolute position from the mesh
  20894. * @returns the absolute position
  20895. */
  20896. getAbsolutePosition(): Vector3;
  20897. /**
  20898. * Gets the absolute pivot point from the mesh
  20899. * @returns the absolute pivot point
  20900. */
  20901. getAbsolutePivotPoint(): Vector3;
  20902. /**
  20903. * Rotates the mesh
  20904. * @param axis The axis of rotation
  20905. * @param amount The amount of rotation
  20906. * @param space The space of the rotation
  20907. * @returns The rotation transform node
  20908. */
  20909. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20910. /**
  20911. * Translates the mesh
  20912. * @param axis The axis of translation
  20913. * @param distance The distance of translation
  20914. * @param space The space of the translation
  20915. * @returns The transform node
  20916. */
  20917. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20918. /**
  20919. * Sets the absolute position of the mesh
  20920. * @param absolutePosition The absolute position of the mesh
  20921. * @returns The transform node
  20922. */
  20923. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20924. /**
  20925. * Gets the class name of the mesh
  20926. * @returns The class name
  20927. */
  20928. getClassName(): string;
  20929. }
  20930. /**
  20931. * Represents a physics imposter
  20932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20933. */
  20934. export class PhysicsImpostor {
  20935. /**
  20936. * The physics-enabled object used as the physics imposter
  20937. */
  20938. object: IPhysicsEnabledObject;
  20939. /**
  20940. * The type of the physics imposter
  20941. */
  20942. type: number;
  20943. private _options;
  20944. private _scene?;
  20945. /**
  20946. * The default object size of the imposter
  20947. */
  20948. static DEFAULT_OBJECT_SIZE: Vector3;
  20949. /**
  20950. * The identity quaternion of the imposter
  20951. */
  20952. static IDENTITY_QUATERNION: Quaternion;
  20953. /** @hidden */
  20954. _pluginData: any;
  20955. private _physicsEngine;
  20956. private _physicsBody;
  20957. private _bodyUpdateRequired;
  20958. private _onBeforePhysicsStepCallbacks;
  20959. private _onAfterPhysicsStepCallbacks;
  20960. /** @hidden */
  20961. _onPhysicsCollideCallbacks: Array<{
  20962. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20963. otherImpostors: Array<PhysicsImpostor>;
  20964. }>;
  20965. private _deltaPosition;
  20966. private _deltaRotation;
  20967. private _deltaRotationConjugated;
  20968. /** hidden */
  20969. _isFromLine: boolean;
  20970. private _parent;
  20971. private _isDisposed;
  20972. private static _tmpVecs;
  20973. private static _tmpQuat;
  20974. /**
  20975. * Specifies if the physics imposter is disposed
  20976. */
  20977. readonly isDisposed: boolean;
  20978. /**
  20979. * Gets the mass of the physics imposter
  20980. */
  20981. mass: number;
  20982. /**
  20983. * Gets the coefficient of friction
  20984. */
  20985. /**
  20986. * Sets the coefficient of friction
  20987. */
  20988. friction: number;
  20989. /**
  20990. * Gets the coefficient of restitution
  20991. */
  20992. /**
  20993. * Sets the coefficient of restitution
  20994. */
  20995. restitution: number;
  20996. /**
  20997. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20998. */
  20999. /**
  21000. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21001. */
  21002. pressure: number;
  21003. /**
  21004. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21005. */
  21006. /**
  21007. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21008. */
  21009. stiffness: number;
  21010. /**
  21011. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21012. */
  21013. /**
  21014. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21015. */
  21016. velocityIterations: number;
  21017. /**
  21018. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21019. */
  21020. /**
  21021. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21022. */
  21023. positionIterations: number;
  21024. /**
  21025. * The unique id of the physics imposter
  21026. * set by the physics engine when adding this impostor to the array
  21027. */
  21028. uniqueId: number;
  21029. /**
  21030. * @hidden
  21031. */
  21032. soft: boolean;
  21033. /**
  21034. * @hidden
  21035. */
  21036. segments: number;
  21037. private _joints;
  21038. /**
  21039. * Initializes the physics imposter
  21040. * @param object The physics-enabled object used as the physics imposter
  21041. * @param type The type of the physics imposter
  21042. * @param _options The options for the physics imposter
  21043. * @param _scene The Babylon scene
  21044. */
  21045. constructor(
  21046. /**
  21047. * The physics-enabled object used as the physics imposter
  21048. */
  21049. object: IPhysicsEnabledObject,
  21050. /**
  21051. * The type of the physics imposter
  21052. */
  21053. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21054. /**
  21055. * This function will completly initialize this impostor.
  21056. * It will create a new body - but only if this mesh has no parent.
  21057. * If it has, this impostor will not be used other than to define the impostor
  21058. * of the child mesh.
  21059. * @hidden
  21060. */
  21061. _init(): void;
  21062. private _getPhysicsParent;
  21063. /**
  21064. * Should a new body be generated.
  21065. * @returns boolean specifying if body initialization is required
  21066. */
  21067. isBodyInitRequired(): boolean;
  21068. /**
  21069. * Sets the updated scaling
  21070. * @param updated Specifies if the scaling is updated
  21071. */
  21072. setScalingUpdated(): void;
  21073. /**
  21074. * Force a regeneration of this or the parent's impostor's body.
  21075. * Use under cautious - This will remove all joints already implemented.
  21076. */
  21077. forceUpdate(): void;
  21078. /**
  21079. * Gets the body that holds this impostor. Either its own, or its parent.
  21080. */
  21081. /**
  21082. * Set the physics body. Used mainly by the physics engine/plugin
  21083. */
  21084. physicsBody: any;
  21085. /**
  21086. * Get the parent of the physics imposter
  21087. * @returns Physics imposter or null
  21088. */
  21089. /**
  21090. * Sets the parent of the physics imposter
  21091. */
  21092. parent: Nullable<PhysicsImpostor>;
  21093. /**
  21094. * Resets the update flags
  21095. */
  21096. resetUpdateFlags(): void;
  21097. /**
  21098. * Gets the object extend size
  21099. * @returns the object extend size
  21100. */
  21101. getObjectExtendSize(): Vector3;
  21102. /**
  21103. * Gets the object center
  21104. * @returns The object center
  21105. */
  21106. getObjectCenter(): Vector3;
  21107. /**
  21108. * Get a specific parametes from the options parameter
  21109. * @param paramName The object parameter name
  21110. * @returns The object parameter
  21111. */
  21112. getParam(paramName: string): any;
  21113. /**
  21114. * Sets a specific parameter in the options given to the physics plugin
  21115. * @param paramName The parameter name
  21116. * @param value The value of the parameter
  21117. */
  21118. setParam(paramName: string, value: number): void;
  21119. /**
  21120. * Specifically change the body's mass option. Won't recreate the physics body object
  21121. * @param mass The mass of the physics imposter
  21122. */
  21123. setMass(mass: number): void;
  21124. /**
  21125. * Gets the linear velocity
  21126. * @returns linear velocity or null
  21127. */
  21128. getLinearVelocity(): Nullable<Vector3>;
  21129. /**
  21130. * Sets the linear velocity
  21131. * @param velocity linear velocity or null
  21132. */
  21133. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21134. /**
  21135. * Gets the angular velocity
  21136. * @returns angular velocity or null
  21137. */
  21138. getAngularVelocity(): Nullable<Vector3>;
  21139. /**
  21140. * Sets the angular velocity
  21141. * @param velocity The velocity or null
  21142. */
  21143. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21144. /**
  21145. * Execute a function with the physics plugin native code
  21146. * Provide a function the will have two variables - the world object and the physics body object
  21147. * @param func The function to execute with the physics plugin native code
  21148. */
  21149. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21150. /**
  21151. * Register a function that will be executed before the physics world is stepping forward
  21152. * @param func The function to execute before the physics world is stepped forward
  21153. */
  21154. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21155. /**
  21156. * Unregister a function that will be executed before the physics world is stepping forward
  21157. * @param func The function to execute before the physics world is stepped forward
  21158. */
  21159. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21160. /**
  21161. * Register a function that will be executed after the physics step
  21162. * @param func The function to execute after physics step
  21163. */
  21164. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21165. /**
  21166. * Unregisters a function that will be executed after the physics step
  21167. * @param func The function to execute after physics step
  21168. */
  21169. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21170. /**
  21171. * register a function that will be executed when this impostor collides against a different body
  21172. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21173. * @param func Callback that is executed on collision
  21174. */
  21175. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21176. /**
  21177. * Unregisters the physics imposter on contact
  21178. * @param collideAgainst The physics object to collide against
  21179. * @param func Callback to execute on collision
  21180. */
  21181. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21182. private _tmpQuat;
  21183. private _tmpQuat2;
  21184. /**
  21185. * Get the parent rotation
  21186. * @returns The parent rotation
  21187. */
  21188. getParentsRotation(): Quaternion;
  21189. /**
  21190. * this function is executed by the physics engine.
  21191. */
  21192. beforeStep: () => void;
  21193. /**
  21194. * this function is executed by the physics engine
  21195. */
  21196. afterStep: () => void;
  21197. /**
  21198. * Legacy collision detection event support
  21199. */
  21200. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21201. /**
  21202. * event and body object due to cannon's event-based architecture.
  21203. */
  21204. onCollide: (e: {
  21205. body: any;
  21206. }) => void;
  21207. /**
  21208. * Apply a force
  21209. * @param force The force to apply
  21210. * @param contactPoint The contact point for the force
  21211. * @returns The physics imposter
  21212. */
  21213. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21214. /**
  21215. * Apply an impulse
  21216. * @param force The impulse force
  21217. * @param contactPoint The contact point for the impulse force
  21218. * @returns The physics imposter
  21219. */
  21220. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21221. /**
  21222. * A help function to create a joint
  21223. * @param otherImpostor A physics imposter used to create a joint
  21224. * @param jointType The type of joint
  21225. * @param jointData The data for the joint
  21226. * @returns The physics imposter
  21227. */
  21228. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21229. /**
  21230. * Add a joint to this impostor with a different impostor
  21231. * @param otherImpostor A physics imposter used to add a joint
  21232. * @param joint The joint to add
  21233. * @returns The physics imposter
  21234. */
  21235. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21236. /**
  21237. * Add an anchor to a cloth impostor
  21238. * @param otherImpostor rigid impostor to anchor to
  21239. * @param width ratio across width from 0 to 1
  21240. * @param height ratio up height from 0 to 1
  21241. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21242. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21243. * @returns impostor the soft imposter
  21244. */
  21245. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21246. /**
  21247. * Add a hook to a rope impostor
  21248. * @param otherImpostor rigid impostor to anchor to
  21249. * @param length ratio across rope from 0 to 1
  21250. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21251. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21252. * @returns impostor the rope imposter
  21253. */
  21254. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21255. /**
  21256. * Will keep this body still, in a sleep mode.
  21257. * @returns the physics imposter
  21258. */
  21259. sleep(): PhysicsImpostor;
  21260. /**
  21261. * Wake the body up.
  21262. * @returns The physics imposter
  21263. */
  21264. wakeUp(): PhysicsImpostor;
  21265. /**
  21266. * Clones the physics imposter
  21267. * @param newObject The physics imposter clones to this physics-enabled object
  21268. * @returns A nullable physics imposter
  21269. */
  21270. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21271. /**
  21272. * Disposes the physics imposter
  21273. */
  21274. dispose(): void;
  21275. /**
  21276. * Sets the delta position
  21277. * @param position The delta position amount
  21278. */
  21279. setDeltaPosition(position: Vector3): void;
  21280. /**
  21281. * Sets the delta rotation
  21282. * @param rotation The delta rotation amount
  21283. */
  21284. setDeltaRotation(rotation: Quaternion): void;
  21285. /**
  21286. * Gets the box size of the physics imposter and stores the result in the input parameter
  21287. * @param result Stores the box size
  21288. * @returns The physics imposter
  21289. */
  21290. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21291. /**
  21292. * Gets the radius of the physics imposter
  21293. * @returns Radius of the physics imposter
  21294. */
  21295. getRadius(): number;
  21296. /**
  21297. * Sync a bone with this impostor
  21298. * @param bone The bone to sync to the impostor.
  21299. * @param boneMesh The mesh that the bone is influencing.
  21300. * @param jointPivot The pivot of the joint / bone in local space.
  21301. * @param distToJoint Optional distance from the impostor to the joint.
  21302. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21303. */
  21304. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21305. /**
  21306. * Sync impostor to a bone
  21307. * @param bone The bone that the impostor will be synced to.
  21308. * @param boneMesh The mesh that the bone is influencing.
  21309. * @param jointPivot The pivot of the joint / bone in local space.
  21310. * @param distToJoint Optional distance from the impostor to the joint.
  21311. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21312. * @param boneAxis Optional vector3 axis the bone is aligned with
  21313. */
  21314. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21315. /**
  21316. * No-Imposter type
  21317. */
  21318. static NoImpostor: number;
  21319. /**
  21320. * Sphere-Imposter type
  21321. */
  21322. static SphereImpostor: number;
  21323. /**
  21324. * Box-Imposter type
  21325. */
  21326. static BoxImpostor: number;
  21327. /**
  21328. * Plane-Imposter type
  21329. */
  21330. static PlaneImpostor: number;
  21331. /**
  21332. * Mesh-imposter type
  21333. */
  21334. static MeshImpostor: number;
  21335. /**
  21336. * Cylinder-Imposter type
  21337. */
  21338. static CylinderImpostor: number;
  21339. /**
  21340. * Particle-Imposter type
  21341. */
  21342. static ParticleImpostor: number;
  21343. /**
  21344. * Heightmap-Imposter type
  21345. */
  21346. static HeightmapImpostor: number;
  21347. /**
  21348. * ConvexHull-Impostor type (Ammo.js plugin only)
  21349. */
  21350. static ConvexHullImpostor: number;
  21351. /**
  21352. * Rope-Imposter type
  21353. */
  21354. static RopeImpostor: number;
  21355. /**
  21356. * Cloth-Imposter type
  21357. */
  21358. static ClothImpostor: number;
  21359. /**
  21360. * Softbody-Imposter type
  21361. */
  21362. static SoftbodyImpostor: number;
  21363. }
  21364. }
  21365. declare module "babylonjs/Meshes/mesh" {
  21366. import { Observable } from "babylonjs/Misc/observable";
  21367. import { IAnimatable } from "babylonjs/Misc/tools";
  21368. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21369. import { Camera } from "babylonjs/Cameras/camera";
  21370. import { Scene } from "babylonjs/scene";
  21371. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21372. import { Engine } from "babylonjs/Engines/engine";
  21373. import { Node } from "babylonjs/node";
  21374. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21375. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21376. import { Buffer } from "babylonjs/Meshes/buffer";
  21377. import { Geometry } from "babylonjs/Meshes/geometry";
  21378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21379. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21380. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21381. import { Effect } from "babylonjs/Materials/effect";
  21382. import { Material } from "babylonjs/Materials/material";
  21383. import { Skeleton } from "babylonjs/Bones/skeleton";
  21384. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21385. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21386. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21387. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21388. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21389. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21390. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21391. /**
  21392. * @hidden
  21393. **/
  21394. export class _CreationDataStorage {
  21395. closePath?: boolean;
  21396. closeArray?: boolean;
  21397. idx: number[];
  21398. dashSize: number;
  21399. gapSize: number;
  21400. path3D: Path3D;
  21401. pathArray: Vector3[][];
  21402. arc: number;
  21403. radius: number;
  21404. cap: number;
  21405. tessellation: number;
  21406. }
  21407. /**
  21408. * @hidden
  21409. **/
  21410. class _InstanceDataStorage {
  21411. visibleInstances: any;
  21412. batchCache: _InstancesBatch;
  21413. instancesBufferSize: number;
  21414. instancesBuffer: Nullable<Buffer>;
  21415. instancesData: Float32Array;
  21416. overridenInstanceCount: number;
  21417. isFrozen: boolean;
  21418. previousBatch: _InstancesBatch;
  21419. hardwareInstancedRendering: boolean;
  21420. sideOrientation: number;
  21421. }
  21422. /**
  21423. * @hidden
  21424. **/
  21425. export class _InstancesBatch {
  21426. mustReturn: boolean;
  21427. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21428. renderSelf: boolean[];
  21429. hardwareInstancedRendering: boolean[];
  21430. }
  21431. /**
  21432. * Class used to represent renderable models
  21433. */
  21434. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21435. /**
  21436. * Mesh side orientation : usually the external or front surface
  21437. */
  21438. static readonly FRONTSIDE: number;
  21439. /**
  21440. * Mesh side orientation : usually the internal or back surface
  21441. */
  21442. static readonly BACKSIDE: number;
  21443. /**
  21444. * Mesh side orientation : both internal and external or front and back surfaces
  21445. */
  21446. static readonly DOUBLESIDE: number;
  21447. /**
  21448. * Mesh side orientation : by default, `FRONTSIDE`
  21449. */
  21450. static readonly DEFAULTSIDE: number;
  21451. /**
  21452. * Mesh cap setting : no cap
  21453. */
  21454. static readonly NO_CAP: number;
  21455. /**
  21456. * Mesh cap setting : one cap at the beginning of the mesh
  21457. */
  21458. static readonly CAP_START: number;
  21459. /**
  21460. * Mesh cap setting : one cap at the end of the mesh
  21461. */
  21462. static readonly CAP_END: number;
  21463. /**
  21464. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21465. */
  21466. static readonly CAP_ALL: number;
  21467. /**
  21468. * Gets the default side orientation.
  21469. * @param orientation the orientation to value to attempt to get
  21470. * @returns the default orientation
  21471. * @hidden
  21472. */
  21473. static _GetDefaultSideOrientation(orientation?: number): number;
  21474. private _onBeforeRenderObservable;
  21475. private _onBeforeBindObservable;
  21476. private _onAfterRenderObservable;
  21477. private _onBeforeDrawObservable;
  21478. /**
  21479. * An event triggered before rendering the mesh
  21480. */
  21481. readonly onBeforeRenderObservable: Observable<Mesh>;
  21482. /**
  21483. * An event triggered before binding the mesh
  21484. */
  21485. readonly onBeforeBindObservable: Observable<Mesh>;
  21486. /**
  21487. * An event triggered after rendering the mesh
  21488. */
  21489. readonly onAfterRenderObservable: Observable<Mesh>;
  21490. /**
  21491. * An event triggered before drawing the mesh
  21492. */
  21493. readonly onBeforeDrawObservable: Observable<Mesh>;
  21494. private _onBeforeDrawObserver;
  21495. /**
  21496. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21497. */
  21498. onBeforeDraw: () => void;
  21499. /**
  21500. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21501. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21502. */
  21503. delayLoadState: number;
  21504. /**
  21505. * Gets the list of instances created from this mesh
  21506. * it is not supposed to be modified manually.
  21507. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21508. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21509. */
  21510. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21511. /**
  21512. * Gets the file containing delay loading data for this mesh
  21513. */
  21514. delayLoadingFile: string;
  21515. /** @hidden */
  21516. _binaryInfo: any;
  21517. private _LODLevels;
  21518. /**
  21519. * User defined function used to change how LOD level selection is done
  21520. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21521. */
  21522. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21523. private _morphTargetManager;
  21524. /**
  21525. * Gets or sets the morph target manager
  21526. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21527. */
  21528. morphTargetManager: Nullable<MorphTargetManager>;
  21529. /** @hidden */
  21530. _creationDataStorage: Nullable<_CreationDataStorage>;
  21531. /** @hidden */
  21532. _geometry: Nullable<Geometry>;
  21533. /** @hidden */
  21534. _delayInfo: Array<string>;
  21535. /** @hidden */
  21536. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21537. /** @hidden */
  21538. _instanceDataStorage: _InstanceDataStorage;
  21539. private _effectiveMaterial;
  21540. /** @hidden */
  21541. _shouldGenerateFlatShading: boolean;
  21542. private _preActivateId;
  21543. /** @hidden */
  21544. _originalBuilderSideOrientation: number;
  21545. /**
  21546. * Use this property to change the original side orientation defined at construction time
  21547. */
  21548. overrideMaterialSideOrientation: Nullable<number>;
  21549. private _areNormalsFrozen;
  21550. private _sourcePositions;
  21551. private _sourceNormals;
  21552. private _source;
  21553. private meshMap;
  21554. /**
  21555. * Gets the source mesh (the one used to clone this one from)
  21556. */
  21557. readonly source: Nullable<Mesh>;
  21558. /**
  21559. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21560. */
  21561. isUnIndexed: boolean;
  21562. /**
  21563. * @constructor
  21564. * @param name The value used by scene.getMeshByName() to do a lookup.
  21565. * @param scene The scene to add this mesh to.
  21566. * @param parent The parent of this mesh, if it has one
  21567. * @param source An optional Mesh from which geometry is shared, cloned.
  21568. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21569. * When false, achieved by calling a clone(), also passing False.
  21570. * This will make creation of children, recursive.
  21571. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21572. */
  21573. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21574. /**
  21575. * Gets the class name
  21576. * @returns the string "Mesh".
  21577. */
  21578. getClassName(): string;
  21579. /** @hidden */
  21580. readonly _isMesh: boolean;
  21581. /**
  21582. * Returns a description of this mesh
  21583. * @param fullDetails define if full details about this mesh must be used
  21584. * @returns a descriptive string representing this mesh
  21585. */
  21586. toString(fullDetails?: boolean): string;
  21587. /** @hidden */
  21588. _unBindEffect(): void;
  21589. /**
  21590. * Gets a boolean indicating if this mesh has LOD
  21591. */
  21592. readonly hasLODLevels: boolean;
  21593. /**
  21594. * Gets the list of MeshLODLevel associated with the current mesh
  21595. * @returns an array of MeshLODLevel
  21596. */
  21597. getLODLevels(): MeshLODLevel[];
  21598. private _sortLODLevels;
  21599. /**
  21600. * Add a mesh as LOD level triggered at the given distance.
  21601. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21602. * @param distance The distance from the center of the object to show this level
  21603. * @param mesh The mesh to be added as LOD level (can be null)
  21604. * @return This mesh (for chaining)
  21605. */
  21606. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21607. /**
  21608. * Returns the LOD level mesh at the passed distance or null if not found.
  21609. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21610. * @param distance The distance from the center of the object to show this level
  21611. * @returns a Mesh or `null`
  21612. */
  21613. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21614. /**
  21615. * Remove a mesh from the LOD array
  21616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21617. * @param mesh defines the mesh to be removed
  21618. * @return This mesh (for chaining)
  21619. */
  21620. removeLODLevel(mesh: Mesh): Mesh;
  21621. /**
  21622. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21623. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21624. * @param camera defines the camera to use to compute distance
  21625. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21626. * @return This mesh (for chaining)
  21627. */
  21628. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21629. /**
  21630. * Gets the mesh internal Geometry object
  21631. */
  21632. readonly geometry: Nullable<Geometry>;
  21633. /**
  21634. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21635. * @returns the total number of vertices
  21636. */
  21637. getTotalVertices(): number;
  21638. /**
  21639. * Returns the content of an associated vertex buffer
  21640. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21641. * - VertexBuffer.PositionKind
  21642. * - VertexBuffer.UVKind
  21643. * - VertexBuffer.UV2Kind
  21644. * - VertexBuffer.UV3Kind
  21645. * - VertexBuffer.UV4Kind
  21646. * - VertexBuffer.UV5Kind
  21647. * - VertexBuffer.UV6Kind
  21648. * - VertexBuffer.ColorKind
  21649. * - VertexBuffer.MatricesIndicesKind
  21650. * - VertexBuffer.MatricesIndicesExtraKind
  21651. * - VertexBuffer.MatricesWeightsKind
  21652. * - VertexBuffer.MatricesWeightsExtraKind
  21653. * @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
  21654. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21655. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21656. */
  21657. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21658. /**
  21659. * Returns the mesh VertexBuffer object from the requested `kind`
  21660. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21661. * - VertexBuffer.PositionKind
  21662. * - VertexBuffer.UVKind
  21663. * - VertexBuffer.UV2Kind
  21664. * - VertexBuffer.UV3Kind
  21665. * - VertexBuffer.UV4Kind
  21666. * - VertexBuffer.UV5Kind
  21667. * - VertexBuffer.UV6Kind
  21668. * - VertexBuffer.ColorKind
  21669. * - VertexBuffer.MatricesIndicesKind
  21670. * - VertexBuffer.MatricesIndicesExtraKind
  21671. * - VertexBuffer.MatricesWeightsKind
  21672. * - VertexBuffer.MatricesWeightsExtraKind
  21673. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21674. */
  21675. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21676. /**
  21677. * Tests if a specific vertex buffer is associated with this mesh
  21678. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21679. * - VertexBuffer.PositionKind
  21680. * - VertexBuffer.UVKind
  21681. * - VertexBuffer.UV2Kind
  21682. * - VertexBuffer.UV3Kind
  21683. * - VertexBuffer.UV4Kind
  21684. * - VertexBuffer.UV5Kind
  21685. * - VertexBuffer.UV6Kind
  21686. * - VertexBuffer.ColorKind
  21687. * - VertexBuffer.MatricesIndicesKind
  21688. * - VertexBuffer.MatricesIndicesExtraKind
  21689. * - VertexBuffer.MatricesWeightsKind
  21690. * - VertexBuffer.MatricesWeightsExtraKind
  21691. * @returns a boolean
  21692. */
  21693. isVerticesDataPresent(kind: string): boolean;
  21694. /**
  21695. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21696. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21697. * - VertexBuffer.PositionKind
  21698. * - VertexBuffer.UVKind
  21699. * - VertexBuffer.UV2Kind
  21700. * - VertexBuffer.UV3Kind
  21701. * - VertexBuffer.UV4Kind
  21702. * - VertexBuffer.UV5Kind
  21703. * - VertexBuffer.UV6Kind
  21704. * - VertexBuffer.ColorKind
  21705. * - VertexBuffer.MatricesIndicesKind
  21706. * - VertexBuffer.MatricesIndicesExtraKind
  21707. * - VertexBuffer.MatricesWeightsKind
  21708. * - VertexBuffer.MatricesWeightsExtraKind
  21709. * @returns a boolean
  21710. */
  21711. isVertexBufferUpdatable(kind: string): boolean;
  21712. /**
  21713. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21714. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21715. * - VertexBuffer.PositionKind
  21716. * - VertexBuffer.UVKind
  21717. * - VertexBuffer.UV2Kind
  21718. * - VertexBuffer.UV3Kind
  21719. * - VertexBuffer.UV4Kind
  21720. * - VertexBuffer.UV5Kind
  21721. * - VertexBuffer.UV6Kind
  21722. * - VertexBuffer.ColorKind
  21723. * - VertexBuffer.MatricesIndicesKind
  21724. * - VertexBuffer.MatricesIndicesExtraKind
  21725. * - VertexBuffer.MatricesWeightsKind
  21726. * - VertexBuffer.MatricesWeightsExtraKind
  21727. * @returns an array of strings
  21728. */
  21729. getVerticesDataKinds(): string[];
  21730. /**
  21731. * Returns a positive integer : the total number of indices in this mesh geometry.
  21732. * @returns the numner of indices or zero if the mesh has no geometry.
  21733. */
  21734. getTotalIndices(): number;
  21735. /**
  21736. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21737. * @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.
  21738. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21739. * @returns the indices array or an empty array if the mesh has no geometry
  21740. */
  21741. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21742. readonly isBlocked: boolean;
  21743. /**
  21744. * Determine if the current mesh is ready to be rendered
  21745. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21746. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21747. * @returns true if all associated assets are ready (material, textures, shaders)
  21748. */
  21749. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21750. /**
  21751. * 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.
  21752. */
  21753. readonly areNormalsFrozen: boolean;
  21754. /**
  21755. * 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.
  21756. * @returns the current mesh
  21757. */
  21758. freezeNormals(): Mesh;
  21759. /**
  21760. * 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
  21761. * @returns the current mesh
  21762. */
  21763. unfreezeNormals(): Mesh;
  21764. /**
  21765. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21766. */
  21767. overridenInstanceCount: number;
  21768. /** @hidden */
  21769. _preActivate(): Mesh;
  21770. /** @hidden */
  21771. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21772. /** @hidden */
  21773. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21774. /**
  21775. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21776. * This means the mesh underlying bounding box and sphere are recomputed.
  21777. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21778. * @returns the current mesh
  21779. */
  21780. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21781. /** @hidden */
  21782. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21783. /**
  21784. * This function will subdivide the mesh into multiple submeshes
  21785. * @param count defines the expected number of submeshes
  21786. */
  21787. subdivide(count: number): void;
  21788. /**
  21789. * Copy a FloatArray into a specific associated vertex buffer
  21790. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21791. * - VertexBuffer.PositionKind
  21792. * - VertexBuffer.UVKind
  21793. * - VertexBuffer.UV2Kind
  21794. * - VertexBuffer.UV3Kind
  21795. * - VertexBuffer.UV4Kind
  21796. * - VertexBuffer.UV5Kind
  21797. * - VertexBuffer.UV6Kind
  21798. * - VertexBuffer.ColorKind
  21799. * - VertexBuffer.MatricesIndicesKind
  21800. * - VertexBuffer.MatricesIndicesExtraKind
  21801. * - VertexBuffer.MatricesWeightsKind
  21802. * - VertexBuffer.MatricesWeightsExtraKind
  21803. * @param data defines the data source
  21804. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21805. * @param stride defines the data stride size (can be null)
  21806. * @returns the current mesh
  21807. */
  21808. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21809. /**
  21810. * Flags an associated vertex buffer as updatable
  21811. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21812. * - VertexBuffer.PositionKind
  21813. * - VertexBuffer.UVKind
  21814. * - VertexBuffer.UV2Kind
  21815. * - VertexBuffer.UV3Kind
  21816. * - VertexBuffer.UV4Kind
  21817. * - VertexBuffer.UV5Kind
  21818. * - VertexBuffer.UV6Kind
  21819. * - VertexBuffer.ColorKind
  21820. * - VertexBuffer.MatricesIndicesKind
  21821. * - VertexBuffer.MatricesIndicesExtraKind
  21822. * - VertexBuffer.MatricesWeightsKind
  21823. * - VertexBuffer.MatricesWeightsExtraKind
  21824. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21825. */
  21826. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21827. /**
  21828. * Sets the mesh global Vertex Buffer
  21829. * @param buffer defines the buffer to use
  21830. * @returns the current mesh
  21831. */
  21832. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21833. /**
  21834. * Update a specific associated vertex buffer
  21835. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21836. * - VertexBuffer.PositionKind
  21837. * - VertexBuffer.UVKind
  21838. * - VertexBuffer.UV2Kind
  21839. * - VertexBuffer.UV3Kind
  21840. * - VertexBuffer.UV4Kind
  21841. * - VertexBuffer.UV5Kind
  21842. * - VertexBuffer.UV6Kind
  21843. * - VertexBuffer.ColorKind
  21844. * - VertexBuffer.MatricesIndicesKind
  21845. * - VertexBuffer.MatricesIndicesExtraKind
  21846. * - VertexBuffer.MatricesWeightsKind
  21847. * - VertexBuffer.MatricesWeightsExtraKind
  21848. * @param data defines the data source
  21849. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21850. * @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)
  21851. * @returns the current mesh
  21852. */
  21853. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21854. /**
  21855. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21856. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21857. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21858. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21859. * @returns the current mesh
  21860. */
  21861. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21862. /**
  21863. * Creates a un-shared specific occurence of the geometry for the mesh.
  21864. * @returns the current mesh
  21865. */
  21866. makeGeometryUnique(): Mesh;
  21867. /**
  21868. * Set the index buffer of this mesh
  21869. * @param indices defines the source data
  21870. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21871. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21872. * @returns the current mesh
  21873. */
  21874. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21875. /**
  21876. * Update the current index buffer
  21877. * @param indices defines the source data
  21878. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21879. * @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)
  21880. * @returns the current mesh
  21881. */
  21882. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21883. /**
  21884. * Invert the geometry to move from a right handed system to a left handed one.
  21885. * @returns the current mesh
  21886. */
  21887. toLeftHanded(): Mesh;
  21888. /** @hidden */
  21889. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21890. /** @hidden */
  21891. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21892. /**
  21893. * Registers for this mesh a javascript function called just before the rendering process
  21894. * @param func defines the function to call before rendering this mesh
  21895. * @returns the current mesh
  21896. */
  21897. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21898. /**
  21899. * Disposes a previously registered javascript function called before the rendering
  21900. * @param func defines the function to remove
  21901. * @returns the current mesh
  21902. */
  21903. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21904. /**
  21905. * Registers for this mesh a javascript function called just after the rendering is complete
  21906. * @param func defines the function to call after rendering this mesh
  21907. * @returns the current mesh
  21908. */
  21909. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21910. /**
  21911. * Disposes a previously registered javascript function called after the rendering.
  21912. * @param func defines the function to remove
  21913. * @returns the current mesh
  21914. */
  21915. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21916. /** @hidden */
  21917. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21918. /** @hidden */
  21919. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21920. /** @hidden */
  21921. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21922. /** @hidden */
  21923. _freeze(): void;
  21924. /** @hidden */
  21925. _unFreeze(): void;
  21926. /**
  21927. * 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
  21928. * @param subMesh defines the subMesh to render
  21929. * @param enableAlphaMode defines if alpha mode can be changed
  21930. * @returns the current mesh
  21931. */
  21932. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21933. private _onBeforeDraw;
  21934. /**
  21935. * Renormalize the mesh and patch it up if there are no weights
  21936. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21937. * However in the case of zero weights then we set just a single influence to 1.
  21938. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21939. */
  21940. cleanMatrixWeights(): void;
  21941. private normalizeSkinFourWeights;
  21942. private normalizeSkinWeightsAndExtra;
  21943. /**
  21944. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21945. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21946. * the user know there was an issue with importing the mesh
  21947. * @returns a validation object with skinned, valid and report string
  21948. */
  21949. validateSkinning(): {
  21950. skinned: boolean;
  21951. valid: boolean;
  21952. report: string;
  21953. };
  21954. /** @hidden */
  21955. _checkDelayState(): Mesh;
  21956. private _queueLoad;
  21957. /**
  21958. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21959. * A mesh is in the frustum if its bounding box intersects the frustum
  21960. * @param frustumPlanes defines the frustum to test
  21961. * @returns true if the mesh is in the frustum planes
  21962. */
  21963. isInFrustum(frustumPlanes: Plane[]): boolean;
  21964. /**
  21965. * Sets the mesh material by the material or multiMaterial `id` property
  21966. * @param id is a string identifying the material or the multiMaterial
  21967. * @returns the current mesh
  21968. */
  21969. setMaterialByID(id: string): Mesh;
  21970. /**
  21971. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21972. * @returns an array of IAnimatable
  21973. */
  21974. getAnimatables(): IAnimatable[];
  21975. /**
  21976. * Modifies the mesh geometry according to the passed transformation matrix.
  21977. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21978. * The mesh normals are modified using the same transformation.
  21979. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21980. * @param transform defines the transform matrix to use
  21981. * @see http://doc.babylonjs.com/resources/baking_transformations
  21982. * @returns the current mesh
  21983. */
  21984. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21985. /**
  21986. * Modifies the mesh geometry according to its own current World Matrix.
  21987. * The mesh World Matrix is then reset.
  21988. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21989. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21990. * @see http://doc.babylonjs.com/resources/baking_transformations
  21991. * @returns the current mesh
  21992. */
  21993. bakeCurrentTransformIntoVertices(): Mesh;
  21994. /** @hidden */
  21995. readonly _positions: Nullable<Vector3[]>;
  21996. /** @hidden */
  21997. _resetPointsArrayCache(): Mesh;
  21998. /** @hidden */
  21999. _generatePointsArray(): boolean;
  22000. /**
  22001. * Returns a new Mesh object generated from the current mesh properties.
  22002. * This method must not get confused with createInstance()
  22003. * @param name is a string, the name given to the new mesh
  22004. * @param newParent can be any Node object (default `null`)
  22005. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22006. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22007. * @returns a new mesh
  22008. */
  22009. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22010. /**
  22011. * Releases resources associated with this mesh.
  22012. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22013. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22014. */
  22015. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22016. /**
  22017. * Modifies the mesh geometry according to a displacement map.
  22018. * 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.
  22019. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22020. * @param url is a string, the URL from the image file is to be downloaded.
  22021. * @param minHeight is the lower limit of the displacement.
  22022. * @param maxHeight is the upper limit of the displacement.
  22023. * @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.
  22024. * @param uvOffset is an optional vector2 used to offset UV.
  22025. * @param uvScale is an optional vector2 used to scale UV.
  22026. * @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.
  22027. * @returns the Mesh.
  22028. */
  22029. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22030. /**
  22031. * Modifies the mesh geometry according to a displacementMap buffer.
  22032. * 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.
  22033. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22034. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22035. * @param heightMapWidth is the width of the buffer image.
  22036. * @param heightMapHeight is the height of the buffer image.
  22037. * @param minHeight is the lower limit of the displacement.
  22038. * @param maxHeight is the upper limit of the displacement.
  22039. * @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.
  22040. * @param uvOffset is an optional vector2 used to offset UV.
  22041. * @param uvScale is an optional vector2 used to scale UV.
  22042. * @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.
  22043. * @returns the Mesh.
  22044. */
  22045. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22046. /**
  22047. * Modify the mesh to get a flat shading rendering.
  22048. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22049. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22050. * @returns current mesh
  22051. */
  22052. convertToFlatShadedMesh(): Mesh;
  22053. /**
  22054. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22055. * In other words, more vertices, no more indices and a single bigger VBO.
  22056. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22057. * @returns current mesh
  22058. */
  22059. convertToUnIndexedMesh(): Mesh;
  22060. /**
  22061. * Inverses facet orientations.
  22062. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22063. * @param flipNormals will also inverts the normals
  22064. * @returns current mesh
  22065. */
  22066. flipFaces(flipNormals?: boolean): Mesh;
  22067. /**
  22068. * Increase the number of facets and hence vertices in a mesh
  22069. * Vertex normals are interpolated from existing vertex normals
  22070. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22071. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22072. */
  22073. increaseVertices(numberPerEdge: number): void;
  22074. /**
  22075. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22076. * This will undo any application of covertToFlatShadedMesh
  22077. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22078. */
  22079. forceSharedVertices(): void;
  22080. /** @hidden */
  22081. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22082. /** @hidden */
  22083. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22084. /**
  22085. * Creates a new InstancedMesh object from the mesh model.
  22086. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22087. * @param name defines the name of the new instance
  22088. * @returns a new InstancedMesh
  22089. */
  22090. createInstance(name: string): InstancedMesh;
  22091. /**
  22092. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22093. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22094. * @returns the current mesh
  22095. */
  22096. synchronizeInstances(): Mesh;
  22097. /**
  22098. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22099. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22100. * This should be used together with the simplification to avoid disappearing triangles.
  22101. * @param successCallback an optional success callback to be called after the optimization finished.
  22102. * @returns the current mesh
  22103. */
  22104. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22105. /**
  22106. * Serialize current mesh
  22107. * @param serializationObject defines the object which will receive the serialization data
  22108. */
  22109. serialize(serializationObject: any): void;
  22110. /** @hidden */
  22111. _syncGeometryWithMorphTargetManager(): void;
  22112. /** @hidden */
  22113. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22114. /**
  22115. * Returns a new Mesh object parsed from the source provided.
  22116. * @param parsedMesh is the source
  22117. * @param scene defines the hosting scene
  22118. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22119. * @returns a new Mesh
  22120. */
  22121. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22122. /**
  22123. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22124. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22125. * @param name defines the name of the mesh to create
  22126. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22127. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22128. * @param closePath creates a seam between the first and the last points of each path of the path array
  22129. * @param offset is taken in account only if the `pathArray` is containing a single path
  22130. * @param scene defines the hosting scene
  22131. * @param updatable defines if the mesh must be flagged as updatable
  22132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22133. * @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)
  22134. * @returns a new Mesh
  22135. */
  22136. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22137. /**
  22138. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22139. * @param name defines the name of the mesh to create
  22140. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22141. * @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
  22142. * @param scene defines the hosting scene
  22143. * @param updatable defines if the mesh must be flagged as updatable
  22144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22145. * @returns a new Mesh
  22146. */
  22147. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22148. /**
  22149. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22150. * @param name defines the name of the mesh to create
  22151. * @param size sets the size (float) of each box side (default 1)
  22152. * @param scene defines the hosting scene
  22153. * @param updatable defines if the mesh must be flagged as updatable
  22154. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22155. * @returns a new Mesh
  22156. */
  22157. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22158. /**
  22159. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22160. * @param name defines the name of the mesh to create
  22161. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22162. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22163. * @param scene defines the hosting scene
  22164. * @param updatable defines if the mesh must be flagged as updatable
  22165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22166. * @returns a new Mesh
  22167. */
  22168. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22169. /**
  22170. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22171. * @param name defines the name of the mesh to create
  22172. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22173. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22174. * @param scene defines the hosting scene
  22175. * @returns a new Mesh
  22176. */
  22177. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22178. /**
  22179. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22180. * @param name defines the name of the mesh to create
  22181. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22182. * @param diameterTop set the top cap diameter (floats, default 1)
  22183. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22184. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22185. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22186. * @param scene defines the hosting scene
  22187. * @param updatable defines if the mesh must be flagged as updatable
  22188. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22189. * @returns a new Mesh
  22190. */
  22191. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22192. /**
  22193. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22194. * @param name defines the name of the mesh to create
  22195. * @param diameter sets the diameter size (float) of the torus (default 1)
  22196. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22197. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22198. * @param scene defines the hosting scene
  22199. * @param updatable defines if the mesh must be flagged as updatable
  22200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22201. * @returns a new Mesh
  22202. */
  22203. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22204. /**
  22205. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22206. * @param name defines the name of the mesh to create
  22207. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22208. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22209. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22210. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22211. * @param p the number of windings on X axis (positive integers, default 2)
  22212. * @param q the number of windings on Y axis (positive integers, default 3)
  22213. * @param scene defines the hosting scene
  22214. * @param updatable defines if the mesh must be flagged as updatable
  22215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22216. * @returns a new Mesh
  22217. */
  22218. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22219. /**
  22220. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22221. * @param name defines the name of the mesh to create
  22222. * @param points is an array successive Vector3
  22223. * @param scene defines the hosting scene
  22224. * @param updatable defines if the mesh must be flagged as updatable
  22225. * @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).
  22226. * @returns a new Mesh
  22227. */
  22228. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22229. /**
  22230. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22231. * @param name defines the name of the mesh to create
  22232. * @param points is an array successive Vector3
  22233. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22234. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22235. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  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 CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22242. /**
  22243. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22244. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22245. * 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.
  22246. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22247. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22248. * Remember you can only change the shape positions, not their number when updating a polygon.
  22249. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22250. * @param name defines the name of the mesh to create
  22251. * @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
  22252. * @param scene defines the hosting scene
  22253. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22254. * @param updatable defines if the mesh must be flagged as updatable
  22255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22256. * @param earcutInjection can be used to inject your own earcut reference
  22257. * @returns a new Mesh
  22258. */
  22259. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22260. /**
  22261. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22262. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-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 depth defines the height of extrusion
  22266. * @param scene defines the hosting scene
  22267. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22268. * @param updatable defines if the mesh must be flagged as updatable
  22269. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22270. * @param earcutInjection can be used to inject your own earcut reference
  22271. * @returns a new Mesh
  22272. */
  22273. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22274. /**
  22275. * Creates an extruded shape mesh.
  22276. * 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
  22277. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22278. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22279. * @param name defines the name of the mesh to create
  22280. * @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
  22281. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22282. * @param scale is the value to scale the shape
  22283. * @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
  22284. * @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
  22285. * @param scene defines the hosting scene
  22286. * @param updatable defines if the mesh must be flagged as updatable
  22287. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22288. * @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)
  22289. * @returns a new Mesh
  22290. */
  22291. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22292. /**
  22293. * Creates an custom extruded shape mesh.
  22294. * The custom extrusion is a parametric shape.
  22295. * It has no predefined shape. Its final shape will depend on the input parameters.
  22296. * Please consider using the same method from the MeshBuilder class instead
  22297. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22298. * @param name defines the name of the mesh to create
  22299. * @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
  22300. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22301. * @param scaleFunction is a custom Javascript function called on each path point
  22302. * @param rotationFunction is a custom Javascript function called on each path point
  22303. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22304. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22305. * @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
  22306. * @param scene defines the hosting scene
  22307. * @param updatable defines if the mesh must be flagged as updatable
  22308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22309. * @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)
  22310. * @returns a new Mesh
  22311. */
  22312. 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;
  22313. /**
  22314. * Creates lathe mesh.
  22315. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22316. * Please consider using the same method from the MeshBuilder class instead
  22317. * @param name defines the name of the mesh to create
  22318. * @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
  22319. * @param radius is the radius value of the lathe
  22320. * @param tessellation is the side number of the lathe.
  22321. * @param scene defines the hosting scene
  22322. * @param updatable defines if the mesh must be flagged as updatable
  22323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22324. * @returns a new Mesh
  22325. */
  22326. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22327. /**
  22328. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22329. * @param name defines the name of the mesh to create
  22330. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22331. * @param scene defines the hosting scene
  22332. * @param updatable defines if the mesh must be flagged as updatable
  22333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22334. * @returns a new Mesh
  22335. */
  22336. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22337. /**
  22338. * Creates a ground mesh.
  22339. * Please consider using the same method from the MeshBuilder class instead
  22340. * @param name defines the name of the mesh to create
  22341. * @param width set the width of the ground
  22342. * @param height set the height of the ground
  22343. * @param subdivisions sets the number of subdivisions per side
  22344. * @param scene defines the hosting scene
  22345. * @param updatable defines if the mesh must be flagged as updatable
  22346. * @returns a new Mesh
  22347. */
  22348. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22349. /**
  22350. * Creates a tiled ground mesh.
  22351. * Please consider using the same method from the MeshBuilder class instead
  22352. * @param name defines the name of the mesh to create
  22353. * @param xmin set the ground minimum X coordinate
  22354. * @param zmin set the ground minimum Y coordinate
  22355. * @param xmax set the ground maximum X coordinate
  22356. * @param zmax set the ground maximum Z coordinate
  22357. * @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
  22358. * @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
  22359. * @param scene defines the hosting scene
  22360. * @param updatable defines if the mesh must be flagged as updatable
  22361. * @returns a new Mesh
  22362. */
  22363. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22364. w: number;
  22365. h: number;
  22366. }, precision: {
  22367. w: number;
  22368. h: number;
  22369. }, scene: Scene, updatable?: boolean): Mesh;
  22370. /**
  22371. * Creates a ground mesh from a height map.
  22372. * Please consider using the same method from the MeshBuilder class instead
  22373. * @see http://doc.babylonjs.com/babylon101/height_map
  22374. * @param name defines the name of the mesh to create
  22375. * @param url sets the URL of the height map image resource
  22376. * @param width set the ground width size
  22377. * @param height set the ground height size
  22378. * @param subdivisions sets the number of subdivision per side
  22379. * @param minHeight is the minimum altitude on the ground
  22380. * @param maxHeight is the maximum altitude on the ground
  22381. * @param scene defines the hosting scene
  22382. * @param updatable defines if the mesh must be flagged as updatable
  22383. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22384. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22385. * @returns a new Mesh
  22386. */
  22387. 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;
  22388. /**
  22389. * Creates a tube mesh.
  22390. * The tube is a parametric shape.
  22391. * It has no predefined shape. Its final shape will depend on the input parameters.
  22392. * Please consider using the same method from the MeshBuilder class instead
  22393. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22394. * @param name defines the name of the mesh to create
  22395. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22396. * @param radius sets the tube radius size
  22397. * @param tessellation is the number of sides on the tubular surface
  22398. * @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
  22399. * @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
  22400. * @param scene defines the hosting scene
  22401. * @param updatable defines if the mesh must be flagged as updatable
  22402. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22403. * @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)
  22404. * @returns a new Mesh
  22405. */
  22406. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22407. (i: number, distance: number): number;
  22408. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22409. /**
  22410. * Creates a polyhedron mesh.
  22411. * Please consider using the same method from the MeshBuilder class instead.
  22412. * * 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
  22413. * * The parameter `size` (positive float, default 1) sets the polygon size
  22414. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22415. * * 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`
  22416. * * 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
  22417. * * 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)`)
  22418. * * 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
  22419. * * 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
  22420. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22421. * * If you create a double-sided mesh, you can choose what parts of 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
  22422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22423. * @param name defines the name of the mesh to create
  22424. * @param options defines the options used to create the mesh
  22425. * @param scene defines the hosting scene
  22426. * @returns a new Mesh
  22427. */
  22428. static CreatePolyhedron(name: string, options: {
  22429. type?: number;
  22430. size?: number;
  22431. sizeX?: number;
  22432. sizeY?: number;
  22433. sizeZ?: number;
  22434. custom?: any;
  22435. faceUV?: Vector4[];
  22436. faceColors?: Color4[];
  22437. updatable?: boolean;
  22438. sideOrientation?: number;
  22439. }, scene: Scene): Mesh;
  22440. /**
  22441. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22442. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22443. * * 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`)
  22444. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22445. * * 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
  22446. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22447. * * If you create a double-sided mesh, you can choose what parts of 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
  22448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22449. * @param name defines the name of the mesh
  22450. * @param options defines the options used to create the mesh
  22451. * @param scene defines the hosting scene
  22452. * @returns a new Mesh
  22453. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22454. */
  22455. static CreateIcoSphere(name: string, options: {
  22456. radius?: number;
  22457. flat?: boolean;
  22458. subdivisions?: number;
  22459. sideOrientation?: number;
  22460. updatable?: boolean;
  22461. }, scene: Scene): Mesh;
  22462. /**
  22463. * Creates a decal mesh.
  22464. * Please consider using the same method from the MeshBuilder class instead.
  22465. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22466. * @param name defines the name of the mesh
  22467. * @param sourceMesh defines the mesh receiving the decal
  22468. * @param position sets the position of the decal in world coordinates
  22469. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22470. * @param size sets the decal scaling
  22471. * @param angle sets the angle to rotate the decal
  22472. * @returns a new Mesh
  22473. */
  22474. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22475. /**
  22476. * Prepare internal position array for software CPU skinning
  22477. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22478. */
  22479. setPositionsForCPUSkinning(): Float32Array;
  22480. /**
  22481. * Prepare internal normal array for software CPU skinning
  22482. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22483. */
  22484. setNormalsForCPUSkinning(): Float32Array;
  22485. /**
  22486. * Updates the vertex buffer by applying transformation from the bones
  22487. * @param skeleton defines the skeleton to apply to current mesh
  22488. * @returns the current mesh
  22489. */
  22490. applySkeleton(skeleton: Skeleton): Mesh;
  22491. /**
  22492. * 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
  22493. * @param meshes defines the list of meshes to scan
  22494. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22495. */
  22496. static MinMax(meshes: AbstractMesh[]): {
  22497. min: Vector3;
  22498. max: Vector3;
  22499. };
  22500. /**
  22501. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22502. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22503. * @returns a vector3
  22504. */
  22505. static Center(meshesOrMinMaxVector: {
  22506. min: Vector3;
  22507. max: Vector3;
  22508. } | AbstractMesh[]): Vector3;
  22509. /**
  22510. * Merge the array of meshes into a single mesh for performance reasons.
  22511. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22512. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22513. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22514. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22515. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22516. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22517. * @returns a new mesh
  22518. */
  22519. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22520. /** @hidden */
  22521. addInstance(instance: InstancedMesh): void;
  22522. /** @hidden */
  22523. removeInstance(instance: InstancedMesh): void;
  22524. }
  22525. }
  22526. declare module "babylonjs/Materials/material" {
  22527. import { IAnimatable } from "babylonjs/Misc/tools";
  22528. import { SmartArray } from "babylonjs/Misc/smartArray";
  22529. import { Observable } from "babylonjs/Misc/observable";
  22530. import { Nullable } from "babylonjs/types";
  22531. import { Scene } from "babylonjs/scene";
  22532. import { Matrix } from "babylonjs/Maths/math";
  22533. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22535. import { Mesh } from "babylonjs/Meshes/mesh";
  22536. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22537. import { Effect } from "babylonjs/Materials/effect";
  22538. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22539. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22540. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22541. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22542. import { Animation } from "babylonjs/Animations/animation";
  22543. /**
  22544. * Base class for the main features of a material in Babylon.js
  22545. */
  22546. export class Material implements IAnimatable {
  22547. /**
  22548. * Returns the triangle fill mode
  22549. */
  22550. static readonly TriangleFillMode: number;
  22551. /**
  22552. * Returns the wireframe mode
  22553. */
  22554. static readonly WireFrameFillMode: number;
  22555. /**
  22556. * Returns the point fill mode
  22557. */
  22558. static readonly PointFillMode: number;
  22559. /**
  22560. * Returns the point list draw mode
  22561. */
  22562. static readonly PointListDrawMode: number;
  22563. /**
  22564. * Returns the line list draw mode
  22565. */
  22566. static readonly LineListDrawMode: number;
  22567. /**
  22568. * Returns the line loop draw mode
  22569. */
  22570. static readonly LineLoopDrawMode: number;
  22571. /**
  22572. * Returns the line strip draw mode
  22573. */
  22574. static readonly LineStripDrawMode: number;
  22575. /**
  22576. * Returns the triangle strip draw mode
  22577. */
  22578. static readonly TriangleStripDrawMode: number;
  22579. /**
  22580. * Returns the triangle fan draw mode
  22581. */
  22582. static readonly TriangleFanDrawMode: number;
  22583. /**
  22584. * Stores the clock-wise side orientation
  22585. */
  22586. static readonly ClockWiseSideOrientation: number;
  22587. /**
  22588. * Stores the counter clock-wise side orientation
  22589. */
  22590. static readonly CounterClockWiseSideOrientation: number;
  22591. /**
  22592. * The dirty texture flag value
  22593. */
  22594. static readonly TextureDirtyFlag: number;
  22595. /**
  22596. * The dirty light flag value
  22597. */
  22598. static readonly LightDirtyFlag: number;
  22599. /**
  22600. * The dirty fresnel flag value
  22601. */
  22602. static readonly FresnelDirtyFlag: number;
  22603. /**
  22604. * The dirty attribute flag value
  22605. */
  22606. static readonly AttributesDirtyFlag: number;
  22607. /**
  22608. * The dirty misc flag value
  22609. */
  22610. static readonly MiscDirtyFlag: number;
  22611. /**
  22612. * The all dirty flag value
  22613. */
  22614. static readonly AllDirtyFlag: number;
  22615. /**
  22616. * The ID of the material
  22617. */
  22618. id: string;
  22619. /**
  22620. * Gets or sets the unique id of the material
  22621. */
  22622. uniqueId: number;
  22623. /**
  22624. * The name of the material
  22625. */
  22626. name: string;
  22627. /**
  22628. * Gets or sets user defined metadata
  22629. */
  22630. metadata: any;
  22631. /**
  22632. * For internal use only. Please do not use.
  22633. */
  22634. reservedDataStore: any;
  22635. /**
  22636. * Specifies if the ready state should be checked on each call
  22637. */
  22638. checkReadyOnEveryCall: boolean;
  22639. /**
  22640. * Specifies if the ready state should be checked once
  22641. */
  22642. checkReadyOnlyOnce: boolean;
  22643. /**
  22644. * The state of the material
  22645. */
  22646. state: string;
  22647. /**
  22648. * The alpha value of the material
  22649. */
  22650. protected _alpha: number;
  22651. /**
  22652. * List of inspectable custom properties (used by the Inspector)
  22653. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22654. */
  22655. inspectableCustomProperties: IInspectable[];
  22656. /**
  22657. * Sets the alpha value of the material
  22658. */
  22659. /**
  22660. * Gets the alpha value of the material
  22661. */
  22662. alpha: number;
  22663. /**
  22664. * Specifies if back face culling is enabled
  22665. */
  22666. protected _backFaceCulling: boolean;
  22667. /**
  22668. * Sets the back-face culling state
  22669. */
  22670. /**
  22671. * Gets the back-face culling state
  22672. */
  22673. backFaceCulling: boolean;
  22674. /**
  22675. * Stores the value for side orientation
  22676. */
  22677. sideOrientation: number;
  22678. /**
  22679. * Callback triggered when the material is compiled
  22680. */
  22681. onCompiled: Nullable<(effect: Effect) => void>;
  22682. /**
  22683. * Callback triggered when an error occurs
  22684. */
  22685. onError: Nullable<(effect: Effect, errors: string) => void>;
  22686. /**
  22687. * Callback triggered to get the render target textures
  22688. */
  22689. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22690. /**
  22691. * Gets a boolean indicating that current material needs to register RTT
  22692. */
  22693. readonly hasRenderTargetTextures: boolean;
  22694. /**
  22695. * Specifies if the material should be serialized
  22696. */
  22697. doNotSerialize: boolean;
  22698. /**
  22699. * @hidden
  22700. */
  22701. _storeEffectOnSubMeshes: boolean;
  22702. /**
  22703. * Stores the animations for the material
  22704. */
  22705. animations: Nullable<Array<Animation>>;
  22706. /**
  22707. * An event triggered when the material is disposed
  22708. */
  22709. onDisposeObservable: Observable<Material>;
  22710. /**
  22711. * An observer which watches for dispose events
  22712. */
  22713. private _onDisposeObserver;
  22714. private _onUnBindObservable;
  22715. /**
  22716. * Called during a dispose event
  22717. */
  22718. onDispose: () => void;
  22719. private _onBindObservable;
  22720. /**
  22721. * An event triggered when the material is bound
  22722. */
  22723. readonly onBindObservable: Observable<AbstractMesh>;
  22724. /**
  22725. * An observer which watches for bind events
  22726. */
  22727. private _onBindObserver;
  22728. /**
  22729. * Called during a bind event
  22730. */
  22731. onBind: (Mesh: AbstractMesh) => void;
  22732. /**
  22733. * An event triggered when the material is unbound
  22734. */
  22735. readonly onUnBindObservable: Observable<Material>;
  22736. /**
  22737. * Stores the value of the alpha mode
  22738. */
  22739. private _alphaMode;
  22740. /**
  22741. * Sets the value of the alpha mode.
  22742. *
  22743. * | Value | Type | Description |
  22744. * | --- | --- | --- |
  22745. * | 0 | ALPHA_DISABLE | |
  22746. * | 1 | ALPHA_ADD | |
  22747. * | 2 | ALPHA_COMBINE | |
  22748. * | 3 | ALPHA_SUBTRACT | |
  22749. * | 4 | ALPHA_MULTIPLY | |
  22750. * | 5 | ALPHA_MAXIMIZED | |
  22751. * | 6 | ALPHA_ONEONE | |
  22752. * | 7 | ALPHA_PREMULTIPLIED | |
  22753. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22754. * | 9 | ALPHA_INTERPOLATE | |
  22755. * | 10 | ALPHA_SCREENMODE | |
  22756. *
  22757. */
  22758. /**
  22759. * Gets the value of the alpha mode
  22760. */
  22761. alphaMode: number;
  22762. /**
  22763. * Stores the state of the need depth pre-pass value
  22764. */
  22765. private _needDepthPrePass;
  22766. /**
  22767. * Sets the need depth pre-pass value
  22768. */
  22769. /**
  22770. * Gets the depth pre-pass value
  22771. */
  22772. needDepthPrePass: boolean;
  22773. /**
  22774. * Specifies if depth writing should be disabled
  22775. */
  22776. disableDepthWrite: boolean;
  22777. /**
  22778. * Specifies if depth writing should be forced
  22779. */
  22780. forceDepthWrite: boolean;
  22781. /**
  22782. * Specifies if there should be a separate pass for culling
  22783. */
  22784. separateCullingPass: boolean;
  22785. /**
  22786. * Stores the state specifing if fog should be enabled
  22787. */
  22788. private _fogEnabled;
  22789. /**
  22790. * Sets the state for enabling fog
  22791. */
  22792. /**
  22793. * Gets the value of the fog enabled state
  22794. */
  22795. fogEnabled: boolean;
  22796. /**
  22797. * Stores the size of points
  22798. */
  22799. pointSize: number;
  22800. /**
  22801. * Stores the z offset value
  22802. */
  22803. zOffset: number;
  22804. /**
  22805. * Gets a value specifying if wireframe mode is enabled
  22806. */
  22807. /**
  22808. * Sets the state of wireframe mode
  22809. */
  22810. wireframe: boolean;
  22811. /**
  22812. * Gets the value specifying if point clouds are enabled
  22813. */
  22814. /**
  22815. * Sets the state of point cloud mode
  22816. */
  22817. pointsCloud: boolean;
  22818. /**
  22819. * Gets the material fill mode
  22820. */
  22821. /**
  22822. * Sets the material fill mode
  22823. */
  22824. fillMode: number;
  22825. /**
  22826. * @hidden
  22827. * Stores the effects for the material
  22828. */
  22829. _effect: Nullable<Effect>;
  22830. /**
  22831. * @hidden
  22832. * Specifies if the material was previously ready
  22833. */
  22834. _wasPreviouslyReady: boolean;
  22835. /**
  22836. * Specifies if uniform buffers should be used
  22837. */
  22838. private _useUBO;
  22839. /**
  22840. * Stores a reference to the scene
  22841. */
  22842. private _scene;
  22843. /**
  22844. * Stores the fill mode state
  22845. */
  22846. private _fillMode;
  22847. /**
  22848. * Specifies if the depth write state should be cached
  22849. */
  22850. private _cachedDepthWriteState;
  22851. /**
  22852. * Stores the uniform buffer
  22853. */
  22854. protected _uniformBuffer: UniformBuffer;
  22855. /** @hidden */
  22856. _indexInSceneMaterialArray: number;
  22857. /** @hidden */
  22858. meshMap: Nullable<{
  22859. [id: string]: AbstractMesh | undefined;
  22860. }>;
  22861. /**
  22862. * Creates a material instance
  22863. * @param name defines the name of the material
  22864. * @param scene defines the scene to reference
  22865. * @param doNotAdd specifies if the material should be added to the scene
  22866. */
  22867. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22868. /**
  22869. * Returns a string representation of the current material
  22870. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22871. * @returns a string with material information
  22872. */
  22873. toString(fullDetails?: boolean): string;
  22874. /**
  22875. * Gets the class name of the material
  22876. * @returns a string with the class name of the material
  22877. */
  22878. getClassName(): string;
  22879. /**
  22880. * Specifies if updates for the material been locked
  22881. */
  22882. readonly isFrozen: boolean;
  22883. /**
  22884. * Locks updates for the material
  22885. */
  22886. freeze(): void;
  22887. /**
  22888. * Unlocks updates for the material
  22889. */
  22890. unfreeze(): void;
  22891. /**
  22892. * Specifies if the material is ready to be used
  22893. * @param mesh defines the mesh to check
  22894. * @param useInstances specifies if instances should be used
  22895. * @returns a boolean indicating if the material is ready to be used
  22896. */
  22897. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22898. /**
  22899. * Specifies that the submesh is ready to be used
  22900. * @param mesh defines the mesh to check
  22901. * @param subMesh defines which submesh to check
  22902. * @param useInstances specifies that instances should be used
  22903. * @returns a boolean indicating that the submesh is ready or not
  22904. */
  22905. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22906. /**
  22907. * Returns the material effect
  22908. * @returns the effect associated with the material
  22909. */
  22910. getEffect(): Nullable<Effect>;
  22911. /**
  22912. * Returns the current scene
  22913. * @returns a Scene
  22914. */
  22915. getScene(): Scene;
  22916. /**
  22917. * Specifies if the material will require alpha blending
  22918. * @returns a boolean specifying if alpha blending is needed
  22919. */
  22920. needAlphaBlending(): boolean;
  22921. /**
  22922. * Specifies if the mesh will require alpha blending
  22923. * @param mesh defines the mesh to check
  22924. * @returns a boolean specifying if alpha blending is needed for the mesh
  22925. */
  22926. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22927. /**
  22928. * Specifies if this material should be rendered in alpha test mode
  22929. * @returns a boolean specifying if an alpha test is needed.
  22930. */
  22931. needAlphaTesting(): boolean;
  22932. /**
  22933. * Gets the texture used for the alpha test
  22934. * @returns the texture to use for alpha testing
  22935. */
  22936. getAlphaTestTexture(): Nullable<BaseTexture>;
  22937. /**
  22938. * Marks the material to indicate that it needs to be re-calculated
  22939. */
  22940. markDirty(): void;
  22941. /** @hidden */
  22942. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22943. /**
  22944. * Binds the material to the mesh
  22945. * @param world defines the world transformation matrix
  22946. * @param mesh defines the mesh to bind the material to
  22947. */
  22948. bind(world: Matrix, mesh?: Mesh): void;
  22949. /**
  22950. * Binds the submesh to the material
  22951. * @param world defines the world transformation matrix
  22952. * @param mesh defines the mesh containing the submesh
  22953. * @param subMesh defines the submesh to bind the material to
  22954. */
  22955. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22956. /**
  22957. * Binds the world matrix to the material
  22958. * @param world defines the world transformation matrix
  22959. */
  22960. bindOnlyWorldMatrix(world: Matrix): void;
  22961. /**
  22962. * Binds the scene's uniform buffer to the effect.
  22963. * @param effect defines the effect to bind to the scene uniform buffer
  22964. * @param sceneUbo defines the uniform buffer storing scene data
  22965. */
  22966. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22967. /**
  22968. * Binds the view matrix to the effect
  22969. * @param effect defines the effect to bind the view matrix to
  22970. */
  22971. bindView(effect: Effect): void;
  22972. /**
  22973. * Binds the view projection matrix to the effect
  22974. * @param effect defines the effect to bind the view projection matrix to
  22975. */
  22976. bindViewProjection(effect: Effect): void;
  22977. /**
  22978. * Specifies if material alpha testing should be turned on for the mesh
  22979. * @param mesh defines the mesh to check
  22980. */
  22981. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22982. /**
  22983. * Processes to execute after binding the material to a mesh
  22984. * @param mesh defines the rendered mesh
  22985. */
  22986. protected _afterBind(mesh?: Mesh): void;
  22987. /**
  22988. * Unbinds the material from the mesh
  22989. */
  22990. unbind(): void;
  22991. /**
  22992. * Gets the active textures from the material
  22993. * @returns an array of textures
  22994. */
  22995. getActiveTextures(): BaseTexture[];
  22996. /**
  22997. * Specifies if the material uses a texture
  22998. * @param texture defines the texture to check against the material
  22999. * @returns a boolean specifying if the material uses the texture
  23000. */
  23001. hasTexture(texture: BaseTexture): boolean;
  23002. /**
  23003. * Makes a duplicate of the material, and gives it a new name
  23004. * @param name defines the new name for the duplicated material
  23005. * @returns the cloned material
  23006. */
  23007. clone(name: string): Nullable<Material>;
  23008. /**
  23009. * Gets the meshes bound to the material
  23010. * @returns an array of meshes bound to the material
  23011. */
  23012. getBindedMeshes(): AbstractMesh[];
  23013. /**
  23014. * Force shader compilation
  23015. * @param mesh defines the mesh associated with this material
  23016. * @param onCompiled defines a function to execute once the material is compiled
  23017. * @param options defines the options to configure the compilation
  23018. */
  23019. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23020. clipPlane: boolean;
  23021. }>): void;
  23022. /**
  23023. * Force shader compilation
  23024. * @param mesh defines the mesh that will use this material
  23025. * @param options defines additional options for compiling the shaders
  23026. * @returns a promise that resolves when the compilation completes
  23027. */
  23028. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23029. clipPlane: boolean;
  23030. }>): Promise<void>;
  23031. private static readonly _ImageProcessingDirtyCallBack;
  23032. private static readonly _TextureDirtyCallBack;
  23033. private static readonly _FresnelDirtyCallBack;
  23034. private static readonly _MiscDirtyCallBack;
  23035. private static readonly _LightsDirtyCallBack;
  23036. private static readonly _AttributeDirtyCallBack;
  23037. private static _FresnelAndMiscDirtyCallBack;
  23038. private static _TextureAndMiscDirtyCallBack;
  23039. private static readonly _DirtyCallbackArray;
  23040. private static readonly _RunDirtyCallBacks;
  23041. /**
  23042. * Marks a define in the material to indicate that it needs to be re-computed
  23043. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23044. */
  23045. markAsDirty(flag: number): void;
  23046. /**
  23047. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23048. * @param func defines a function which checks material defines against the submeshes
  23049. */
  23050. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23051. /**
  23052. * Indicates that image processing needs to be re-calculated for all submeshes
  23053. */
  23054. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23055. /**
  23056. * Indicates that textures need to be re-calculated for all submeshes
  23057. */
  23058. protected _markAllSubMeshesAsTexturesDirty(): void;
  23059. /**
  23060. * Indicates that fresnel needs to be re-calculated for all submeshes
  23061. */
  23062. protected _markAllSubMeshesAsFresnelDirty(): void;
  23063. /**
  23064. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23065. */
  23066. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23067. /**
  23068. * Indicates that lights need to be re-calculated for all submeshes
  23069. */
  23070. protected _markAllSubMeshesAsLightsDirty(): void;
  23071. /**
  23072. * Indicates that attributes need to be re-calculated for all submeshes
  23073. */
  23074. protected _markAllSubMeshesAsAttributesDirty(): void;
  23075. /**
  23076. * Indicates that misc needs to be re-calculated for all submeshes
  23077. */
  23078. protected _markAllSubMeshesAsMiscDirty(): void;
  23079. /**
  23080. * Indicates that textures and misc need to be re-calculated for all submeshes
  23081. */
  23082. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23083. /**
  23084. * Disposes the material
  23085. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23086. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23087. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23088. */
  23089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23090. /** @hidden */
  23091. private releaseVertexArrayObject;
  23092. /**
  23093. * Serializes this material
  23094. * @returns the serialized material object
  23095. */
  23096. serialize(): any;
  23097. /**
  23098. * Creates a material from parsed material data
  23099. * @param parsedMaterial defines parsed material data
  23100. * @param scene defines the hosting scene
  23101. * @param rootUrl defines the root URL to use to load textures
  23102. * @returns a new material
  23103. */
  23104. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23105. }
  23106. }
  23107. declare module "babylonjs/Meshes/subMesh" {
  23108. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23109. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23110. import { Engine } from "babylonjs/Engines/engine";
  23111. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23112. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23113. import { Effect } from "babylonjs/Materials/effect";
  23114. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23115. import { Collider } from "babylonjs/Collisions/collider";
  23116. import { Material } from "babylonjs/Materials/material";
  23117. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23119. import { Mesh } from "babylonjs/Meshes/mesh";
  23120. import { Ray } from "babylonjs/Culling/ray";
  23121. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23122. /**
  23123. * Base class for submeshes
  23124. */
  23125. export class BaseSubMesh {
  23126. /** @hidden */
  23127. _materialDefines: Nullable<MaterialDefines>;
  23128. /** @hidden */
  23129. _materialEffect: Nullable<Effect>;
  23130. /**
  23131. * Gets associated effect
  23132. */
  23133. readonly effect: Nullable<Effect>;
  23134. /**
  23135. * Sets associated effect (effect used to render this submesh)
  23136. * @param effect defines the effect to associate with
  23137. * @param defines defines the set of defines used to compile this effect
  23138. */
  23139. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23140. }
  23141. /**
  23142. * Defines a subdivision inside a mesh
  23143. */
  23144. export class SubMesh extends BaseSubMesh implements ICullable {
  23145. /** the material index to use */
  23146. materialIndex: number;
  23147. /** vertex index start */
  23148. verticesStart: number;
  23149. /** vertices count */
  23150. verticesCount: number;
  23151. /** index start */
  23152. indexStart: number;
  23153. /** indices count */
  23154. indexCount: number;
  23155. /** @hidden */
  23156. _linesIndexCount: number;
  23157. private _mesh;
  23158. private _renderingMesh;
  23159. private _boundingInfo;
  23160. private _linesIndexBuffer;
  23161. /** @hidden */
  23162. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23163. /** @hidden */
  23164. _trianglePlanes: Plane[];
  23165. /** @hidden */
  23166. _lastColliderTransformMatrix: Nullable<Matrix>;
  23167. /** @hidden */
  23168. _renderId: number;
  23169. /** @hidden */
  23170. _alphaIndex: number;
  23171. /** @hidden */
  23172. _distanceToCamera: number;
  23173. /** @hidden */
  23174. _id: number;
  23175. private _currentMaterial;
  23176. /**
  23177. * Add a new submesh to a mesh
  23178. * @param materialIndex defines the material index to use
  23179. * @param verticesStart defines vertex index start
  23180. * @param verticesCount defines vertices count
  23181. * @param indexStart defines index start
  23182. * @param indexCount defines indices count
  23183. * @param mesh defines the parent mesh
  23184. * @param renderingMesh defines an optional rendering mesh
  23185. * @param createBoundingBox defines if bounding box should be created for this submesh
  23186. * @returns the new submesh
  23187. */
  23188. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23189. /**
  23190. * Creates a new submesh
  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. */
  23200. constructor(
  23201. /** the material index to use */
  23202. materialIndex: number,
  23203. /** vertex index start */
  23204. verticesStart: number,
  23205. /** vertices count */
  23206. verticesCount: number,
  23207. /** index start */
  23208. indexStart: number,
  23209. /** indices count */
  23210. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23211. /**
  23212. * Returns true if this submesh covers the entire parent mesh
  23213. * @ignorenaming
  23214. */
  23215. readonly IsGlobal: boolean;
  23216. /**
  23217. * Returns the submesh BoudingInfo object
  23218. * @returns current bounding info (or mesh's one if the submesh is global)
  23219. */
  23220. getBoundingInfo(): BoundingInfo;
  23221. /**
  23222. * Sets the submesh BoundingInfo
  23223. * @param boundingInfo defines the new bounding info to use
  23224. * @returns the SubMesh
  23225. */
  23226. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23227. /**
  23228. * Returns the mesh of the current submesh
  23229. * @return the parent mesh
  23230. */
  23231. getMesh(): AbstractMesh;
  23232. /**
  23233. * Returns the rendering mesh of the submesh
  23234. * @returns the rendering mesh (could be different from parent mesh)
  23235. */
  23236. getRenderingMesh(): Mesh;
  23237. /**
  23238. * Returns the submesh material
  23239. * @returns null or the current material
  23240. */
  23241. getMaterial(): Nullable<Material>;
  23242. /**
  23243. * Sets a new updated BoundingInfo object to the submesh
  23244. * @param data defines an optional position array to use to determine the bounding info
  23245. * @returns the SubMesh
  23246. */
  23247. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23248. /** @hidden */
  23249. _checkCollision(collider: Collider): boolean;
  23250. /**
  23251. * Updates the submesh BoundingInfo
  23252. * @param world defines the world matrix to use to update the bounding info
  23253. * @returns the submesh
  23254. */
  23255. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23256. /**
  23257. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23258. * @param frustumPlanes defines the frustum planes
  23259. * @returns true if the submesh is intersecting with the frustum
  23260. */
  23261. isInFrustum(frustumPlanes: Plane[]): boolean;
  23262. /**
  23263. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23264. * @param frustumPlanes defines the frustum planes
  23265. * @returns true if the submesh is inside the frustum
  23266. */
  23267. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23268. /**
  23269. * Renders the submesh
  23270. * @param enableAlphaMode defines if alpha needs to be used
  23271. * @returns the submesh
  23272. */
  23273. render(enableAlphaMode: boolean): SubMesh;
  23274. /**
  23275. * @hidden
  23276. */
  23277. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23278. /**
  23279. * Checks if the submesh intersects with a ray
  23280. * @param ray defines the ray to test
  23281. * @returns true is the passed ray intersects the submesh bounding box
  23282. */
  23283. canIntersects(ray: Ray): boolean;
  23284. /**
  23285. * Intersects current submesh with a ray
  23286. * @param ray defines the ray to test
  23287. * @param positions defines mesh's positions array
  23288. * @param indices defines mesh's indices array
  23289. * @param fastCheck defines if only bounding info should be used
  23290. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23291. * @returns intersection info or null if no intersection
  23292. */
  23293. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23294. /** @hidden */
  23295. private _intersectLines;
  23296. /** @hidden */
  23297. private _intersectTriangles;
  23298. /** @hidden */
  23299. _rebuild(): void;
  23300. /**
  23301. * Creates a new submesh from the passed mesh
  23302. * @param newMesh defines the new hosting mesh
  23303. * @param newRenderingMesh defines an optional rendering mesh
  23304. * @returns the new submesh
  23305. */
  23306. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23307. /**
  23308. * Release associated resources
  23309. */
  23310. dispose(): void;
  23311. /**
  23312. * Gets the class name
  23313. * @returns the string "SubMesh".
  23314. */
  23315. getClassName(): string;
  23316. /**
  23317. * Creates a new submesh from indices data
  23318. * @param materialIndex the index of the main mesh material
  23319. * @param startIndex the index where to start the copy in the mesh indices array
  23320. * @param indexCount the number of indices to copy then from the startIndex
  23321. * @param mesh the main mesh to create the submesh from
  23322. * @param renderingMesh the optional rendering mesh
  23323. * @returns a new submesh
  23324. */
  23325. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23326. }
  23327. }
  23328. declare module "babylonjs/Meshes/geometry" {
  23329. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23330. import { Scene } from "babylonjs/scene";
  23331. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23332. import { Engine } from "babylonjs/Engines/engine";
  23333. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23334. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23335. import { Effect } from "babylonjs/Materials/effect";
  23336. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23337. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23338. import { Mesh } from "babylonjs/Meshes/mesh";
  23339. /**
  23340. * Class used to store geometry data (vertex buffers + index buffer)
  23341. */
  23342. export class Geometry implements IGetSetVerticesData {
  23343. /**
  23344. * Gets or sets the ID of the geometry
  23345. */
  23346. id: string;
  23347. /**
  23348. * Gets or sets the unique ID of the geometry
  23349. */
  23350. uniqueId: number;
  23351. /**
  23352. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23353. */
  23354. delayLoadState: number;
  23355. /**
  23356. * Gets the file containing the data to load when running in delay load state
  23357. */
  23358. delayLoadingFile: Nullable<string>;
  23359. /**
  23360. * Callback called when the geometry is updated
  23361. */
  23362. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23363. private _scene;
  23364. private _engine;
  23365. private _meshes;
  23366. private _totalVertices;
  23367. /** @hidden */
  23368. _indices: IndicesArray;
  23369. /** @hidden */
  23370. _vertexBuffers: {
  23371. [key: string]: VertexBuffer;
  23372. };
  23373. private _isDisposed;
  23374. private _extend;
  23375. private _boundingBias;
  23376. /** @hidden */
  23377. _delayInfo: Array<string>;
  23378. private _indexBuffer;
  23379. private _indexBufferIsUpdatable;
  23380. /** @hidden */
  23381. _boundingInfo: Nullable<BoundingInfo>;
  23382. /** @hidden */
  23383. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23384. /** @hidden */
  23385. _softwareSkinningFrameId: number;
  23386. private _vertexArrayObjects;
  23387. private _updatable;
  23388. /** @hidden */
  23389. _positions: Nullable<Vector3[]>;
  23390. /**
  23391. * 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
  23392. */
  23393. /**
  23394. * 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
  23395. */
  23396. boundingBias: Vector2;
  23397. /**
  23398. * Static function used to attach a new empty geometry to a mesh
  23399. * @param mesh defines the mesh to attach the geometry to
  23400. * @returns the new Geometry
  23401. */
  23402. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23403. /**
  23404. * Creates a new geometry
  23405. * @param id defines the unique ID
  23406. * @param scene defines the hosting scene
  23407. * @param vertexData defines the VertexData used to get geometry data
  23408. * @param updatable defines if geometry must be updatable (false by default)
  23409. * @param mesh defines the mesh that will be associated with the geometry
  23410. */
  23411. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23412. /**
  23413. * Gets the current extend of the geometry
  23414. */
  23415. readonly extend: {
  23416. minimum: Vector3;
  23417. maximum: Vector3;
  23418. };
  23419. /**
  23420. * Gets the hosting scene
  23421. * @returns the hosting Scene
  23422. */
  23423. getScene(): Scene;
  23424. /**
  23425. * Gets the hosting engine
  23426. * @returns the hosting Engine
  23427. */
  23428. getEngine(): Engine;
  23429. /**
  23430. * Defines if the geometry is ready to use
  23431. * @returns true if the geometry is ready to be used
  23432. */
  23433. isReady(): boolean;
  23434. /**
  23435. * Gets a value indicating that the geometry should not be serialized
  23436. */
  23437. readonly doNotSerialize: boolean;
  23438. /** @hidden */
  23439. _rebuild(): void;
  23440. /**
  23441. * Affects all geometry data in one call
  23442. * @param vertexData defines the geometry data
  23443. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23444. */
  23445. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23446. /**
  23447. * Set specific vertex data
  23448. * @param kind defines the data kind (Position, normal, etc...)
  23449. * @param data defines the vertex data to use
  23450. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23451. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23452. */
  23453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23454. /**
  23455. * Removes a specific vertex data
  23456. * @param kind defines the data kind (Position, normal, etc...)
  23457. */
  23458. removeVerticesData(kind: string): void;
  23459. /**
  23460. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23461. * @param buffer defines the vertex buffer to use
  23462. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23463. */
  23464. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23465. /**
  23466. * Update a specific vertex buffer
  23467. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23468. * It will do nothing if the buffer is not updatable
  23469. * @param kind defines the data kind (Position, normal, etc...)
  23470. * @param data defines the data to use
  23471. * @param offset defines the offset in the target buffer where to store the data
  23472. * @param useBytes set to true if the offset is in bytes
  23473. */
  23474. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23475. /**
  23476. * Update a specific vertex buffer
  23477. * This function will create a new buffer if the current one is not updatable
  23478. * @param kind defines the data kind (Position, normal, etc...)
  23479. * @param data defines the data to use
  23480. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23481. */
  23482. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23483. private _updateBoundingInfo;
  23484. /** @hidden */
  23485. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23486. /**
  23487. * Gets total number of vertices
  23488. * @returns the total number of vertices
  23489. */
  23490. getTotalVertices(): number;
  23491. /**
  23492. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23493. * @param kind defines the data kind (Position, normal, etc...)
  23494. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23495. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23496. * @returns a float array containing vertex data
  23497. */
  23498. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23499. /**
  23500. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23501. * @param kind defines the data kind (Position, normal, etc...)
  23502. * @returns true if the vertex buffer with the specified kind is updatable
  23503. */
  23504. isVertexBufferUpdatable(kind: string): boolean;
  23505. /**
  23506. * Gets a specific vertex buffer
  23507. * @param kind defines the data kind (Position, normal, etc...)
  23508. * @returns a VertexBuffer
  23509. */
  23510. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23511. /**
  23512. * Returns all vertex buffers
  23513. * @return an object holding all vertex buffers indexed by kind
  23514. */
  23515. getVertexBuffers(): Nullable<{
  23516. [key: string]: VertexBuffer;
  23517. }>;
  23518. /**
  23519. * Gets a boolean indicating if specific vertex buffer is present
  23520. * @param kind defines the data kind (Position, normal, etc...)
  23521. * @returns true if data is present
  23522. */
  23523. isVerticesDataPresent(kind: string): boolean;
  23524. /**
  23525. * Gets a list of all attached data kinds (Position, normal, etc...)
  23526. * @returns a list of string containing all kinds
  23527. */
  23528. getVerticesDataKinds(): string[];
  23529. /**
  23530. * Update index buffer
  23531. * @param indices defines the indices to store in the index buffer
  23532. * @param offset defines the offset in the target buffer where to store the data
  23533. * @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)
  23534. */
  23535. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23536. /**
  23537. * Creates a new index buffer
  23538. * @param indices defines the indices to store in the index buffer
  23539. * @param totalVertices defines the total number of vertices (could be null)
  23540. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23541. */
  23542. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23543. /**
  23544. * Return the total number of indices
  23545. * @returns the total number of indices
  23546. */
  23547. getTotalIndices(): number;
  23548. /**
  23549. * Gets the index buffer array
  23550. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23551. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23552. * @returns the index buffer array
  23553. */
  23554. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23555. /**
  23556. * Gets the index buffer
  23557. * @return the index buffer
  23558. */
  23559. getIndexBuffer(): Nullable<DataBuffer>;
  23560. /** @hidden */
  23561. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23562. /**
  23563. * Release the associated resources for a specific mesh
  23564. * @param mesh defines the source mesh
  23565. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23566. */
  23567. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23568. /**
  23569. * Apply current geometry to a given mesh
  23570. * @param mesh defines the mesh to apply geometry to
  23571. */
  23572. applyToMesh(mesh: Mesh): void;
  23573. private _updateExtend;
  23574. private _applyToMesh;
  23575. private notifyUpdate;
  23576. /**
  23577. * Load the geometry if it was flagged as delay loaded
  23578. * @param scene defines the hosting scene
  23579. * @param onLoaded defines a callback called when the geometry is loaded
  23580. */
  23581. load(scene: Scene, onLoaded?: () => void): void;
  23582. private _queueLoad;
  23583. /**
  23584. * Invert the geometry to move from a right handed system to a left handed one.
  23585. */
  23586. toLeftHanded(): void;
  23587. /** @hidden */
  23588. _resetPointsArrayCache(): void;
  23589. /** @hidden */
  23590. _generatePointsArray(): boolean;
  23591. /**
  23592. * Gets a value indicating if the geometry is disposed
  23593. * @returns true if the geometry was disposed
  23594. */
  23595. isDisposed(): boolean;
  23596. private _disposeVertexArrayObjects;
  23597. /**
  23598. * Free all associated resources
  23599. */
  23600. dispose(): void;
  23601. /**
  23602. * Clone the current geometry into a new geometry
  23603. * @param id defines the unique ID of the new geometry
  23604. * @returns a new geometry object
  23605. */
  23606. copy(id: string): Geometry;
  23607. /**
  23608. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23609. * @return a JSON representation of the current geometry data (without the vertices data)
  23610. */
  23611. serialize(): any;
  23612. private toNumberArray;
  23613. /**
  23614. * Serialize all vertices data into a JSON oject
  23615. * @returns a JSON representation of the current geometry data
  23616. */
  23617. serializeVerticeData(): any;
  23618. /**
  23619. * Extracts a clone of a mesh geometry
  23620. * @param mesh defines the source mesh
  23621. * @param id defines the unique ID of the new geometry object
  23622. * @returns the new geometry object
  23623. */
  23624. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23625. /**
  23626. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23627. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23628. * Be aware Math.random() could cause collisions, but:
  23629. * "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"
  23630. * @returns a string containing a new GUID
  23631. */
  23632. static RandomId(): string;
  23633. /** @hidden */
  23634. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23635. private static _CleanMatricesWeights;
  23636. /**
  23637. * Create a new geometry from persisted data (Using .babylon file format)
  23638. * @param parsedVertexData defines the persisted data
  23639. * @param scene defines the hosting scene
  23640. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23641. * @returns the new geometry object
  23642. */
  23643. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23644. }
  23645. }
  23646. declare module "babylonjs/Meshes/mesh.vertexData" {
  23647. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23648. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23649. import { Geometry } from "babylonjs/Meshes/geometry";
  23650. import { Mesh } from "babylonjs/Meshes/mesh";
  23651. /**
  23652. * Define an interface for all classes that will get and set the data on vertices
  23653. */
  23654. export interface IGetSetVerticesData {
  23655. /**
  23656. * Gets a boolean indicating if specific vertex data is present
  23657. * @param kind defines the vertex data kind to use
  23658. * @returns true is data kind is present
  23659. */
  23660. isVerticesDataPresent(kind: string): boolean;
  23661. /**
  23662. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23663. * @param kind defines the data kind (Position, normal, etc...)
  23664. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23665. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23666. * @returns a float array containing vertex data
  23667. */
  23668. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23669. /**
  23670. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23671. * @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.
  23672. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23673. * @returns the indices array or an empty array if the mesh has no geometry
  23674. */
  23675. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23676. /**
  23677. * Set specific vertex data
  23678. * @param kind defines the data kind (Position, normal, etc...)
  23679. * @param data defines the vertex data to use
  23680. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23681. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23682. */
  23683. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23684. /**
  23685. * Update a specific associated vertex buffer
  23686. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23687. * - VertexBuffer.PositionKind
  23688. * - VertexBuffer.UVKind
  23689. * - VertexBuffer.UV2Kind
  23690. * - VertexBuffer.UV3Kind
  23691. * - VertexBuffer.UV4Kind
  23692. * - VertexBuffer.UV5Kind
  23693. * - VertexBuffer.UV6Kind
  23694. * - VertexBuffer.ColorKind
  23695. * - VertexBuffer.MatricesIndicesKind
  23696. * - VertexBuffer.MatricesIndicesExtraKind
  23697. * - VertexBuffer.MatricesWeightsKind
  23698. * - VertexBuffer.MatricesWeightsExtraKind
  23699. * @param data defines the data source
  23700. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23701. * @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)
  23702. */
  23703. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23704. /**
  23705. * Creates a new index buffer
  23706. * @param indices defines the indices to store in the index buffer
  23707. * @param totalVertices defines the total number of vertices (could be null)
  23708. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23709. */
  23710. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23711. }
  23712. /**
  23713. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23714. */
  23715. export class VertexData {
  23716. /**
  23717. * Mesh side orientation : usually the external or front surface
  23718. */
  23719. static readonly FRONTSIDE: number;
  23720. /**
  23721. * Mesh side orientation : usually the internal or back surface
  23722. */
  23723. static readonly BACKSIDE: number;
  23724. /**
  23725. * Mesh side orientation : both internal and external or front and back surfaces
  23726. */
  23727. static readonly DOUBLESIDE: number;
  23728. /**
  23729. * Mesh side orientation : by default, `FRONTSIDE`
  23730. */
  23731. static readonly DEFAULTSIDE: number;
  23732. /**
  23733. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23734. */
  23735. positions: Nullable<FloatArray>;
  23736. /**
  23737. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23738. */
  23739. normals: Nullable<FloatArray>;
  23740. /**
  23741. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23742. */
  23743. tangents: Nullable<FloatArray>;
  23744. /**
  23745. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23746. */
  23747. uvs: Nullable<FloatArray>;
  23748. /**
  23749. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23750. */
  23751. uvs2: Nullable<FloatArray>;
  23752. /**
  23753. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23754. */
  23755. uvs3: Nullable<FloatArray>;
  23756. /**
  23757. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23758. */
  23759. uvs4: Nullable<FloatArray>;
  23760. /**
  23761. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23762. */
  23763. uvs5: Nullable<FloatArray>;
  23764. /**
  23765. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23766. */
  23767. uvs6: Nullable<FloatArray>;
  23768. /**
  23769. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23770. */
  23771. colors: Nullable<FloatArray>;
  23772. /**
  23773. * 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).
  23774. */
  23775. matricesIndices: Nullable<FloatArray>;
  23776. /**
  23777. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23778. */
  23779. matricesWeights: Nullable<FloatArray>;
  23780. /**
  23781. * An array extending the number of possible indices
  23782. */
  23783. matricesIndicesExtra: Nullable<FloatArray>;
  23784. /**
  23785. * An array extending the number of possible weights when the number of indices is extended
  23786. */
  23787. matricesWeightsExtra: Nullable<FloatArray>;
  23788. /**
  23789. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23790. */
  23791. indices: Nullable<IndicesArray>;
  23792. /**
  23793. * Uses the passed data array to set the set the values for the specified kind of data
  23794. * @param data a linear array of floating numbers
  23795. * @param kind the type of data that is being set, eg positions, colors etc
  23796. */
  23797. set(data: FloatArray, kind: string): void;
  23798. /**
  23799. * Associates the vertexData to the passed Mesh.
  23800. * Sets it as updatable or not (default `false`)
  23801. * @param mesh the mesh the vertexData is applied to
  23802. * @param updatable when used and having the value true allows new data to update the vertexData
  23803. * @returns the VertexData
  23804. */
  23805. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23806. /**
  23807. * Associates the vertexData to the passed Geometry.
  23808. * Sets it as updatable or not (default `false`)
  23809. * @param geometry the geometry the vertexData is applied to
  23810. * @param updatable when used and having the value true allows new data to update the vertexData
  23811. * @returns VertexData
  23812. */
  23813. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23814. /**
  23815. * Updates the associated mesh
  23816. * @param mesh the mesh to be updated
  23817. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23818. * @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
  23819. * @returns VertexData
  23820. */
  23821. updateMesh(mesh: Mesh): VertexData;
  23822. /**
  23823. * Updates the associated geometry
  23824. * @param geometry the geometry to be updated
  23825. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23826. * @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
  23827. * @returns VertexData.
  23828. */
  23829. updateGeometry(geometry: Geometry): VertexData;
  23830. private _applyTo;
  23831. private _update;
  23832. /**
  23833. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23834. * @param matrix the transforming matrix
  23835. * @returns the VertexData
  23836. */
  23837. transform(matrix: Matrix): VertexData;
  23838. /**
  23839. * Merges the passed VertexData into the current one
  23840. * @param other the VertexData to be merged into the current one
  23841. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23842. * @returns the modified VertexData
  23843. */
  23844. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23845. private _mergeElement;
  23846. private _validate;
  23847. /**
  23848. * Serializes the VertexData
  23849. * @returns a serialized object
  23850. */
  23851. serialize(): any;
  23852. /**
  23853. * Extracts the vertexData from a mesh
  23854. * @param mesh the mesh from which to extract the VertexData
  23855. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23856. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23857. * @returns the object VertexData associated to the passed mesh
  23858. */
  23859. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23860. /**
  23861. * Extracts the vertexData from the geometry
  23862. * @param geometry the geometry from which to extract the VertexData
  23863. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23864. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23865. * @returns the object VertexData associated to the passed mesh
  23866. */
  23867. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23868. private static _ExtractFrom;
  23869. /**
  23870. * Creates the VertexData for a Ribbon
  23871. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23872. * * pathArray array of paths, each of which an array of successive Vector3
  23873. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23874. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23875. * * 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
  23876. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23877. * * 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)
  23878. * * 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)
  23879. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23880. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23881. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23882. * @returns the VertexData of the ribbon
  23883. */
  23884. static CreateRibbon(options: {
  23885. pathArray: Vector3[][];
  23886. closeArray?: boolean;
  23887. closePath?: boolean;
  23888. offset?: number;
  23889. sideOrientation?: number;
  23890. frontUVs?: Vector4;
  23891. backUVs?: Vector4;
  23892. invertUV?: boolean;
  23893. uvs?: Vector2[];
  23894. colors?: Color4[];
  23895. }): VertexData;
  23896. /**
  23897. * Creates the VertexData for a box
  23898. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23899. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23900. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23901. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23902. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23903. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23904. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23906. * * 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)
  23907. * * 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)
  23908. * @returns the VertexData of the box
  23909. */
  23910. static CreateBox(options: {
  23911. size?: number;
  23912. width?: number;
  23913. height?: number;
  23914. depth?: number;
  23915. faceUV?: Vector4[];
  23916. faceColors?: Color4[];
  23917. sideOrientation?: number;
  23918. frontUVs?: Vector4;
  23919. backUVs?: Vector4;
  23920. }): VertexData;
  23921. /**
  23922. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23923. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23924. * * segments sets the number of horizontal strips optional, default 32
  23925. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23926. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23927. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23928. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23929. * * 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
  23930. * * 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
  23931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23932. * * 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)
  23933. * * 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)
  23934. * @returns the VertexData of the ellipsoid
  23935. */
  23936. static CreateSphere(options: {
  23937. segments?: number;
  23938. diameter?: number;
  23939. diameterX?: number;
  23940. diameterY?: number;
  23941. diameterZ?: number;
  23942. arc?: number;
  23943. slice?: number;
  23944. sideOrientation?: number;
  23945. frontUVs?: Vector4;
  23946. backUVs?: Vector4;
  23947. }): VertexData;
  23948. /**
  23949. * Creates the VertexData for a cylinder, cone or prism
  23950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23951. * * height sets the height (y direction) of the cylinder, optional, default 2
  23952. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23953. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23954. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23955. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23956. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23957. * * 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
  23958. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23959. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23960. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23961. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23963. * * 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)
  23964. * * 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)
  23965. * @returns the VertexData of the cylinder, cone or prism
  23966. */
  23967. static CreateCylinder(options: {
  23968. height?: number;
  23969. diameterTop?: number;
  23970. diameterBottom?: number;
  23971. diameter?: number;
  23972. tessellation?: number;
  23973. subdivisions?: number;
  23974. arc?: number;
  23975. faceColors?: Color4[];
  23976. faceUV?: Vector4[];
  23977. hasRings?: boolean;
  23978. enclose?: boolean;
  23979. sideOrientation?: number;
  23980. frontUVs?: Vector4;
  23981. backUVs?: Vector4;
  23982. }): VertexData;
  23983. /**
  23984. * Creates the VertexData for a torus
  23985. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23986. * * diameter the diameter of the torus, optional default 1
  23987. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23988. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23990. * * 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)
  23991. * * 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)
  23992. * @returns the VertexData of the torus
  23993. */
  23994. static CreateTorus(options: {
  23995. diameter?: number;
  23996. thickness?: number;
  23997. tessellation?: number;
  23998. sideOrientation?: number;
  23999. frontUVs?: Vector4;
  24000. backUVs?: Vector4;
  24001. }): VertexData;
  24002. /**
  24003. * Creates the VertexData of the LineSystem
  24004. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24005. * - lines an array of lines, each line being an array of successive Vector3
  24006. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24007. * @returns the VertexData of the LineSystem
  24008. */
  24009. static CreateLineSystem(options: {
  24010. lines: Vector3[][];
  24011. colors?: Nullable<Color4[][]>;
  24012. }): VertexData;
  24013. /**
  24014. * Create the VertexData for a DashedLines
  24015. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24016. * - points an array successive Vector3
  24017. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24018. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24019. * - dashNb the intended total number of dashes, optional, default 200
  24020. * @returns the VertexData for the DashedLines
  24021. */
  24022. static CreateDashedLines(options: {
  24023. points: Vector3[];
  24024. dashSize?: number;
  24025. gapSize?: number;
  24026. dashNb?: number;
  24027. }): VertexData;
  24028. /**
  24029. * Creates the VertexData for a Ground
  24030. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24031. * - width the width (x direction) of the ground, optional, default 1
  24032. * - height the height (z direction) of the ground, optional, default 1
  24033. * - subdivisions the number of subdivisions per side, optional, default 1
  24034. * @returns the VertexData of the Ground
  24035. */
  24036. static CreateGround(options: {
  24037. width?: number;
  24038. height?: number;
  24039. subdivisions?: number;
  24040. subdivisionsX?: number;
  24041. subdivisionsY?: number;
  24042. }): VertexData;
  24043. /**
  24044. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24045. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24046. * * xmin the ground minimum X coordinate, optional, default -1
  24047. * * zmin the ground minimum Z coordinate, optional, default -1
  24048. * * xmax the ground maximum X coordinate, optional, default 1
  24049. * * zmax the ground maximum Z coordinate, optional, default 1
  24050. * * 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}
  24051. * * 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}
  24052. * @returns the VertexData of the TiledGround
  24053. */
  24054. static CreateTiledGround(options: {
  24055. xmin: number;
  24056. zmin: number;
  24057. xmax: number;
  24058. zmax: number;
  24059. subdivisions?: {
  24060. w: number;
  24061. h: number;
  24062. };
  24063. precision?: {
  24064. w: number;
  24065. h: number;
  24066. };
  24067. }): VertexData;
  24068. /**
  24069. * Creates the VertexData of the Ground designed from a heightmap
  24070. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24071. * * width the width (x direction) of the ground
  24072. * * height the height (z direction) of the ground
  24073. * * subdivisions the number of subdivisions per side
  24074. * * minHeight the minimum altitude on the ground, optional, default 0
  24075. * * maxHeight the maximum altitude on the ground, optional default 1
  24076. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24077. * * buffer the array holding the image color data
  24078. * * bufferWidth the width of image
  24079. * * bufferHeight the height of image
  24080. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24081. * @returns the VertexData of the Ground designed from a heightmap
  24082. */
  24083. static CreateGroundFromHeightMap(options: {
  24084. width: number;
  24085. height: number;
  24086. subdivisions: number;
  24087. minHeight: number;
  24088. maxHeight: number;
  24089. colorFilter: Color3;
  24090. buffer: Uint8Array;
  24091. bufferWidth: number;
  24092. bufferHeight: number;
  24093. alphaFilter: number;
  24094. }): VertexData;
  24095. /**
  24096. * Creates the VertexData for a Plane
  24097. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24098. * * size sets the width and height of the plane to the value of size, optional default 1
  24099. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24100. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24102. * * 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)
  24103. * * 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)
  24104. * @returns the VertexData of the box
  24105. */
  24106. static CreatePlane(options: {
  24107. size?: number;
  24108. width?: number;
  24109. height?: number;
  24110. sideOrientation?: number;
  24111. frontUVs?: Vector4;
  24112. backUVs?: Vector4;
  24113. }): VertexData;
  24114. /**
  24115. * Creates the VertexData of the Disc or regular Polygon
  24116. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24117. * * radius the radius of the disc, optional default 0.5
  24118. * * tessellation the number of polygon sides, optional, default 64
  24119. * * 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
  24120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24121. * * 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)
  24122. * * 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)
  24123. * @returns the VertexData of the box
  24124. */
  24125. static CreateDisc(options: {
  24126. radius?: number;
  24127. tessellation?: number;
  24128. arc?: number;
  24129. sideOrientation?: number;
  24130. frontUVs?: Vector4;
  24131. backUVs?: Vector4;
  24132. }): VertexData;
  24133. /**
  24134. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24135. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24136. * @param polygon a mesh built from polygonTriangulation.build()
  24137. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24138. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24139. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24140. * @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)
  24141. * @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)
  24142. * @returns the VertexData of the Polygon
  24143. */
  24144. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24145. /**
  24146. * Creates the VertexData of the IcoSphere
  24147. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24148. * * radius the radius of the IcoSphere, optional default 1
  24149. * * radiusX allows stretching in the x direction, optional, default radius
  24150. * * radiusY allows stretching in the y direction, optional, default radius
  24151. * * radiusZ allows stretching in the z direction, optional, default radius
  24152. * * flat when true creates a flat shaded mesh, optional, default true
  24153. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24155. * * 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)
  24156. * * 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)
  24157. * @returns the VertexData of the IcoSphere
  24158. */
  24159. static CreateIcoSphere(options: {
  24160. radius?: number;
  24161. radiusX?: number;
  24162. radiusY?: number;
  24163. radiusZ?: number;
  24164. flat?: boolean;
  24165. subdivisions?: number;
  24166. sideOrientation?: number;
  24167. frontUVs?: Vector4;
  24168. backUVs?: Vector4;
  24169. }): VertexData;
  24170. /**
  24171. * Creates the VertexData for a Polyhedron
  24172. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24173. * * type provided types are:
  24174. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24175. * * 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)
  24176. * * size the size of the IcoSphere, optional default 1
  24177. * * sizeX allows stretching in the x direction, optional, default size
  24178. * * sizeY allows stretching in the y direction, optional, default size
  24179. * * sizeZ allows stretching in the z direction, optional, default size
  24180. * * 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
  24181. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24182. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24183. * * flat when true creates a flat shaded mesh, optional, default true
  24184. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24186. * * 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)
  24187. * * 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)
  24188. * @returns the VertexData of the Polyhedron
  24189. */
  24190. static CreatePolyhedron(options: {
  24191. type?: number;
  24192. size?: number;
  24193. sizeX?: number;
  24194. sizeY?: number;
  24195. sizeZ?: number;
  24196. custom?: any;
  24197. faceUV?: Vector4[];
  24198. faceColors?: Color4[];
  24199. flat?: boolean;
  24200. sideOrientation?: number;
  24201. frontUVs?: Vector4;
  24202. backUVs?: Vector4;
  24203. }): VertexData;
  24204. /**
  24205. * Creates the VertexData for a TorusKnot
  24206. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24207. * * radius the radius of the torus knot, optional, default 2
  24208. * * tube the thickness of the tube, optional, default 0.5
  24209. * * radialSegments the number of sides on each tube segments, optional, default 32
  24210. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24211. * * p the number of windings around the z axis, optional, default 2
  24212. * * q the number of windings around the x axis, optional, default 3
  24213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24214. * * 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)
  24215. * * 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)
  24216. * @returns the VertexData of the Torus Knot
  24217. */
  24218. static CreateTorusKnot(options: {
  24219. radius?: number;
  24220. tube?: number;
  24221. radialSegments?: number;
  24222. tubularSegments?: number;
  24223. p?: number;
  24224. q?: number;
  24225. sideOrientation?: number;
  24226. frontUVs?: Vector4;
  24227. backUVs?: Vector4;
  24228. }): VertexData;
  24229. /**
  24230. * Compute normals for given positions and indices
  24231. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24232. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24233. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24234. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24235. * * facetNormals : optional array of facet normals (vector3)
  24236. * * facetPositions : optional array of facet positions (vector3)
  24237. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24238. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24239. * * bInfo : optional bounding info, required for facetPartitioning computation
  24240. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24241. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24242. * * useRightHandedSystem: optional boolean to for right handed system computation
  24243. * * depthSort : optional boolean to enable the facet depth sort computation
  24244. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24245. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24246. */
  24247. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24248. facetNormals?: any;
  24249. facetPositions?: any;
  24250. facetPartitioning?: any;
  24251. ratio?: number;
  24252. bInfo?: any;
  24253. bbSize?: Vector3;
  24254. subDiv?: any;
  24255. useRightHandedSystem?: boolean;
  24256. depthSort?: boolean;
  24257. distanceTo?: Vector3;
  24258. depthSortedFacets?: any;
  24259. }): void;
  24260. /** @hidden */
  24261. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24262. /**
  24263. * Applies VertexData created from the imported parameters to the geometry
  24264. * @param parsedVertexData the parsed data from an imported file
  24265. * @param geometry the geometry to apply the VertexData to
  24266. */
  24267. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24268. }
  24269. }
  24270. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24271. import { Nullable } from "babylonjs/types";
  24272. import { Scene } from "babylonjs/scene";
  24273. import { Vector4 } from "babylonjs/Maths/math";
  24274. import { Mesh } from "babylonjs/Meshes/mesh";
  24275. /**
  24276. * Class containing static functions to help procedurally build meshes
  24277. */
  24278. export class DiscBuilder {
  24279. /**
  24280. * Creates a plane polygonal mesh. By default, this is a disc
  24281. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24282. * * 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
  24283. * * 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
  24284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24287. * @param name defines the name of the mesh
  24288. * @param options defines the options used to create the mesh
  24289. * @param scene defines the hosting scene
  24290. * @returns the plane polygonal mesh
  24291. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24292. */
  24293. static CreateDisc(name: string, options: {
  24294. radius?: number;
  24295. tessellation?: number;
  24296. arc?: number;
  24297. updatable?: boolean;
  24298. sideOrientation?: number;
  24299. frontUVs?: Vector4;
  24300. backUVs?: Vector4;
  24301. }, scene?: Nullable<Scene>): Mesh;
  24302. }
  24303. }
  24304. declare module "babylonjs/Particles/solidParticleSystem" {
  24305. import { Vector3 } from "babylonjs/Maths/math";
  24306. import { Mesh } from "babylonjs/Meshes/mesh";
  24307. import { Scene, IDisposable } from "babylonjs/scene";
  24308. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24309. /**
  24310. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24311. *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.
  24312. * The SPS is also a particle system. It provides some methods to manage the particles.
  24313. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24314. *
  24315. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24316. */
  24317. export class SolidParticleSystem implements IDisposable {
  24318. /**
  24319. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24320. * Example : var p = SPS.particles[i];
  24321. */
  24322. particles: SolidParticle[];
  24323. /**
  24324. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24325. */
  24326. nbParticles: number;
  24327. /**
  24328. * If the particles must ever face the camera (default false). Useful for planar particles.
  24329. */
  24330. billboard: boolean;
  24331. /**
  24332. * Recompute normals when adding a shape
  24333. */
  24334. recomputeNormals: boolean;
  24335. /**
  24336. * This a counter ofr your own usage. It's not set by any SPS functions.
  24337. */
  24338. counter: number;
  24339. /**
  24340. * The SPS name. This name is also given to the underlying mesh.
  24341. */
  24342. name: string;
  24343. /**
  24344. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24345. */
  24346. mesh: Mesh;
  24347. /**
  24348. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24349. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24350. */
  24351. vars: any;
  24352. /**
  24353. * This array is populated when the SPS is set as 'pickable'.
  24354. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24355. * Each element of this array is an object `{idx: int, faceId: int}`.
  24356. * `idx` is the picked particle index in the `SPS.particles` array
  24357. * `faceId` is the picked face index counted within this particle.
  24358. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24359. */
  24360. pickedParticles: {
  24361. idx: number;
  24362. faceId: number;
  24363. }[];
  24364. /**
  24365. * This array is populated when `enableDepthSort` is set to true.
  24366. * Each element of this array is an instance of the class DepthSortedParticle.
  24367. */
  24368. depthSortedParticles: DepthSortedParticle[];
  24369. /**
  24370. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24371. * @hidden
  24372. */
  24373. _bSphereOnly: boolean;
  24374. /**
  24375. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24376. * @hidden
  24377. */
  24378. _bSphereRadiusFactor: number;
  24379. private _scene;
  24380. private _positions;
  24381. private _indices;
  24382. private _normals;
  24383. private _colors;
  24384. private _uvs;
  24385. private _indices32;
  24386. private _positions32;
  24387. private _normals32;
  24388. private _fixedNormal32;
  24389. private _colors32;
  24390. private _uvs32;
  24391. private _index;
  24392. private _updatable;
  24393. private _pickable;
  24394. private _isVisibilityBoxLocked;
  24395. private _alwaysVisible;
  24396. private _depthSort;
  24397. private _shapeCounter;
  24398. private _copy;
  24399. private _color;
  24400. private _computeParticleColor;
  24401. private _computeParticleTexture;
  24402. private _computeParticleRotation;
  24403. private _computeParticleVertex;
  24404. private _computeBoundingBox;
  24405. private _depthSortParticles;
  24406. private _camera;
  24407. private _mustUnrotateFixedNormals;
  24408. private _particlesIntersect;
  24409. private _needs32Bits;
  24410. /**
  24411. * Creates a SPS (Solid Particle System) object.
  24412. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24413. * @param scene (Scene) is the scene in which the SPS is added.
  24414. * @param options defines the options of the sps e.g.
  24415. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24416. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24417. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24418. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24419. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24420. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24421. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24422. */
  24423. constructor(name: string, scene: Scene, options?: {
  24424. updatable?: boolean;
  24425. isPickable?: boolean;
  24426. enableDepthSort?: boolean;
  24427. particleIntersection?: boolean;
  24428. boundingSphereOnly?: boolean;
  24429. bSphereRadiusFactor?: number;
  24430. });
  24431. /**
  24432. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24433. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24434. * @returns the created mesh
  24435. */
  24436. buildMesh(): Mesh;
  24437. /**
  24438. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24439. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24440. * Thus the particles generated from `digest()` have their property `position` set yet.
  24441. * @param mesh ( Mesh ) is the mesh to be digested
  24442. * @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
  24443. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24444. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24445. * @returns the current SPS
  24446. */
  24447. digest(mesh: Mesh, options?: {
  24448. facetNb?: number;
  24449. number?: number;
  24450. delta?: number;
  24451. }): SolidParticleSystem;
  24452. private _unrotateFixedNormals;
  24453. private _resetCopy;
  24454. private _meshBuilder;
  24455. private _posToShape;
  24456. private _uvsToShapeUV;
  24457. private _addParticle;
  24458. /**
  24459. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24460. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24461. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24462. * @param nb (positive integer) the number of particles to be created from this model
  24463. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24464. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24465. * @returns the number of shapes in the system
  24466. */
  24467. addShape(mesh: Mesh, nb: number, options?: {
  24468. positionFunction?: any;
  24469. vertexFunction?: any;
  24470. }): number;
  24471. private _rebuildParticle;
  24472. /**
  24473. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24474. * @returns the SPS.
  24475. */
  24476. rebuildMesh(): SolidParticleSystem;
  24477. /**
  24478. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24479. * This method calls `updateParticle()` for each particle of the SPS.
  24480. * For an animated SPS, it is usually called within the render loop.
  24481. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24482. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24483. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24484. * @returns the SPS.
  24485. */
  24486. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24487. /**
  24488. * Disposes the SPS.
  24489. */
  24490. dispose(): void;
  24491. /**
  24492. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24493. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24494. * @returns the SPS.
  24495. */
  24496. refreshVisibleSize(): SolidParticleSystem;
  24497. /**
  24498. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24499. * @param size the size (float) of the visibility box
  24500. * note : this doesn't lock the SPS mesh bounding box.
  24501. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24502. */
  24503. setVisibilityBox(size: number): void;
  24504. /**
  24505. * Gets whether the SPS as always visible or not
  24506. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24507. */
  24508. /**
  24509. * Sets the SPS as always visible or not
  24510. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24511. */
  24512. isAlwaysVisible: boolean;
  24513. /**
  24514. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24515. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24516. */
  24517. /**
  24518. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24519. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24520. */
  24521. isVisibilityBoxLocked: boolean;
  24522. /**
  24523. * Tells to `setParticles()` to compute the particle rotations or not.
  24524. * Default value : true. The SPS is faster when it's set to false.
  24525. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24526. */
  24527. /**
  24528. * Gets if `setParticles()` computes the particle rotations or not.
  24529. * Default value : true. The SPS is faster when it's set to false.
  24530. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24531. */
  24532. computeParticleRotation: boolean;
  24533. /**
  24534. * Tells to `setParticles()` to compute the particle colors or not.
  24535. * Default value : true. The SPS is faster when it's set to false.
  24536. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24537. */
  24538. /**
  24539. * Gets if `setParticles()` computes the particle colors or not.
  24540. * Default value : true. The SPS is faster when it's set to false.
  24541. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24542. */
  24543. computeParticleColor: boolean;
  24544. /**
  24545. * Gets if `setParticles()` computes the particle textures or not.
  24546. * Default value : true. The SPS is faster when it's set to false.
  24547. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24548. */
  24549. computeParticleTexture: boolean;
  24550. /**
  24551. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24552. * Default value : false. The SPS is faster when it's set to false.
  24553. * Note : the particle custom vertex positions aren't stored values.
  24554. */
  24555. /**
  24556. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24557. * Default value : false. The SPS is faster when it's set to false.
  24558. * Note : the particle custom vertex positions aren't stored values.
  24559. */
  24560. computeParticleVertex: boolean;
  24561. /**
  24562. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24563. */
  24564. /**
  24565. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24566. */
  24567. computeBoundingBox: boolean;
  24568. /**
  24569. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24570. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24571. * Default : `true`
  24572. */
  24573. /**
  24574. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24575. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24576. * Default : `true`
  24577. */
  24578. depthSortParticles: boolean;
  24579. /**
  24580. * This function does nothing. It may be overwritten to set all the particle first values.
  24581. * The SPS doesn't call this function, you may have to call it by your own.
  24582. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24583. */
  24584. initParticles(): void;
  24585. /**
  24586. * This function does nothing. It may be overwritten to recycle a particle.
  24587. * The SPS doesn't call this function, you may have to call it by your own.
  24588. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24589. * @param particle The particle to recycle
  24590. * @returns the recycled particle
  24591. */
  24592. recycleParticle(particle: SolidParticle): SolidParticle;
  24593. /**
  24594. * Updates a particle : this function should be overwritten by the user.
  24595. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24596. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24597. * @example : just set a particle position or velocity and recycle conditions
  24598. * @param particle The particle to update
  24599. * @returns the updated particle
  24600. */
  24601. updateParticle(particle: SolidParticle): SolidParticle;
  24602. /**
  24603. * Updates a vertex of a particle : it can be overwritten by the user.
  24604. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24605. * @param particle the current particle
  24606. * @param vertex the current index of the current particle
  24607. * @param pt the index of the current vertex in the particle shape
  24608. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24609. * @example : just set a vertex particle position
  24610. * @returns the updated vertex
  24611. */
  24612. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24613. /**
  24614. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24615. * This does nothing and may be overwritten by the user.
  24616. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24617. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24618. * @param update the boolean update value actually passed to setParticles()
  24619. */
  24620. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24621. /**
  24622. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24623. * This will be passed three parameters.
  24624. * This does nothing and may be overwritten by the user.
  24625. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24626. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24627. * @param update the boolean update value actually passed to setParticles()
  24628. */
  24629. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24630. }
  24631. }
  24632. declare module "babylonjs/Particles/solidParticle" {
  24633. import { Nullable } from "babylonjs/types";
  24634. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24635. import { Mesh } from "babylonjs/Meshes/mesh";
  24636. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24637. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24638. /**
  24639. * Represents one particle of a solid particle system.
  24640. */
  24641. export class SolidParticle {
  24642. /**
  24643. * particle global index
  24644. */
  24645. idx: number;
  24646. /**
  24647. * The color of the particle
  24648. */
  24649. color: Nullable<Color4>;
  24650. /**
  24651. * The world space position of the particle.
  24652. */
  24653. position: Vector3;
  24654. /**
  24655. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24656. */
  24657. rotation: Vector3;
  24658. /**
  24659. * The world space rotation quaternion of the particle.
  24660. */
  24661. rotationQuaternion: Nullable<Quaternion>;
  24662. /**
  24663. * The scaling of the particle.
  24664. */
  24665. scaling: Vector3;
  24666. /**
  24667. * The uvs of the particle.
  24668. */
  24669. uvs: Vector4;
  24670. /**
  24671. * The current speed of the particle.
  24672. */
  24673. velocity: Vector3;
  24674. /**
  24675. * The pivot point in the particle local space.
  24676. */
  24677. pivot: Vector3;
  24678. /**
  24679. * Must the particle be translated from its pivot point in its local space ?
  24680. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24681. * Default : false
  24682. */
  24683. translateFromPivot: boolean;
  24684. /**
  24685. * Is the particle active or not ?
  24686. */
  24687. alive: boolean;
  24688. /**
  24689. * Is the particle visible or not ?
  24690. */
  24691. isVisible: boolean;
  24692. /**
  24693. * Index of this particle in the global "positions" array (Internal use)
  24694. * @hidden
  24695. */
  24696. _pos: number;
  24697. /**
  24698. * @hidden Index of this particle in the global "indices" array (Internal use)
  24699. */
  24700. _ind: number;
  24701. /**
  24702. * @hidden ModelShape of this particle (Internal use)
  24703. */
  24704. _model: ModelShape;
  24705. /**
  24706. * ModelShape id of this particle
  24707. */
  24708. shapeId: number;
  24709. /**
  24710. * Index of the particle in its shape id (Internal use)
  24711. */
  24712. idxInShape: number;
  24713. /**
  24714. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24715. */
  24716. _modelBoundingInfo: BoundingInfo;
  24717. /**
  24718. * @hidden Particle BoundingInfo object (Internal use)
  24719. */
  24720. _boundingInfo: BoundingInfo;
  24721. /**
  24722. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24723. */
  24724. _sps: SolidParticleSystem;
  24725. /**
  24726. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24727. */
  24728. _stillInvisible: boolean;
  24729. /**
  24730. * @hidden Last computed particle rotation matrix
  24731. */
  24732. _rotationMatrix: number[];
  24733. /**
  24734. * Parent particle Id, if any.
  24735. * Default null.
  24736. */
  24737. parentId: Nullable<number>;
  24738. /**
  24739. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24740. * The possible values are :
  24741. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24742. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24743. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24744. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24745. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24746. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24747. * */
  24748. cullingStrategy: number;
  24749. /**
  24750. * @hidden Internal global position in the SPS.
  24751. */
  24752. _globalPosition: Vector3;
  24753. /**
  24754. * Creates a Solid Particle object.
  24755. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24756. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24757. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24758. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24759. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24760. * @param shapeId (integer) is the model shape identifier in the SPS.
  24761. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24762. * @param sps defines the sps it is associated to
  24763. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24764. */
  24765. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24766. /**
  24767. * Legacy support, changed scale to scaling
  24768. */
  24769. /**
  24770. * Legacy support, changed scale to scaling
  24771. */
  24772. scale: Vector3;
  24773. /**
  24774. * Legacy support, changed quaternion to rotationQuaternion
  24775. */
  24776. /**
  24777. * Legacy support, changed quaternion to rotationQuaternion
  24778. */
  24779. quaternion: Nullable<Quaternion>;
  24780. /**
  24781. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24782. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24783. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24784. * @returns true if it intersects
  24785. */
  24786. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24787. /**
  24788. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24789. * A particle is in the frustum if its bounding box intersects the frustum
  24790. * @param frustumPlanes defines the frustum to test
  24791. * @returns true if the particle is in the frustum planes
  24792. */
  24793. isInFrustum(frustumPlanes: Plane[]): boolean;
  24794. /**
  24795. * get the rotation matrix of the particle
  24796. * @hidden
  24797. */
  24798. getRotationMatrix(m: Matrix): void;
  24799. }
  24800. /**
  24801. * Represents the shape of the model used by one particle of a solid particle system.
  24802. * SPS internal tool, don't use it manually.
  24803. */
  24804. export class ModelShape {
  24805. /**
  24806. * The shape id
  24807. * @hidden
  24808. */
  24809. shapeID: number;
  24810. /**
  24811. * flat array of model positions (internal use)
  24812. * @hidden
  24813. */
  24814. _shape: Vector3[];
  24815. /**
  24816. * flat array of model UVs (internal use)
  24817. * @hidden
  24818. */
  24819. _shapeUV: number[];
  24820. /**
  24821. * length of the shape in the model indices array (internal use)
  24822. * @hidden
  24823. */
  24824. _indicesLength: number;
  24825. /**
  24826. * Custom position function (internal use)
  24827. * @hidden
  24828. */
  24829. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24830. /**
  24831. * Custom vertex function (internal use)
  24832. * @hidden
  24833. */
  24834. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24835. /**
  24836. * 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.
  24837. * SPS internal tool, don't use it manually.
  24838. * @hidden
  24839. */
  24840. 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>);
  24841. }
  24842. /**
  24843. * Represents a Depth Sorted Particle in the solid particle system.
  24844. */
  24845. export class DepthSortedParticle {
  24846. /**
  24847. * Index of the particle in the "indices" array
  24848. */
  24849. ind: number;
  24850. /**
  24851. * Length of the particle shape in the "indices" array
  24852. */
  24853. indicesLength: number;
  24854. /**
  24855. * Squared distance from the particle to the camera
  24856. */
  24857. sqDistance: number;
  24858. }
  24859. }
  24860. declare module "babylonjs/Meshes/abstractMesh" {
  24861. import { Observable } from "babylonjs/Misc/observable";
  24862. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24863. import { Camera } from "babylonjs/Cameras/camera";
  24864. import { Scene, IDisposable } from "babylonjs/scene";
  24865. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24866. import { Node } from "babylonjs/node";
  24867. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24869. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24870. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24871. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24872. import { Material } from "babylonjs/Materials/material";
  24873. import { Light } from "babylonjs/Lights/light";
  24874. import { Skeleton } from "babylonjs/Bones/skeleton";
  24875. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24876. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24877. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24878. import { Ray } from "babylonjs/Culling/ray";
  24879. import { Collider } from "babylonjs/Collisions/collider";
  24880. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24881. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24882. /**
  24883. * Class used to store all common mesh properties
  24884. */
  24885. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24886. /** No occlusion */
  24887. static OCCLUSION_TYPE_NONE: number;
  24888. /** Occlusion set to optimisitic */
  24889. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24890. /** Occlusion set to strict */
  24891. static OCCLUSION_TYPE_STRICT: number;
  24892. /** Use an accurante occlusion algorithm */
  24893. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24894. /** Use a conservative occlusion algorithm */
  24895. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24896. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24897. * Test order :
  24898. * Is the bounding sphere outside the frustum ?
  24899. * If not, are the bounding box vertices outside the frustum ?
  24900. * It not, then the cullable object is in the frustum.
  24901. */
  24902. static readonly CULLINGSTRATEGY_STANDARD: number;
  24903. /** Culling strategy : Bounding Sphere Only.
  24904. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24905. * It's also less accurate than the standard because some not visible objects can still be selected.
  24906. * Test : is the bounding sphere outside the frustum ?
  24907. * If not, then the cullable object is in the frustum.
  24908. */
  24909. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24910. /** Culling strategy : Optimistic Inclusion.
  24911. * This in an inclusion test first, then the standard exclusion test.
  24912. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24913. * 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.
  24914. * Anyway, it's as accurate as the standard strategy.
  24915. * Test :
  24916. * Is the cullable object bounding sphere center in the frustum ?
  24917. * If not, apply the default culling strategy.
  24918. */
  24919. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24920. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24921. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24922. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24923. * 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.
  24924. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24925. * Test :
  24926. * Is the cullable object bounding sphere center in the frustum ?
  24927. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24928. */
  24929. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24930. /**
  24931. * No billboard
  24932. */
  24933. static readonly BILLBOARDMODE_NONE: number;
  24934. /** Billboard on X axis */
  24935. static readonly BILLBOARDMODE_X: number;
  24936. /** Billboard on Y axis */
  24937. static readonly BILLBOARDMODE_Y: number;
  24938. /** Billboard on Z axis */
  24939. static readonly BILLBOARDMODE_Z: number;
  24940. /** Billboard on all axes */
  24941. static readonly BILLBOARDMODE_ALL: number;
  24942. private _facetData;
  24943. /**
  24944. * The culling strategy to use to check whether the mesh must be rendered or not.
  24945. * This value can be changed at any time and will be used on the next render mesh selection.
  24946. * The possible values are :
  24947. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24948. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24949. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24950. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24951. * Please read each static variable documentation to get details about the culling process.
  24952. * */
  24953. cullingStrategy: number;
  24954. /**
  24955. * Gets the number of facets in the mesh
  24956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24957. */
  24958. readonly facetNb: number;
  24959. /**
  24960. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24962. */
  24963. partitioningSubdivisions: number;
  24964. /**
  24965. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24966. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24968. */
  24969. partitioningBBoxRatio: number;
  24970. /**
  24971. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24972. * Works only for updatable meshes.
  24973. * Doesn't work with multi-materials
  24974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24975. */
  24976. mustDepthSortFacets: boolean;
  24977. /**
  24978. * The location (Vector3) where the facet depth sort must be computed from.
  24979. * By default, the active camera position.
  24980. * Used only when facet depth sort is enabled
  24981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24982. */
  24983. facetDepthSortFrom: Vector3;
  24984. /**
  24985. * gets a boolean indicating if facetData is enabled
  24986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24987. */
  24988. readonly isFacetDataEnabled: boolean;
  24989. /** @hidden */
  24990. _updateNonUniformScalingState(value: boolean): boolean;
  24991. /**
  24992. * An event triggered when this mesh collides with another one
  24993. */
  24994. onCollideObservable: Observable<AbstractMesh>;
  24995. private _onCollideObserver;
  24996. /** Set a function to call when this mesh collides with another one */
  24997. onCollide: () => void;
  24998. /**
  24999. * An event triggered when the collision's position changes
  25000. */
  25001. onCollisionPositionChangeObservable: Observable<Vector3>;
  25002. private _onCollisionPositionChangeObserver;
  25003. /** Set a function to call when the collision's position changes */
  25004. onCollisionPositionChange: () => void;
  25005. /**
  25006. * An event triggered when material is changed
  25007. */
  25008. onMaterialChangedObservable: Observable<AbstractMesh>;
  25009. /**
  25010. * Gets or sets the orientation for POV movement & rotation
  25011. */
  25012. definedFacingForward: boolean;
  25013. /** @hidden */
  25014. _occlusionQuery: Nullable<WebGLQuery>;
  25015. private _visibility;
  25016. /** @hidden */
  25017. _isActive: boolean;
  25018. /** @hidden */
  25019. _onlyForInstances: boolean;
  25020. /** @hidden */
  25021. _renderingGroup: Nullable<RenderingGroup>;
  25022. /**
  25023. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25024. */
  25025. /**
  25026. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25027. */
  25028. visibility: number;
  25029. /** Gets or sets the alpha index used to sort transparent meshes
  25030. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25031. */
  25032. alphaIndex: number;
  25033. /**
  25034. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25035. */
  25036. isVisible: boolean;
  25037. /**
  25038. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25039. */
  25040. isPickable: boolean;
  25041. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25042. showSubMeshesBoundingBox: boolean;
  25043. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25044. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25045. */
  25046. isBlocker: boolean;
  25047. /**
  25048. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25049. */
  25050. enablePointerMoveEvents: boolean;
  25051. /**
  25052. * Specifies the rendering group id for this mesh (0 by default)
  25053. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25054. */
  25055. renderingGroupId: number;
  25056. private _material;
  25057. /** Gets or sets current material */
  25058. material: Nullable<Material>;
  25059. private _receiveShadows;
  25060. /**
  25061. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25062. * @see http://doc.babylonjs.com/babylon101/shadows
  25063. */
  25064. receiveShadows: boolean;
  25065. /** Defines color to use when rendering outline */
  25066. outlineColor: Color3;
  25067. /** Define width to use when rendering outline */
  25068. outlineWidth: number;
  25069. /** Defines color to use when rendering overlay */
  25070. overlayColor: Color3;
  25071. /** Defines alpha to use when rendering overlay */
  25072. overlayAlpha: number;
  25073. private _hasVertexAlpha;
  25074. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25075. hasVertexAlpha: boolean;
  25076. private _useVertexColors;
  25077. /** 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) */
  25078. useVertexColors: boolean;
  25079. private _computeBonesUsingShaders;
  25080. /**
  25081. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25082. */
  25083. computeBonesUsingShaders: boolean;
  25084. private _numBoneInfluencers;
  25085. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25086. numBoneInfluencers: number;
  25087. private _applyFog;
  25088. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25089. applyFog: boolean;
  25090. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25091. useOctreeForRenderingSelection: boolean;
  25092. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25093. useOctreeForPicking: boolean;
  25094. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25095. useOctreeForCollisions: boolean;
  25096. private _layerMask;
  25097. /**
  25098. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25099. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25100. */
  25101. layerMask: number;
  25102. /**
  25103. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25104. */
  25105. alwaysSelectAsActiveMesh: boolean;
  25106. /**
  25107. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25108. */
  25109. doNotSyncBoundingInfo: boolean;
  25110. /**
  25111. * Gets or sets the current action manager
  25112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25113. */
  25114. actionManager: Nullable<AbstractActionManager>;
  25115. private _checkCollisions;
  25116. private _collisionMask;
  25117. private _collisionGroup;
  25118. /**
  25119. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25121. */
  25122. ellipsoid: Vector3;
  25123. /**
  25124. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25126. */
  25127. ellipsoidOffset: Vector3;
  25128. private _collider;
  25129. private _oldPositionForCollisions;
  25130. private _diffPositionForCollisions;
  25131. /**
  25132. * Gets or sets a collision mask used to mask collisions (default is -1).
  25133. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25134. */
  25135. collisionMask: number;
  25136. /**
  25137. * Gets or sets the current collision group mask (-1 by default).
  25138. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25139. */
  25140. collisionGroup: number;
  25141. /**
  25142. * Defines edge width used when edgesRenderer is enabled
  25143. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25144. */
  25145. edgesWidth: number;
  25146. /**
  25147. * Defines edge color used when edgesRenderer is enabled
  25148. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25149. */
  25150. edgesColor: Color4;
  25151. /** @hidden */
  25152. _edgesRenderer: Nullable<IEdgesRenderer>;
  25153. /** @hidden */
  25154. _masterMesh: Nullable<AbstractMesh>;
  25155. /** @hidden */
  25156. _boundingInfo: Nullable<BoundingInfo>;
  25157. /** @hidden */
  25158. _renderId: number;
  25159. /**
  25160. * Gets or sets the list of subMeshes
  25161. * @see http://doc.babylonjs.com/how_to/multi_materials
  25162. */
  25163. subMeshes: SubMesh[];
  25164. /** @hidden */
  25165. _intersectionsInProgress: AbstractMesh[];
  25166. /** @hidden */
  25167. _unIndexed: boolean;
  25168. /** @hidden */
  25169. _lightSources: Light[];
  25170. /** Gets the list of lights affecting that mesh */
  25171. readonly lightSources: Light[];
  25172. /** @hidden */
  25173. readonly _positions: Nullable<Vector3[]>;
  25174. /** @hidden */
  25175. _waitingActions: Nullable<any>;
  25176. /** @hidden */
  25177. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25178. private _skeleton;
  25179. /** @hidden */
  25180. _bonesTransformMatrices: Nullable<Float32Array>;
  25181. /**
  25182. * Gets or sets a skeleton to apply skining transformations
  25183. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25184. */
  25185. skeleton: Nullable<Skeleton>;
  25186. /**
  25187. * An event triggered when the mesh is rebuilt.
  25188. */
  25189. onRebuildObservable: Observable<AbstractMesh>;
  25190. /**
  25191. * Creates a new AbstractMesh
  25192. * @param name defines the name of the mesh
  25193. * @param scene defines the hosting scene
  25194. */
  25195. constructor(name: string, scene?: Nullable<Scene>);
  25196. /**
  25197. * Returns the string "AbstractMesh"
  25198. * @returns "AbstractMesh"
  25199. */
  25200. getClassName(): string;
  25201. /**
  25202. * Gets a string representation of the current mesh
  25203. * @param fullDetails defines a boolean indicating if full details must be included
  25204. * @returns a string representation of the current mesh
  25205. */
  25206. toString(fullDetails?: boolean): string;
  25207. /**
  25208. * @hidden
  25209. */
  25210. protected _getEffectiveParent(): Nullable<Node>;
  25211. /** @hidden */
  25212. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25213. /** @hidden */
  25214. _rebuild(): void;
  25215. /** @hidden */
  25216. _resyncLightSources(): void;
  25217. /** @hidden */
  25218. _resyncLighSource(light: Light): void;
  25219. /** @hidden */
  25220. _unBindEffect(): void;
  25221. /** @hidden */
  25222. _removeLightSource(light: Light): void;
  25223. private _markSubMeshesAsDirty;
  25224. /** @hidden */
  25225. _markSubMeshesAsLightDirty(): void;
  25226. /** @hidden */
  25227. _markSubMeshesAsAttributesDirty(): void;
  25228. /** @hidden */
  25229. _markSubMeshesAsMiscDirty(): void;
  25230. /**
  25231. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25232. */
  25233. scaling: Vector3;
  25234. /**
  25235. * Returns true if the mesh is blocked. Implemented by child classes
  25236. */
  25237. readonly isBlocked: boolean;
  25238. /**
  25239. * Returns the mesh itself by default. Implemented by child classes
  25240. * @param camera defines the camera to use to pick the right LOD level
  25241. * @returns the currentAbstractMesh
  25242. */
  25243. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25244. /**
  25245. * Returns 0 by default. Implemented by child classes
  25246. * @returns an integer
  25247. */
  25248. getTotalVertices(): number;
  25249. /**
  25250. * Returns a positive integer : the total number of indices in this mesh geometry.
  25251. * @returns the numner of indices or zero if the mesh has no geometry.
  25252. */
  25253. getTotalIndices(): number;
  25254. /**
  25255. * Returns null by default. Implemented by child classes
  25256. * @returns null
  25257. */
  25258. getIndices(): Nullable<IndicesArray>;
  25259. /**
  25260. * Returns the array of the requested vertex data kind. Implemented by child classes
  25261. * @param kind defines the vertex data kind to use
  25262. * @returns null
  25263. */
  25264. getVerticesData(kind: string): Nullable<FloatArray>;
  25265. /**
  25266. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25267. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25268. * Note that a new underlying VertexBuffer object is created each call.
  25269. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25270. * @param kind defines vertex data kind:
  25271. * * VertexBuffer.PositionKind
  25272. * * VertexBuffer.UVKind
  25273. * * VertexBuffer.UV2Kind
  25274. * * VertexBuffer.UV3Kind
  25275. * * VertexBuffer.UV4Kind
  25276. * * VertexBuffer.UV5Kind
  25277. * * VertexBuffer.UV6Kind
  25278. * * VertexBuffer.ColorKind
  25279. * * VertexBuffer.MatricesIndicesKind
  25280. * * VertexBuffer.MatricesIndicesExtraKind
  25281. * * VertexBuffer.MatricesWeightsKind
  25282. * * VertexBuffer.MatricesWeightsExtraKind
  25283. * @param data defines the data source
  25284. * @param updatable defines if the data must be flagged as updatable (or static)
  25285. * @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
  25286. * @returns the current mesh
  25287. */
  25288. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25289. /**
  25290. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25291. * If the mesh has no geometry, it is simply returned as it is.
  25292. * @param kind defines vertex data kind:
  25293. * * VertexBuffer.PositionKind
  25294. * * VertexBuffer.UVKind
  25295. * * VertexBuffer.UV2Kind
  25296. * * VertexBuffer.UV3Kind
  25297. * * VertexBuffer.UV4Kind
  25298. * * VertexBuffer.UV5Kind
  25299. * * VertexBuffer.UV6Kind
  25300. * * VertexBuffer.ColorKind
  25301. * * VertexBuffer.MatricesIndicesKind
  25302. * * VertexBuffer.MatricesIndicesExtraKind
  25303. * * VertexBuffer.MatricesWeightsKind
  25304. * * VertexBuffer.MatricesWeightsExtraKind
  25305. * @param data defines the data source
  25306. * @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
  25307. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25308. * @returns the current mesh
  25309. */
  25310. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25311. /**
  25312. * Sets the mesh indices,
  25313. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25314. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25315. * @param totalVertices Defines the total number of vertices
  25316. * @returns the current mesh
  25317. */
  25318. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25319. /**
  25320. * Gets a boolean indicating if specific vertex data is present
  25321. * @param kind defines the vertex data kind to use
  25322. * @returns true is data kind is present
  25323. */
  25324. isVerticesDataPresent(kind: string): boolean;
  25325. /**
  25326. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25327. * @returns a BoundingInfo
  25328. */
  25329. getBoundingInfo(): BoundingInfo;
  25330. /**
  25331. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25332. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25333. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25334. * @returns the current mesh
  25335. */
  25336. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25337. /**
  25338. * Overwrite the current bounding info
  25339. * @param boundingInfo defines the new bounding info
  25340. * @returns the current mesh
  25341. */
  25342. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25343. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25344. readonly useBones: boolean;
  25345. /** @hidden */
  25346. _preActivate(): void;
  25347. /** @hidden */
  25348. _preActivateForIntermediateRendering(renderId: number): void;
  25349. /** @hidden */
  25350. _activate(renderId: number): boolean;
  25351. /** @hidden */
  25352. _freeze(): void;
  25353. /** @hidden */
  25354. _unFreeze(): void;
  25355. /**
  25356. * Gets the current world matrix
  25357. * @returns a Matrix
  25358. */
  25359. getWorldMatrix(): Matrix;
  25360. /** @hidden */
  25361. _getWorldMatrixDeterminant(): number;
  25362. /**
  25363. * Perform relative position change from the point of view of behind the front of the mesh.
  25364. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25365. * Supports definition of mesh facing forward or backward
  25366. * @param amountRight defines the distance on the right axis
  25367. * @param amountUp defines the distance on the up axis
  25368. * @param amountForward defines the distance on the forward axis
  25369. * @returns the current mesh
  25370. */
  25371. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25372. /**
  25373. * Calculate relative position change from the point of view of behind the front of the mesh.
  25374. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25375. * Supports definition of mesh facing forward or backward
  25376. * @param amountRight defines the distance on the right axis
  25377. * @param amountUp defines the distance on the up axis
  25378. * @param amountForward defines the distance on the forward axis
  25379. * @returns the new displacement vector
  25380. */
  25381. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25382. /**
  25383. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25384. * Supports definition of mesh facing forward or backward
  25385. * @param flipBack defines the flip
  25386. * @param twirlClockwise defines the twirl
  25387. * @param tiltRight defines the tilt
  25388. * @returns the current mesh
  25389. */
  25390. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25391. /**
  25392. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25393. * Supports definition of mesh facing forward or backward.
  25394. * @param flipBack defines the flip
  25395. * @param twirlClockwise defines the twirl
  25396. * @param tiltRight defines the tilt
  25397. * @returns the new rotation vector
  25398. */
  25399. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25400. /**
  25401. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25402. * This means the mesh underlying bounding box and sphere are recomputed.
  25403. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25404. * @returns the current mesh
  25405. */
  25406. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25407. /** @hidden */
  25408. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25409. /** @hidden */
  25410. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25411. /** @hidden */
  25412. _updateBoundingInfo(): AbstractMesh;
  25413. /** @hidden */
  25414. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25415. /** @hidden */
  25416. protected _afterComputeWorldMatrix(): void;
  25417. /** @hidden */
  25418. readonly _effectiveMesh: AbstractMesh;
  25419. /**
  25420. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25421. * A mesh is in the frustum if its bounding box intersects the frustum
  25422. * @param frustumPlanes defines the frustum to test
  25423. * @returns true if the mesh is in the frustum planes
  25424. */
  25425. isInFrustum(frustumPlanes: Plane[]): boolean;
  25426. /**
  25427. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25428. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25429. * @param frustumPlanes defines the frustum to test
  25430. * @returns true if the mesh is completely in the frustum planes
  25431. */
  25432. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25433. /**
  25434. * True if the mesh intersects another mesh or a SolidParticle object
  25435. * @param mesh defines a target mesh or SolidParticle to test
  25436. * @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)
  25437. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25438. * @returns true if there is an intersection
  25439. */
  25440. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25441. /**
  25442. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25443. * @param point defines the point to test
  25444. * @returns true if there is an intersection
  25445. */
  25446. intersectsPoint(point: Vector3): boolean;
  25447. /**
  25448. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25450. */
  25451. checkCollisions: boolean;
  25452. /**
  25453. * Gets Collider object used to compute collisions (not physics)
  25454. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25455. */
  25456. readonly collider: Nullable<Collider>;
  25457. /**
  25458. * Move the mesh using collision engine
  25459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25460. * @param displacement defines the requested displacement vector
  25461. * @returns the current mesh
  25462. */
  25463. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25464. private _onCollisionPositionChange;
  25465. /** @hidden */
  25466. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25467. /** @hidden */
  25468. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25469. /** @hidden */
  25470. _checkCollision(collider: Collider): AbstractMesh;
  25471. /** @hidden */
  25472. _generatePointsArray(): boolean;
  25473. /**
  25474. * Checks if the passed Ray intersects with the mesh
  25475. * @param ray defines the ray to use
  25476. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25477. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25478. * @returns the picking info
  25479. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25480. */
  25481. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25482. /**
  25483. * Clones the current mesh
  25484. * @param name defines the mesh name
  25485. * @param newParent defines the new mesh parent
  25486. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25487. * @returns the new mesh
  25488. */
  25489. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25490. /**
  25491. * Disposes all the submeshes of the current meshnp
  25492. * @returns the current mesh
  25493. */
  25494. releaseSubMeshes(): AbstractMesh;
  25495. /**
  25496. * Releases resources associated with this abstract mesh.
  25497. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25498. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25499. */
  25500. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25501. /**
  25502. * Adds the passed mesh as a child to the current mesh
  25503. * @param mesh defines the child mesh
  25504. * @returns the current mesh
  25505. */
  25506. addChild(mesh: AbstractMesh): AbstractMesh;
  25507. /**
  25508. * Removes the passed mesh from the current mesh children list
  25509. * @param mesh defines the child mesh
  25510. * @returns the current mesh
  25511. */
  25512. removeChild(mesh: AbstractMesh): AbstractMesh;
  25513. /** @hidden */
  25514. private _initFacetData;
  25515. /**
  25516. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25517. * This method can be called within the render loop.
  25518. * 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
  25519. * @returns the current mesh
  25520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25521. */
  25522. updateFacetData(): AbstractMesh;
  25523. /**
  25524. * Returns the facetLocalNormals array.
  25525. * The normals are expressed in the mesh local spac
  25526. * @returns an array of Vector3
  25527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25528. */
  25529. getFacetLocalNormals(): Vector3[];
  25530. /**
  25531. * Returns the facetLocalPositions array.
  25532. * The facet positions are expressed in the mesh local space
  25533. * @returns an array of Vector3
  25534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25535. */
  25536. getFacetLocalPositions(): Vector3[];
  25537. /**
  25538. * Returns the facetLocalPartioning array
  25539. * @returns an array of array of numbers
  25540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25541. */
  25542. getFacetLocalPartitioning(): number[][];
  25543. /**
  25544. * Returns the i-th facet position in the world system.
  25545. * This method allocates a new Vector3 per call
  25546. * @param i defines the facet index
  25547. * @returns a new Vector3
  25548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25549. */
  25550. getFacetPosition(i: number): Vector3;
  25551. /**
  25552. * Sets the reference Vector3 with the i-th facet position in the world system
  25553. * @param i defines the facet index
  25554. * @param ref defines the target vector
  25555. * @returns the current mesh
  25556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25557. */
  25558. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25559. /**
  25560. * Returns the i-th facet normal in the world system.
  25561. * This method allocates a new Vector3 per call
  25562. * @param i defines the facet index
  25563. * @returns a new Vector3
  25564. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25565. */
  25566. getFacetNormal(i: number): Vector3;
  25567. /**
  25568. * Sets the reference Vector3 with the i-th facet normal in the world system
  25569. * @param i defines the facet index
  25570. * @param ref defines the target vector
  25571. * @returns the current mesh
  25572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25573. */
  25574. getFacetNormalToRef(i: number, ref: Vector3): this;
  25575. /**
  25576. * 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)
  25577. * @param x defines x coordinate
  25578. * @param y defines y coordinate
  25579. * @param z defines z coordinate
  25580. * @returns the array of facet indexes
  25581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25582. */
  25583. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25584. /**
  25585. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25586. * @param projected sets as the (x,y,z) world projection on the facet
  25587. * @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
  25588. * @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
  25589. * @param x defines x coordinate
  25590. * @param y defines y coordinate
  25591. * @param z defines z coordinate
  25592. * @returns the face index if found (or null instead)
  25593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25594. */
  25595. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25596. /**
  25597. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25598. * @param projected sets as the (x,y,z) local projection on the facet
  25599. * @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
  25600. * @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
  25601. * @param x defines x coordinate
  25602. * @param y defines y coordinate
  25603. * @param z defines z coordinate
  25604. * @returns the face index if found (or null instead)
  25605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25606. */
  25607. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25608. /**
  25609. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25610. * @returns the parameters
  25611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25612. */
  25613. getFacetDataParameters(): any;
  25614. /**
  25615. * Disables the feature FacetData and frees the related memory
  25616. * @returns the current mesh
  25617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25618. */
  25619. disableFacetData(): AbstractMesh;
  25620. /**
  25621. * Updates the AbstractMesh indices array
  25622. * @param indices defines the data source
  25623. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25624. * @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)
  25625. * @returns the current mesh
  25626. */
  25627. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25628. /**
  25629. * Creates new normals data for the mesh
  25630. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25631. * @returns the current mesh
  25632. */
  25633. createNormals(updatable: boolean): AbstractMesh;
  25634. /**
  25635. * Align the mesh with a normal
  25636. * @param normal defines the normal to use
  25637. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25638. * @returns the current mesh
  25639. */
  25640. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25641. /** @hidden */
  25642. _checkOcclusionQuery(): boolean;
  25643. }
  25644. }
  25645. declare module "babylonjs/Actions/actionEvent" {
  25646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25647. import { Nullable } from "babylonjs/types";
  25648. import { Sprite } from "babylonjs/Sprites/sprite";
  25649. import { Scene } from "babylonjs/scene";
  25650. import { Vector2 } from "babylonjs/Maths/math";
  25651. /**
  25652. * Interface used to define ActionEvent
  25653. */
  25654. export interface IActionEvent {
  25655. /** The mesh or sprite that triggered the action */
  25656. source: any;
  25657. /** The X mouse cursor position at the time of the event */
  25658. pointerX: number;
  25659. /** The Y mouse cursor position at the time of the event */
  25660. pointerY: number;
  25661. /** The mesh that is currently pointed at (can be null) */
  25662. meshUnderPointer: Nullable<AbstractMesh>;
  25663. /** the original (browser) event that triggered the ActionEvent */
  25664. sourceEvent?: any;
  25665. /** additional data for the event */
  25666. additionalData?: any;
  25667. }
  25668. /**
  25669. * ActionEvent is the event being sent when an action is triggered.
  25670. */
  25671. export class ActionEvent implements 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. * Creates a new ActionEvent
  25686. * @param source The mesh or sprite that triggered the action
  25687. * @param pointerX The X mouse cursor position at the time of the event
  25688. * @param pointerY The Y mouse cursor position at the time of the event
  25689. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25690. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25691. * @param additionalData additional data for the event
  25692. */
  25693. constructor(
  25694. /** The mesh or sprite that triggered the action */
  25695. source: any,
  25696. /** The X mouse cursor position at the time of the event */
  25697. pointerX: number,
  25698. /** The Y mouse cursor position at the time of the event */
  25699. pointerY: number,
  25700. /** The mesh that is currently pointed at (can be null) */
  25701. meshUnderPointer: Nullable<AbstractMesh>,
  25702. /** the original (browser) event that triggered the ActionEvent */
  25703. sourceEvent?: any,
  25704. /** additional data for the event */
  25705. additionalData?: any);
  25706. /**
  25707. * Helper function to auto-create an ActionEvent from a source mesh.
  25708. * @param source The source mesh that triggered the event
  25709. * @param evt The original (browser) event
  25710. * @param additionalData additional data for the event
  25711. * @returns the new ActionEvent
  25712. */
  25713. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25714. /**
  25715. * Helper function to auto-create an ActionEvent from a source sprite
  25716. * @param source The source sprite that triggered the event
  25717. * @param scene Scene associated with the sprite
  25718. * @param evt The original (browser) event
  25719. * @param additionalData additional data for the event
  25720. * @returns the new ActionEvent
  25721. */
  25722. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25723. /**
  25724. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25725. * @param scene the scene where the event occurred
  25726. * @param evt The original (browser) event
  25727. * @returns the new ActionEvent
  25728. */
  25729. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25730. /**
  25731. * Helper function to auto-create an ActionEvent from a primitive
  25732. * @param prim defines the target primitive
  25733. * @param pointerPos defines the pointer position
  25734. * @param evt The original (browser) event
  25735. * @param additionalData additional data for the event
  25736. * @returns the new ActionEvent
  25737. */
  25738. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25739. }
  25740. }
  25741. declare module "babylonjs/Actions/abstractActionManager" {
  25742. import { IDisposable } from "babylonjs/scene";
  25743. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25744. import { IAction } from "babylonjs/Actions/action";
  25745. import { Nullable } from "babylonjs/types";
  25746. /**
  25747. * Abstract class used to decouple action Manager from scene and meshes.
  25748. * Do not instantiate.
  25749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25750. */
  25751. export abstract class AbstractActionManager implements IDisposable {
  25752. /** Gets the list of active triggers */
  25753. static Triggers: {
  25754. [key: string]: number;
  25755. };
  25756. /** Gets the cursor to use when hovering items */
  25757. hoverCursor: string;
  25758. /** Gets the list of actions */
  25759. actions: IAction[];
  25760. /**
  25761. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25762. */
  25763. isRecursive: boolean;
  25764. /**
  25765. * Releases all associated resources
  25766. */
  25767. abstract dispose(): void;
  25768. /**
  25769. * Does this action manager has pointer triggers
  25770. */
  25771. abstract readonly hasPointerTriggers: boolean;
  25772. /**
  25773. * Does this action manager has pick triggers
  25774. */
  25775. abstract readonly hasPickTriggers: boolean;
  25776. /**
  25777. * Process a specific trigger
  25778. * @param trigger defines the trigger to process
  25779. * @param evt defines the event details to be processed
  25780. */
  25781. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25782. /**
  25783. * Does this action manager handles actions of any of the given triggers
  25784. * @param triggers defines the triggers to be tested
  25785. * @return a boolean indicating whether one (or more) of the triggers is handled
  25786. */
  25787. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25788. /**
  25789. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25790. * speed.
  25791. * @param triggerA defines the trigger to be tested
  25792. * @param triggerB defines the trigger to be tested
  25793. * @return a boolean indicating whether one (or more) of the triggers is handled
  25794. */
  25795. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25796. /**
  25797. * Does this action manager handles actions of a given trigger
  25798. * @param trigger defines the trigger to be tested
  25799. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25800. * @return whether the trigger is handled
  25801. */
  25802. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25803. /**
  25804. * Serialize this manager to a JSON object
  25805. * @param name defines the property name to store this manager
  25806. * @returns a JSON representation of this manager
  25807. */
  25808. abstract serialize(name: string): any;
  25809. /**
  25810. * Registers an action to this action manager
  25811. * @param action defines the action to be registered
  25812. * @return the action amended (prepared) after registration
  25813. */
  25814. abstract registerAction(action: IAction): Nullable<IAction>;
  25815. /**
  25816. * Unregisters an action to this action manager
  25817. * @param action defines the action to be unregistered
  25818. * @return a boolean indicating whether the action has been unregistered
  25819. */
  25820. abstract unregisterAction(action: IAction): Boolean;
  25821. /**
  25822. * Does exist one action manager with at least one trigger
  25823. **/
  25824. static readonly HasTriggers: boolean;
  25825. /**
  25826. * Does exist one action manager with at least one pick trigger
  25827. **/
  25828. static readonly HasPickTriggers: boolean;
  25829. /**
  25830. * Does exist one action manager that handles actions of a given trigger
  25831. * @param trigger defines the trigger to be tested
  25832. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25833. **/
  25834. static HasSpecificTrigger(trigger: number): boolean;
  25835. }
  25836. }
  25837. declare module "babylonjs/node" {
  25838. import { Scene } from "babylonjs/scene";
  25839. import { Nullable } from "babylonjs/types";
  25840. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25841. import { Engine } from "babylonjs/Engines/engine";
  25842. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25843. import { Observable } from "babylonjs/Misc/observable";
  25844. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25845. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25846. import { Animatable } from "babylonjs/Animations/animatable";
  25847. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25848. import { Animation } from "babylonjs/Animations/animation";
  25849. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25851. /**
  25852. * Defines how a node can be built from a string name.
  25853. */
  25854. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25855. /**
  25856. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25857. */
  25858. export class Node implements IBehaviorAware<Node> {
  25859. /** @hidden */
  25860. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25861. private static _NodeConstructors;
  25862. /**
  25863. * Add a new node constructor
  25864. * @param type defines the type name of the node to construct
  25865. * @param constructorFunc defines the constructor function
  25866. */
  25867. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25868. /**
  25869. * Returns a node constructor based on type name
  25870. * @param type defines the type name
  25871. * @param name defines the new node name
  25872. * @param scene defines the hosting scene
  25873. * @param options defines optional options to transmit to constructors
  25874. * @returns the new constructor or null
  25875. */
  25876. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25877. /**
  25878. * Gets or sets the name of the node
  25879. */
  25880. name: string;
  25881. /**
  25882. * Gets or sets the id of the node
  25883. */
  25884. id: string;
  25885. /**
  25886. * Gets or sets the unique id of the node
  25887. */
  25888. uniqueId: number;
  25889. /**
  25890. * Gets or sets a string used to store user defined state for the node
  25891. */
  25892. state: string;
  25893. /**
  25894. * Gets or sets an object used to store user defined information for the node
  25895. */
  25896. metadata: any;
  25897. /**
  25898. * For internal use only. Please do not use.
  25899. */
  25900. reservedDataStore: any;
  25901. /**
  25902. * List of inspectable custom properties (used by the Inspector)
  25903. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25904. */
  25905. inspectableCustomProperties: IInspectable[];
  25906. /**
  25907. * Gets or sets a boolean used to define if the node must be serialized
  25908. */
  25909. doNotSerialize: boolean;
  25910. /** @hidden */
  25911. _isDisposed: boolean;
  25912. /**
  25913. * Gets a list of Animations associated with the node
  25914. */
  25915. animations: import("babylonjs/Animations/animation").Animation[];
  25916. protected _ranges: {
  25917. [name: string]: Nullable<AnimationRange>;
  25918. };
  25919. /**
  25920. * Callback raised when the node is ready to be used
  25921. */
  25922. onReady: Nullable<(node: Node) => void>;
  25923. private _isEnabled;
  25924. private _isParentEnabled;
  25925. private _isReady;
  25926. /** @hidden */
  25927. _currentRenderId: number;
  25928. private _parentUpdateId;
  25929. /** @hidden */
  25930. _childUpdateId: number;
  25931. /** @hidden */
  25932. _waitingParentId: Nullable<string>;
  25933. /** @hidden */
  25934. _scene: Scene;
  25935. /** @hidden */
  25936. _cache: any;
  25937. private _parentNode;
  25938. private _children;
  25939. /** @hidden */
  25940. _worldMatrix: Matrix;
  25941. /** @hidden */
  25942. _worldMatrixDeterminant: number;
  25943. /** @hidden */
  25944. _worldMatrixDeterminantIsDirty: boolean;
  25945. /** @hidden */
  25946. private _sceneRootNodesIndex;
  25947. /**
  25948. * Gets a boolean indicating if the node has been disposed
  25949. * @returns true if the node was disposed
  25950. */
  25951. isDisposed(): boolean;
  25952. /**
  25953. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25954. * @see https://doc.babylonjs.com/how_to/parenting
  25955. */
  25956. parent: Nullable<Node>;
  25957. private addToSceneRootNodes;
  25958. private removeFromSceneRootNodes;
  25959. private _animationPropertiesOverride;
  25960. /**
  25961. * Gets or sets the animation properties override
  25962. */
  25963. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25964. /**
  25965. * Gets a string idenfifying the name of the class
  25966. * @returns "Node" string
  25967. */
  25968. getClassName(): string;
  25969. /** @hidden */
  25970. readonly _isNode: boolean;
  25971. /**
  25972. * An event triggered when the mesh is disposed
  25973. */
  25974. onDisposeObservable: Observable<Node>;
  25975. private _onDisposeObserver;
  25976. /**
  25977. * Sets a callback that will be raised when the node will be disposed
  25978. */
  25979. onDispose: () => void;
  25980. /**
  25981. * Creates a new Node
  25982. * @param name the name and id to be given to this node
  25983. * @param scene the scene this node will be added to
  25984. * @param addToRootNodes the node will be added to scene.rootNodes
  25985. */
  25986. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25987. /**
  25988. * Gets the scene of the node
  25989. * @returns a scene
  25990. */
  25991. getScene(): Scene;
  25992. /**
  25993. * Gets the engine of the node
  25994. * @returns a Engine
  25995. */
  25996. getEngine(): Engine;
  25997. private _behaviors;
  25998. /**
  25999. * Attach a behavior to the node
  26000. * @see http://doc.babylonjs.com/features/behaviour
  26001. * @param behavior defines the behavior to attach
  26002. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26003. * @returns the current Node
  26004. */
  26005. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26006. /**
  26007. * Remove an attached behavior
  26008. * @see http://doc.babylonjs.com/features/behaviour
  26009. * @param behavior defines the behavior to attach
  26010. * @returns the current Node
  26011. */
  26012. removeBehavior(behavior: Behavior<Node>): Node;
  26013. /**
  26014. * Gets the list of attached behaviors
  26015. * @see http://doc.babylonjs.com/features/behaviour
  26016. */
  26017. readonly behaviors: Behavior<Node>[];
  26018. /**
  26019. * Gets an attached behavior by name
  26020. * @param name defines the name of the behavior to look for
  26021. * @see http://doc.babylonjs.com/features/behaviour
  26022. * @returns null if behavior was not found else the requested behavior
  26023. */
  26024. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26025. /**
  26026. * Returns the latest update of the World matrix
  26027. * @returns a Matrix
  26028. */
  26029. getWorldMatrix(): Matrix;
  26030. /** @hidden */
  26031. _getWorldMatrixDeterminant(): number;
  26032. /**
  26033. * Returns directly the latest state of the mesh World matrix.
  26034. * A Matrix is returned.
  26035. */
  26036. readonly worldMatrixFromCache: Matrix;
  26037. /** @hidden */
  26038. _initCache(): void;
  26039. /** @hidden */
  26040. updateCache(force?: boolean): void;
  26041. /** @hidden */
  26042. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26043. /** @hidden */
  26044. _updateCache(ignoreParentClass?: boolean): void;
  26045. /** @hidden */
  26046. _isSynchronized(): boolean;
  26047. /** @hidden */
  26048. _markSyncedWithParent(): void;
  26049. /** @hidden */
  26050. isSynchronizedWithParent(): boolean;
  26051. /** @hidden */
  26052. isSynchronized(): boolean;
  26053. /**
  26054. * Is this node ready to be used/rendered
  26055. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26056. * @return true if the node is ready
  26057. */
  26058. isReady(completeCheck?: boolean): boolean;
  26059. /**
  26060. * Is this node enabled?
  26061. * 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
  26062. * @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
  26063. * @return whether this node (and its parent) is enabled
  26064. */
  26065. isEnabled(checkAncestors?: boolean): boolean;
  26066. /** @hidden */
  26067. protected _syncParentEnabledState(): void;
  26068. /**
  26069. * Set the enabled state of this node
  26070. * @param value defines the new enabled state
  26071. */
  26072. setEnabled(value: boolean): void;
  26073. /**
  26074. * Is this node a descendant of the given node?
  26075. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26076. * @param ancestor defines the parent node to inspect
  26077. * @returns a boolean indicating if this node is a descendant of the given node
  26078. */
  26079. isDescendantOf(ancestor: Node): boolean;
  26080. /** @hidden */
  26081. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26082. /**
  26083. * Will return all nodes that have this node as ascendant
  26084. * @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
  26085. * @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
  26086. * @return all children nodes of all types
  26087. */
  26088. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26089. /**
  26090. * Get all child-meshes of this node
  26091. * @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)
  26092. * @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
  26093. * @returns an array of AbstractMesh
  26094. */
  26095. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26096. /**
  26097. * Get all direct children of this node
  26098. * @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
  26099. * @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)
  26100. * @returns an array of Node
  26101. */
  26102. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26103. /** @hidden */
  26104. _setReady(state: boolean): void;
  26105. /**
  26106. * Get an animation by name
  26107. * @param name defines the name of the animation to look for
  26108. * @returns null if not found else the requested animation
  26109. */
  26110. getAnimationByName(name: string): Nullable<Animation>;
  26111. /**
  26112. * Creates an animation range for this node
  26113. * @param name defines the name of the range
  26114. * @param from defines the starting key
  26115. * @param to defines the end key
  26116. */
  26117. createAnimationRange(name: string, from: number, to: number): void;
  26118. /**
  26119. * Delete a specific animation range
  26120. * @param name defines the name of the range to delete
  26121. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26122. */
  26123. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26124. /**
  26125. * Get an animation range by name
  26126. * @param name defines the name of the animation range to look for
  26127. * @returns null if not found else the requested animation range
  26128. */
  26129. getAnimationRange(name: string): Nullable<AnimationRange>;
  26130. /**
  26131. * Gets the list of all animation ranges defined on this node
  26132. * @returns an array
  26133. */
  26134. getAnimationRanges(): Nullable<AnimationRange>[];
  26135. /**
  26136. * Will start the animation sequence
  26137. * @param name defines the range frames for animation sequence
  26138. * @param loop defines if the animation should loop (false by default)
  26139. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26140. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26141. * @returns the object created for this animation. If range does not exist, it will return null
  26142. */
  26143. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26144. /**
  26145. * Serialize animation ranges into a JSON compatible object
  26146. * @returns serialization object
  26147. */
  26148. serializeAnimationRanges(): any;
  26149. /**
  26150. * Computes the world matrix of the node
  26151. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26152. * @returns the world matrix
  26153. */
  26154. computeWorldMatrix(force?: boolean): Matrix;
  26155. /**
  26156. * Releases resources associated with this node.
  26157. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26158. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26159. */
  26160. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26161. /**
  26162. * Parse animation range data from a serialization object and store them into a given node
  26163. * @param node defines where to store the animation ranges
  26164. * @param parsedNode defines the serialization object to read data from
  26165. * @param scene defines the hosting scene
  26166. */
  26167. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26168. /**
  26169. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26170. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26171. * @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
  26172. * @returns the new bounding vectors
  26173. */
  26174. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26175. min: Vector3;
  26176. max: Vector3;
  26177. };
  26178. }
  26179. }
  26180. declare module "babylonjs/Animations/animation" {
  26181. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26182. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26183. import { Nullable } from "babylonjs/types";
  26184. import { Scene } from "babylonjs/scene";
  26185. import { IAnimatable } from "babylonjs/Misc/tools";
  26186. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26187. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26188. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26189. import { Node } from "babylonjs/node";
  26190. import { Animatable } from "babylonjs/Animations/animatable";
  26191. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26192. /**
  26193. * @hidden
  26194. */
  26195. export class _IAnimationState {
  26196. key: number;
  26197. repeatCount: number;
  26198. workValue?: any;
  26199. loopMode?: number;
  26200. offsetValue?: any;
  26201. highLimitValue?: any;
  26202. }
  26203. /**
  26204. * Class used to store any kind of animation
  26205. */
  26206. export class Animation {
  26207. /**Name of the animation */
  26208. name: string;
  26209. /**Property to animate */
  26210. targetProperty: string;
  26211. /**The frames per second of the animation */
  26212. framePerSecond: number;
  26213. /**The data type of the animation */
  26214. dataType: number;
  26215. /**The loop mode of the animation */
  26216. loopMode?: number | undefined;
  26217. /**Specifies if blending should be enabled */
  26218. enableBlending?: boolean | undefined;
  26219. /**
  26220. * Use matrix interpolation instead of using direct key value when animating matrices
  26221. */
  26222. static AllowMatricesInterpolation: boolean;
  26223. /**
  26224. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26225. */
  26226. static AllowMatrixDecomposeForInterpolation: boolean;
  26227. /**
  26228. * Stores the key frames of the animation
  26229. */
  26230. private _keys;
  26231. /**
  26232. * Stores the easing function of the animation
  26233. */
  26234. private _easingFunction;
  26235. /**
  26236. * @hidden Internal use only
  26237. */
  26238. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26239. /**
  26240. * The set of event that will be linked to this animation
  26241. */
  26242. private _events;
  26243. /**
  26244. * Stores an array of target property paths
  26245. */
  26246. targetPropertyPath: string[];
  26247. /**
  26248. * Stores the blending speed of the animation
  26249. */
  26250. blendingSpeed: number;
  26251. /**
  26252. * Stores the animation ranges for the animation
  26253. */
  26254. private _ranges;
  26255. /**
  26256. * @hidden Internal use
  26257. */
  26258. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26259. /**
  26260. * Sets up an animation
  26261. * @param property The property to animate
  26262. * @param animationType The animation type to apply
  26263. * @param framePerSecond The frames per second of the animation
  26264. * @param easingFunction The easing function used in the animation
  26265. * @returns The created animation
  26266. */
  26267. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26268. /**
  26269. * Create and start an animation on a node
  26270. * @param name defines the name of the global animation that will be run on all nodes
  26271. * @param node defines the root node where the animation will take place
  26272. * @param targetProperty defines property to animate
  26273. * @param framePerSecond defines the number of frame per second yo use
  26274. * @param totalFrame defines the number of frames in total
  26275. * @param from defines the initial value
  26276. * @param to defines the final value
  26277. * @param loopMode defines which loop mode you want to use (off by default)
  26278. * @param easingFunction defines the easing function to use (linear by default)
  26279. * @param onAnimationEnd defines the callback to call when animation end
  26280. * @returns the animatable created for this animation
  26281. */
  26282. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26283. /**
  26284. * Create and start an animation on a node and its descendants
  26285. * @param name defines the name of the global animation that will be run on all nodes
  26286. * @param node defines the root node where the animation will take place
  26287. * @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
  26288. * @param targetProperty defines property to animate
  26289. * @param framePerSecond defines the number of frame per second to use
  26290. * @param totalFrame defines the number of frames in total
  26291. * @param from defines the initial value
  26292. * @param to defines the final value
  26293. * @param loopMode defines which loop mode you want to use (off by default)
  26294. * @param easingFunction defines the easing function to use (linear by default)
  26295. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26296. * @returns the list of animatables created for all nodes
  26297. * @example https://www.babylonjs-playground.com/#MH0VLI
  26298. */
  26299. 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[]>;
  26300. /**
  26301. * Creates a new animation, merges it with the existing animations and starts it
  26302. * @param name Name of the animation
  26303. * @param node Node which contains the scene that begins the animations
  26304. * @param targetProperty Specifies which property to animate
  26305. * @param framePerSecond The frames per second of the animation
  26306. * @param totalFrame The total number of frames
  26307. * @param from The frame at the beginning of the animation
  26308. * @param to The frame at the end of the animation
  26309. * @param loopMode Specifies the loop mode of the animation
  26310. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26311. * @param onAnimationEnd Callback to run once the animation is complete
  26312. * @returns Nullable animation
  26313. */
  26314. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26315. /**
  26316. * Transition property of an host to the target Value
  26317. * @param property The property to transition
  26318. * @param targetValue The target Value of the property
  26319. * @param host The object where the property to animate belongs
  26320. * @param scene Scene used to run the animation
  26321. * @param frameRate Framerate (in frame/s) to use
  26322. * @param transition The transition type we want to use
  26323. * @param duration The duration of the animation, in milliseconds
  26324. * @param onAnimationEnd Callback trigger at the end of the animation
  26325. * @returns Nullable animation
  26326. */
  26327. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26328. /**
  26329. * Return the array of runtime animations currently using this animation
  26330. */
  26331. readonly runtimeAnimations: RuntimeAnimation[];
  26332. /**
  26333. * Specifies if any of the runtime animations are currently running
  26334. */
  26335. readonly hasRunningRuntimeAnimations: boolean;
  26336. /**
  26337. * Initializes the animation
  26338. * @param name Name of the animation
  26339. * @param targetProperty Property to animate
  26340. * @param framePerSecond The frames per second of the animation
  26341. * @param dataType The data type of the animation
  26342. * @param loopMode The loop mode of the animation
  26343. * @param enableBlending Specifies if blending should be enabled
  26344. */
  26345. constructor(
  26346. /**Name of the animation */
  26347. name: string,
  26348. /**Property to animate */
  26349. targetProperty: string,
  26350. /**The frames per second of the animation */
  26351. framePerSecond: number,
  26352. /**The data type of the animation */
  26353. dataType: number,
  26354. /**The loop mode of the animation */
  26355. loopMode?: number | undefined,
  26356. /**Specifies if blending should be enabled */
  26357. enableBlending?: boolean | undefined);
  26358. /**
  26359. * Converts the animation to a string
  26360. * @param fullDetails support for multiple levels of logging within scene loading
  26361. * @returns String form of the animation
  26362. */
  26363. toString(fullDetails?: boolean): string;
  26364. /**
  26365. * Add an event to this animation
  26366. * @param event Event to add
  26367. */
  26368. addEvent(event: AnimationEvent): void;
  26369. /**
  26370. * Remove all events found at the given frame
  26371. * @param frame The frame to remove events from
  26372. */
  26373. removeEvents(frame: number): void;
  26374. /**
  26375. * Retrieves all the events from the animation
  26376. * @returns Events from the animation
  26377. */
  26378. getEvents(): AnimationEvent[];
  26379. /**
  26380. * Creates an animation range
  26381. * @param name Name of the animation range
  26382. * @param from Starting frame of the animation range
  26383. * @param to Ending frame of the animation
  26384. */
  26385. createRange(name: string, from: number, to: number): void;
  26386. /**
  26387. * Deletes an animation range by name
  26388. * @param name Name of the animation range to delete
  26389. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26390. */
  26391. deleteRange(name: string, deleteFrames?: boolean): void;
  26392. /**
  26393. * Gets the animation range by name, or null if not defined
  26394. * @param name Name of the animation range
  26395. * @returns Nullable animation range
  26396. */
  26397. getRange(name: string): Nullable<AnimationRange>;
  26398. /**
  26399. * Gets the key frames from the animation
  26400. * @returns The key frames of the animation
  26401. */
  26402. getKeys(): Array<IAnimationKey>;
  26403. /**
  26404. * Gets the highest frame rate of the animation
  26405. * @returns Highest frame rate of the animation
  26406. */
  26407. getHighestFrame(): number;
  26408. /**
  26409. * Gets the easing function of the animation
  26410. * @returns Easing function of the animation
  26411. */
  26412. getEasingFunction(): IEasingFunction;
  26413. /**
  26414. * Sets the easing function of the animation
  26415. * @param easingFunction A custom mathematical formula for animation
  26416. */
  26417. setEasingFunction(easingFunction: EasingFunction): void;
  26418. /**
  26419. * Interpolates a scalar linearly
  26420. * @param startValue Start value of the animation curve
  26421. * @param endValue End value of the animation curve
  26422. * @param gradient Scalar amount to interpolate
  26423. * @returns Interpolated scalar value
  26424. */
  26425. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26426. /**
  26427. * Interpolates a scalar cubically
  26428. * @param startValue Start value of the animation curve
  26429. * @param outTangent End tangent of the animation
  26430. * @param endValue End value of the animation curve
  26431. * @param inTangent Start tangent of the animation curve
  26432. * @param gradient Scalar amount to interpolate
  26433. * @returns Interpolated scalar value
  26434. */
  26435. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26436. /**
  26437. * Interpolates a quaternion using a spherical linear interpolation
  26438. * @param startValue Start value of the animation curve
  26439. * @param endValue End value of the animation curve
  26440. * @param gradient Scalar amount to interpolate
  26441. * @returns Interpolated quaternion value
  26442. */
  26443. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26444. /**
  26445. * Interpolates a quaternion cubically
  26446. * @param startValue Start value of the animation curve
  26447. * @param outTangent End tangent of the animation curve
  26448. * @param endValue End value of the animation curve
  26449. * @param inTangent Start tangent of the animation curve
  26450. * @param gradient Scalar amount to interpolate
  26451. * @returns Interpolated quaternion value
  26452. */
  26453. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26454. /**
  26455. * Interpolates a Vector3 linearl
  26456. * @param startValue Start value of the animation curve
  26457. * @param endValue End value of the animation curve
  26458. * @param gradient Scalar amount to interpolate
  26459. * @returns Interpolated scalar value
  26460. */
  26461. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26462. /**
  26463. * Interpolates a Vector3 cubically
  26464. * @param startValue Start value of the animation curve
  26465. * @param outTangent End tangent of the animation
  26466. * @param endValue End value of the animation curve
  26467. * @param inTangent Start tangent of the animation curve
  26468. * @param gradient Scalar amount to interpolate
  26469. * @returns InterpolatedVector3 value
  26470. */
  26471. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26472. /**
  26473. * Interpolates a Vector2 linearly
  26474. * @param startValue Start value of the animation curve
  26475. * @param endValue End value of the animation curve
  26476. * @param gradient Scalar amount to interpolate
  26477. * @returns Interpolated Vector2 value
  26478. */
  26479. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26480. /**
  26481. * Interpolates a Vector2 cubically
  26482. * @param startValue Start value of the animation curve
  26483. * @param outTangent End tangent of the animation
  26484. * @param endValue End value of the animation curve
  26485. * @param inTangent Start tangent of the animation curve
  26486. * @param gradient Scalar amount to interpolate
  26487. * @returns Interpolated Vector2 value
  26488. */
  26489. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26490. /**
  26491. * Interpolates a size linearly
  26492. * @param startValue Start value of the animation curve
  26493. * @param endValue End value of the animation curve
  26494. * @param gradient Scalar amount to interpolate
  26495. * @returns Interpolated Size value
  26496. */
  26497. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26498. /**
  26499. * Interpolates a Color3 linearly
  26500. * @param startValue Start value of the animation curve
  26501. * @param endValue End value of the animation curve
  26502. * @param gradient Scalar amount to interpolate
  26503. * @returns Interpolated Color3 value
  26504. */
  26505. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26506. /**
  26507. * @hidden Internal use only
  26508. */
  26509. _getKeyValue(value: any): any;
  26510. /**
  26511. * @hidden Internal use only
  26512. */
  26513. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26514. /**
  26515. * Defines the function to use to interpolate matrices
  26516. * @param startValue defines the start matrix
  26517. * @param endValue defines the end matrix
  26518. * @param gradient defines the gradient between both matrices
  26519. * @param result defines an optional target matrix where to store the interpolation
  26520. * @returns the interpolated matrix
  26521. */
  26522. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26523. /**
  26524. * Makes a copy of the animation
  26525. * @returns Cloned animation
  26526. */
  26527. clone(): Animation;
  26528. /**
  26529. * Sets the key frames of the animation
  26530. * @param values The animation key frames to set
  26531. */
  26532. setKeys(values: Array<IAnimationKey>): void;
  26533. /**
  26534. * Serializes the animation to an object
  26535. * @returns Serialized object
  26536. */
  26537. serialize(): any;
  26538. /**
  26539. * Float animation type
  26540. */
  26541. private static _ANIMATIONTYPE_FLOAT;
  26542. /**
  26543. * Vector3 animation type
  26544. */
  26545. private static _ANIMATIONTYPE_VECTOR3;
  26546. /**
  26547. * Quaternion animation type
  26548. */
  26549. private static _ANIMATIONTYPE_QUATERNION;
  26550. /**
  26551. * Matrix animation type
  26552. */
  26553. private static _ANIMATIONTYPE_MATRIX;
  26554. /**
  26555. * Color3 animation type
  26556. */
  26557. private static _ANIMATIONTYPE_COLOR3;
  26558. /**
  26559. * Vector2 animation type
  26560. */
  26561. private static _ANIMATIONTYPE_VECTOR2;
  26562. /**
  26563. * Size animation type
  26564. */
  26565. private static _ANIMATIONTYPE_SIZE;
  26566. /**
  26567. * Relative Loop Mode
  26568. */
  26569. private static _ANIMATIONLOOPMODE_RELATIVE;
  26570. /**
  26571. * Cycle Loop Mode
  26572. */
  26573. private static _ANIMATIONLOOPMODE_CYCLE;
  26574. /**
  26575. * Constant Loop Mode
  26576. */
  26577. private static _ANIMATIONLOOPMODE_CONSTANT;
  26578. /**
  26579. * Get the float animation type
  26580. */
  26581. static readonly ANIMATIONTYPE_FLOAT: number;
  26582. /**
  26583. * Get the Vector3 animation type
  26584. */
  26585. static readonly ANIMATIONTYPE_VECTOR3: number;
  26586. /**
  26587. * Get the Vector2 animation type
  26588. */
  26589. static readonly ANIMATIONTYPE_VECTOR2: number;
  26590. /**
  26591. * Get the Size animation type
  26592. */
  26593. static readonly ANIMATIONTYPE_SIZE: number;
  26594. /**
  26595. * Get the Quaternion animation type
  26596. */
  26597. static readonly ANIMATIONTYPE_QUATERNION: number;
  26598. /**
  26599. * Get the Matrix animation type
  26600. */
  26601. static readonly ANIMATIONTYPE_MATRIX: number;
  26602. /**
  26603. * Get the Color3 animation type
  26604. */
  26605. static readonly ANIMATIONTYPE_COLOR3: number;
  26606. /**
  26607. * Get the Relative Loop Mode
  26608. */
  26609. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26610. /**
  26611. * Get the Cycle Loop Mode
  26612. */
  26613. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26614. /**
  26615. * Get the Constant Loop Mode
  26616. */
  26617. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26618. /** @hidden */
  26619. static _UniversalLerp(left: any, right: any, amount: number): any;
  26620. /**
  26621. * Parses an animation object and creates an animation
  26622. * @param parsedAnimation Parsed animation object
  26623. * @returns Animation object
  26624. */
  26625. static Parse(parsedAnimation: any): Animation;
  26626. /**
  26627. * Appends the serialized animations from the source animations
  26628. * @param source Source containing the animations
  26629. * @param destination Target to store the animations
  26630. */
  26631. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26632. }
  26633. }
  26634. declare module "babylonjs/Materials/Textures/baseTexture" {
  26635. import { Observable } from "babylonjs/Misc/observable";
  26636. import { IAnimatable } from "babylonjs/Misc/tools";
  26637. import { Nullable } from "babylonjs/types";
  26638. import { Scene } from "babylonjs/scene";
  26639. import { Matrix, ISize } from "babylonjs/Maths/math";
  26640. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26642. /**
  26643. * Base class of all the textures in babylon.
  26644. * It groups all the common properties the materials, post process, lights... might need
  26645. * in order to make a correct use of the texture.
  26646. */
  26647. export class BaseTexture implements IAnimatable {
  26648. /**
  26649. * Default anisotropic filtering level for the application.
  26650. * It is set to 4 as a good tradeoff between perf and quality.
  26651. */
  26652. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26653. /**
  26654. * Gets or sets the unique id of the texture
  26655. */
  26656. uniqueId: number;
  26657. /**
  26658. * Define the name of the texture.
  26659. */
  26660. name: string;
  26661. /**
  26662. * Gets or sets an object used to store user defined information.
  26663. */
  26664. metadata: any;
  26665. /**
  26666. * For internal use only. Please do not use.
  26667. */
  26668. reservedDataStore: any;
  26669. private _hasAlpha;
  26670. /**
  26671. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26672. */
  26673. hasAlpha: boolean;
  26674. /**
  26675. * Defines if the alpha value should be determined via the rgb values.
  26676. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26677. */
  26678. getAlphaFromRGB: boolean;
  26679. /**
  26680. * Intensity or strength of the texture.
  26681. * It is commonly used by materials to fine tune the intensity of the texture
  26682. */
  26683. level: number;
  26684. /**
  26685. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26686. * This is part of the texture as textures usually maps to one uv set.
  26687. */
  26688. coordinatesIndex: number;
  26689. private _coordinatesMode;
  26690. /**
  26691. * How a texture is mapped.
  26692. *
  26693. * | Value | Type | Description |
  26694. * | ----- | ----------------------------------- | ----------- |
  26695. * | 0 | EXPLICIT_MODE | |
  26696. * | 1 | SPHERICAL_MODE | |
  26697. * | 2 | PLANAR_MODE | |
  26698. * | 3 | CUBIC_MODE | |
  26699. * | 4 | PROJECTION_MODE | |
  26700. * | 5 | SKYBOX_MODE | |
  26701. * | 6 | INVCUBIC_MODE | |
  26702. * | 7 | EQUIRECTANGULAR_MODE | |
  26703. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26704. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26705. */
  26706. coordinatesMode: number;
  26707. /**
  26708. * | Value | Type | Description |
  26709. * | ----- | ------------------ | ----------- |
  26710. * | 0 | CLAMP_ADDRESSMODE | |
  26711. * | 1 | WRAP_ADDRESSMODE | |
  26712. * | 2 | MIRROR_ADDRESSMODE | |
  26713. */
  26714. wrapU: number;
  26715. /**
  26716. * | Value | Type | Description |
  26717. * | ----- | ------------------ | ----------- |
  26718. * | 0 | CLAMP_ADDRESSMODE | |
  26719. * | 1 | WRAP_ADDRESSMODE | |
  26720. * | 2 | MIRROR_ADDRESSMODE | |
  26721. */
  26722. wrapV: number;
  26723. /**
  26724. * | Value | Type | Description |
  26725. * | ----- | ------------------ | ----------- |
  26726. * | 0 | CLAMP_ADDRESSMODE | |
  26727. * | 1 | WRAP_ADDRESSMODE | |
  26728. * | 2 | MIRROR_ADDRESSMODE | |
  26729. */
  26730. wrapR: number;
  26731. /**
  26732. * With compliant hardware and browser (supporting anisotropic filtering)
  26733. * this defines the level of anisotropic filtering in the texture.
  26734. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26735. */
  26736. anisotropicFilteringLevel: number;
  26737. /**
  26738. * Define if the texture is a cube texture or if false a 2d texture.
  26739. */
  26740. isCube: boolean;
  26741. /**
  26742. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26743. */
  26744. is3D: boolean;
  26745. /**
  26746. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26747. * HDR texture are usually stored in linear space.
  26748. * This only impacts the PBR and Background materials
  26749. */
  26750. gammaSpace: boolean;
  26751. /**
  26752. * Gets whether or not the texture contains RGBD data.
  26753. */
  26754. readonly isRGBD: boolean;
  26755. /**
  26756. * Is Z inverted in the texture (useful in a cube texture).
  26757. */
  26758. invertZ: boolean;
  26759. /**
  26760. * Are mip maps generated for this texture or not.
  26761. */
  26762. readonly noMipmap: boolean;
  26763. /**
  26764. * @hidden
  26765. */
  26766. lodLevelInAlpha: boolean;
  26767. /**
  26768. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26769. */
  26770. lodGenerationOffset: number;
  26771. /**
  26772. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26773. */
  26774. lodGenerationScale: number;
  26775. /**
  26776. * Define if the texture is a render target.
  26777. */
  26778. isRenderTarget: boolean;
  26779. /**
  26780. * Define the unique id of the texture in the scene.
  26781. */
  26782. readonly uid: string;
  26783. /**
  26784. * Return a string representation of the texture.
  26785. * @returns the texture as a string
  26786. */
  26787. toString(): string;
  26788. /**
  26789. * Get the class name of the texture.
  26790. * @returns "BaseTexture"
  26791. */
  26792. getClassName(): string;
  26793. /**
  26794. * Define the list of animation attached to the texture.
  26795. */
  26796. animations: import("babylonjs/Animations/animation").Animation[];
  26797. /**
  26798. * An event triggered when the texture is disposed.
  26799. */
  26800. onDisposeObservable: Observable<BaseTexture>;
  26801. private _onDisposeObserver;
  26802. /**
  26803. * Callback triggered when the texture has been disposed.
  26804. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26805. */
  26806. onDispose: () => void;
  26807. /**
  26808. * Define the current state of the loading sequence when in delayed load mode.
  26809. */
  26810. delayLoadState: number;
  26811. private _scene;
  26812. /** @hidden */
  26813. _texture: Nullable<InternalTexture>;
  26814. private _uid;
  26815. /**
  26816. * Define if the texture is preventinga material to render or not.
  26817. * If not and the texture is not ready, the engine will use a default black texture instead.
  26818. */
  26819. readonly isBlocking: boolean;
  26820. /**
  26821. * Instantiates a new BaseTexture.
  26822. * Base class of all the textures in babylon.
  26823. * It groups all the common properties the materials, post process, lights... might need
  26824. * in order to make a correct use of the texture.
  26825. * @param scene Define the scene the texture blongs to
  26826. */
  26827. constructor(scene: Nullable<Scene>);
  26828. /**
  26829. * Get the scene the texture belongs to.
  26830. * @returns the scene or null if undefined
  26831. */
  26832. getScene(): Nullable<Scene>;
  26833. /**
  26834. * Get the texture transform matrix used to offset tile the texture for istance.
  26835. * @returns the transformation matrix
  26836. */
  26837. getTextureMatrix(): Matrix;
  26838. /**
  26839. * Get the texture reflection matrix used to rotate/transform the reflection.
  26840. * @returns the reflection matrix
  26841. */
  26842. getReflectionTextureMatrix(): Matrix;
  26843. /**
  26844. * Get the underlying lower level texture from Babylon.
  26845. * @returns the insternal texture
  26846. */
  26847. getInternalTexture(): Nullable<InternalTexture>;
  26848. /**
  26849. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26850. * @returns true if ready or not blocking
  26851. */
  26852. isReadyOrNotBlocking(): boolean;
  26853. /**
  26854. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26855. * @returns true if fully ready
  26856. */
  26857. isReady(): boolean;
  26858. private _cachedSize;
  26859. /**
  26860. * Get the size of the texture.
  26861. * @returns the texture size.
  26862. */
  26863. getSize(): ISize;
  26864. /**
  26865. * Get the base size of the texture.
  26866. * It can be different from the size if the texture has been resized for POT for instance
  26867. * @returns the base size
  26868. */
  26869. getBaseSize(): ISize;
  26870. /**
  26871. * Update the sampling mode of the texture.
  26872. * Default is Trilinear mode.
  26873. *
  26874. * | Value | Type | Description |
  26875. * | ----- | ------------------ | ----------- |
  26876. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26877. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26878. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26879. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26880. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26881. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26882. * | 7 | NEAREST_LINEAR | |
  26883. * | 8 | NEAREST_NEAREST | |
  26884. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26885. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26886. * | 11 | LINEAR_LINEAR | |
  26887. * | 12 | LINEAR_NEAREST | |
  26888. *
  26889. * > _mag_: magnification filter (close to the viewer)
  26890. * > _min_: minification filter (far from the viewer)
  26891. * > _mip_: filter used between mip map levels
  26892. *@param samplingMode Define the new sampling mode of the texture
  26893. */
  26894. updateSamplingMode(samplingMode: number): void;
  26895. /**
  26896. * Scales the texture if is `canRescale()`
  26897. * @param ratio the resize factor we want to use to rescale
  26898. */
  26899. scale(ratio: number): void;
  26900. /**
  26901. * Get if the texture can rescale.
  26902. */
  26903. readonly canRescale: boolean;
  26904. /** @hidden */
  26905. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26906. /** @hidden */
  26907. _rebuild(): void;
  26908. /**
  26909. * Triggers the load sequence in delayed load mode.
  26910. */
  26911. delayLoad(): void;
  26912. /**
  26913. * Clones the texture.
  26914. * @returns the cloned texture
  26915. */
  26916. clone(): Nullable<BaseTexture>;
  26917. /**
  26918. * Get the texture underlying type (INT, FLOAT...)
  26919. */
  26920. readonly textureType: number;
  26921. /**
  26922. * Get the texture underlying format (RGB, RGBA...)
  26923. */
  26924. readonly textureFormat: number;
  26925. /**
  26926. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26927. * This will returns an RGBA array buffer containing either in values (0-255) or
  26928. * float values (0-1) depending of the underlying buffer type.
  26929. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26930. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26931. * @param buffer defines a user defined buffer to fill with data (can be null)
  26932. * @returns The Array buffer containing the pixels data.
  26933. */
  26934. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26935. /**
  26936. * Release and destroy the underlying lower level texture aka internalTexture.
  26937. */
  26938. releaseInternalTexture(): void;
  26939. /**
  26940. * Get the polynomial representation of the texture data.
  26941. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26942. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26943. */
  26944. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26945. /** @hidden */
  26946. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26947. /** @hidden */
  26948. readonly _lodTextureMid: Nullable<BaseTexture>;
  26949. /** @hidden */
  26950. readonly _lodTextureLow: Nullable<BaseTexture>;
  26951. /**
  26952. * Dispose the texture and release its associated resources.
  26953. */
  26954. dispose(): void;
  26955. /**
  26956. * Serialize the texture into a JSON representation that can be parsed later on.
  26957. * @returns the JSON representation of the texture
  26958. */
  26959. serialize(): any;
  26960. /**
  26961. * Helper function to be called back once a list of texture contains only ready textures.
  26962. * @param textures Define the list of textures to wait for
  26963. * @param callback Define the callback triggered once the entire list will be ready
  26964. */
  26965. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26966. }
  26967. }
  26968. declare module "babylonjs/Materials/uniformBuffer" {
  26969. import { Nullable, FloatArray } from "babylonjs/types";
  26970. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26971. import { Engine } from "babylonjs/Engines/engine";
  26972. import { Effect } from "babylonjs/Materials/effect";
  26973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26974. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26975. /**
  26976. * Uniform buffer objects.
  26977. *
  26978. * Handles blocks of uniform on the GPU.
  26979. *
  26980. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26981. *
  26982. * For more information, please refer to :
  26983. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26984. */
  26985. export class UniformBuffer {
  26986. private _engine;
  26987. private _buffer;
  26988. private _data;
  26989. private _bufferData;
  26990. private _dynamic?;
  26991. private _uniformLocations;
  26992. private _uniformSizes;
  26993. private _uniformLocationPointer;
  26994. private _needSync;
  26995. private _noUBO;
  26996. private _currentEffect;
  26997. private static _MAX_UNIFORM_SIZE;
  26998. private static _tempBuffer;
  26999. /**
  27000. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27001. * This is dynamic to allow compat with webgl 1 and 2.
  27002. * You will need to pass the name of the uniform as well as the value.
  27003. */
  27004. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27005. /**
  27006. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27007. * This is dynamic to allow compat with webgl 1 and 2.
  27008. * You will need to pass the name of the uniform as well as the value.
  27009. */
  27010. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27011. /**
  27012. * Lambda to Update a single float in a uniform buffer.
  27013. * This is dynamic to allow compat with webgl 1 and 2.
  27014. * You will need to pass the name of the uniform as well as the value.
  27015. */
  27016. updateFloat: (name: string, x: number) => void;
  27017. /**
  27018. * Lambda to Update a vec2 of float in a uniform buffer.
  27019. * This is dynamic to allow compat with webgl 1 and 2.
  27020. * You will need to pass the name of the uniform as well as the value.
  27021. */
  27022. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27023. /**
  27024. * Lambda to Update a vec3 of float in a uniform buffer.
  27025. * This is dynamic to allow compat with webgl 1 and 2.
  27026. * You will need to pass the name of the uniform as well as the value.
  27027. */
  27028. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27029. /**
  27030. * Lambda to Update a vec4 of float in a uniform buffer.
  27031. * This is dynamic to allow compat with webgl 1 and 2.
  27032. * You will need to pass the name of the uniform as well as the value.
  27033. */
  27034. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27035. /**
  27036. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27037. * This is dynamic to allow compat with webgl 1 and 2.
  27038. * You will need to pass the name of the uniform as well as the value.
  27039. */
  27040. updateMatrix: (name: string, mat: Matrix) => void;
  27041. /**
  27042. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27043. * This is dynamic to allow compat with webgl 1 and 2.
  27044. * You will need to pass the name of the uniform as well as the value.
  27045. */
  27046. updateVector3: (name: string, vector: Vector3) => void;
  27047. /**
  27048. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27049. * This is dynamic to allow compat with webgl 1 and 2.
  27050. * You will need to pass the name of the uniform as well as the value.
  27051. */
  27052. updateVector4: (name: string, vector: Vector4) => void;
  27053. /**
  27054. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27055. * This is dynamic to allow compat with webgl 1 and 2.
  27056. * You will need to pass the name of the uniform as well as the value.
  27057. */
  27058. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27059. /**
  27060. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27061. * This is dynamic to allow compat with webgl 1 and 2.
  27062. * You will need to pass the name of the uniform as well as the value.
  27063. */
  27064. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27065. /**
  27066. * Instantiates a new Uniform buffer objects.
  27067. *
  27068. * Handles blocks of uniform on the GPU.
  27069. *
  27070. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27071. *
  27072. * For more information, please refer to :
  27073. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27074. * @param engine Define the engine the buffer is associated with
  27075. * @param data Define the data contained in the buffer
  27076. * @param dynamic Define if the buffer is updatable
  27077. */
  27078. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27079. /**
  27080. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27081. * or just falling back on setUniformXXX calls.
  27082. */
  27083. readonly useUbo: boolean;
  27084. /**
  27085. * Indicates if the WebGL underlying uniform buffer is in sync
  27086. * with the javascript cache data.
  27087. */
  27088. readonly isSync: boolean;
  27089. /**
  27090. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27091. * Also, a dynamic UniformBuffer will disable cache verification and always
  27092. * update the underlying WebGL uniform buffer to the GPU.
  27093. * @returns if Dynamic, otherwise false
  27094. */
  27095. isDynamic(): boolean;
  27096. /**
  27097. * The data cache on JS side.
  27098. * @returns the underlying data as a float array
  27099. */
  27100. getData(): Float32Array;
  27101. /**
  27102. * The underlying WebGL Uniform buffer.
  27103. * @returns the webgl buffer
  27104. */
  27105. getBuffer(): Nullable<DataBuffer>;
  27106. /**
  27107. * std140 layout specifies how to align data within an UBO structure.
  27108. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27109. * for specs.
  27110. */
  27111. private _fillAlignment;
  27112. /**
  27113. * Adds an uniform in the buffer.
  27114. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27115. * for the layout to be correct !
  27116. * @param name Name of the uniform, as used in the uniform block in the shader.
  27117. * @param size Data size, or data directly.
  27118. */
  27119. addUniform(name: string, size: number | number[]): void;
  27120. /**
  27121. * Adds a Matrix 4x4 to the uniform buffer.
  27122. * @param name Name of the uniform, as used in the uniform block in the shader.
  27123. * @param mat A 4x4 matrix.
  27124. */
  27125. addMatrix(name: string, mat: Matrix): void;
  27126. /**
  27127. * Adds a vec2 to the uniform buffer.
  27128. * @param name Name of the uniform, as used in the uniform block in the shader.
  27129. * @param x Define the x component value of the vec2
  27130. * @param y Define the y component value of the vec2
  27131. */
  27132. addFloat2(name: string, x: number, y: number): void;
  27133. /**
  27134. * Adds a vec3 to the uniform buffer.
  27135. * @param name Name of the uniform, as used in the uniform block in the shader.
  27136. * @param x Define the x component value of the vec3
  27137. * @param y Define the y component value of the vec3
  27138. * @param z Define the z component value of the vec3
  27139. */
  27140. addFloat3(name: string, x: number, y: number, z: number): void;
  27141. /**
  27142. * Adds a vec3 to the uniform buffer.
  27143. * @param name Name of the uniform, as used in the uniform block in the shader.
  27144. * @param color Define the vec3 from a Color
  27145. */
  27146. addColor3(name: string, color: Color3): void;
  27147. /**
  27148. * Adds a vec4 to the uniform buffer.
  27149. * @param name Name of the uniform, as used in the uniform block in the shader.
  27150. * @param color Define the rgb components from a Color
  27151. * @param alpha Define the a component of the vec4
  27152. */
  27153. addColor4(name: string, color: Color3, alpha: number): void;
  27154. /**
  27155. * Adds a vec3 to the uniform buffer.
  27156. * @param name Name of the uniform, as used in the uniform block in the shader.
  27157. * @param vector Define the vec3 components from a Vector
  27158. */
  27159. addVector3(name: string, vector: Vector3): void;
  27160. /**
  27161. * Adds a Matrix 3x3 to the uniform buffer.
  27162. * @param name Name of the uniform, as used in the uniform block in the shader.
  27163. */
  27164. addMatrix3x3(name: string): void;
  27165. /**
  27166. * Adds a Matrix 2x2 to the uniform buffer.
  27167. * @param name Name of the uniform, as used in the uniform block in the shader.
  27168. */
  27169. addMatrix2x2(name: string): void;
  27170. /**
  27171. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27172. */
  27173. create(): void;
  27174. /** @hidden */
  27175. _rebuild(): void;
  27176. /**
  27177. * Updates the WebGL Uniform Buffer on the GPU.
  27178. * If the `dynamic` flag is set to true, no cache comparison is done.
  27179. * Otherwise, the buffer will be updated only if the cache differs.
  27180. */
  27181. update(): void;
  27182. /**
  27183. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27184. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27185. * @param data Define the flattened data
  27186. * @param size Define the size of the data.
  27187. */
  27188. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27189. private _updateMatrix3x3ForUniform;
  27190. private _updateMatrix3x3ForEffect;
  27191. private _updateMatrix2x2ForEffect;
  27192. private _updateMatrix2x2ForUniform;
  27193. private _updateFloatForEffect;
  27194. private _updateFloatForUniform;
  27195. private _updateFloat2ForEffect;
  27196. private _updateFloat2ForUniform;
  27197. private _updateFloat3ForEffect;
  27198. private _updateFloat3ForUniform;
  27199. private _updateFloat4ForEffect;
  27200. private _updateFloat4ForUniform;
  27201. private _updateMatrixForEffect;
  27202. private _updateMatrixForUniform;
  27203. private _updateVector3ForEffect;
  27204. private _updateVector3ForUniform;
  27205. private _updateVector4ForEffect;
  27206. private _updateVector4ForUniform;
  27207. private _updateColor3ForEffect;
  27208. private _updateColor3ForUniform;
  27209. private _updateColor4ForEffect;
  27210. private _updateColor4ForUniform;
  27211. /**
  27212. * Sets a sampler uniform on the effect.
  27213. * @param name Define the name of the sampler.
  27214. * @param texture Define the texture to set in the sampler
  27215. */
  27216. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27217. /**
  27218. * Directly updates the value of the uniform in the cache AND on the GPU.
  27219. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27220. * @param data Define the flattened data
  27221. */
  27222. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27223. /**
  27224. * Binds this uniform buffer to an effect.
  27225. * @param effect Define the effect to bind the buffer to
  27226. * @param name Name of the uniform block in the shader.
  27227. */
  27228. bindToEffect(effect: Effect, name: string): void;
  27229. /**
  27230. * Disposes the uniform buffer.
  27231. */
  27232. dispose(): void;
  27233. }
  27234. }
  27235. declare module "babylonjs/Audio/analyser" {
  27236. import { Scene } from "babylonjs/scene";
  27237. /**
  27238. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27240. */
  27241. export class Analyser {
  27242. /**
  27243. * Gets or sets the smoothing
  27244. * @ignorenaming
  27245. */
  27246. SMOOTHING: number;
  27247. /**
  27248. * Gets or sets the FFT table size
  27249. * @ignorenaming
  27250. */
  27251. FFT_SIZE: number;
  27252. /**
  27253. * Gets or sets the bar graph amplitude
  27254. * @ignorenaming
  27255. */
  27256. BARGRAPHAMPLITUDE: number;
  27257. /**
  27258. * Gets or sets the position of the debug canvas
  27259. * @ignorenaming
  27260. */
  27261. DEBUGCANVASPOS: {
  27262. x: number;
  27263. y: number;
  27264. };
  27265. /**
  27266. * Gets or sets the debug canvas size
  27267. * @ignorenaming
  27268. */
  27269. DEBUGCANVASSIZE: {
  27270. width: number;
  27271. height: number;
  27272. };
  27273. private _byteFreqs;
  27274. private _byteTime;
  27275. private _floatFreqs;
  27276. private _webAudioAnalyser;
  27277. private _debugCanvas;
  27278. private _debugCanvasContext;
  27279. private _scene;
  27280. private _registerFunc;
  27281. private _audioEngine;
  27282. /**
  27283. * Creates a new analyser
  27284. * @param scene defines hosting scene
  27285. */
  27286. constructor(scene: Scene);
  27287. /**
  27288. * Get the number of data values you will have to play with for the visualization
  27289. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27290. * @returns a number
  27291. */
  27292. getFrequencyBinCount(): number;
  27293. /**
  27294. * Gets the current frequency data as a byte array
  27295. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27296. * @returns a Uint8Array
  27297. */
  27298. getByteFrequencyData(): Uint8Array;
  27299. /**
  27300. * Gets the current waveform as a byte array
  27301. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27302. * @returns a Uint8Array
  27303. */
  27304. getByteTimeDomainData(): Uint8Array;
  27305. /**
  27306. * Gets the current frequency data as a float array
  27307. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27308. * @returns a Float32Array
  27309. */
  27310. getFloatFrequencyData(): Float32Array;
  27311. /**
  27312. * Renders the debug canvas
  27313. */
  27314. drawDebugCanvas(): void;
  27315. /**
  27316. * Stops rendering the debug canvas and removes it
  27317. */
  27318. stopDebugCanvas(): void;
  27319. /**
  27320. * Connects two audio nodes
  27321. * @param inputAudioNode defines first node to connect
  27322. * @param outputAudioNode defines second node to connect
  27323. */
  27324. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27325. /**
  27326. * Releases all associated resources
  27327. */
  27328. dispose(): void;
  27329. }
  27330. }
  27331. declare module "babylonjs/Audio/audioEngine" {
  27332. import { IDisposable } from "babylonjs/scene";
  27333. import { Analyser } from "babylonjs/Audio/analyser";
  27334. import { Nullable } from "babylonjs/types";
  27335. import { Observable } from "babylonjs/Misc/observable";
  27336. /**
  27337. * This represents an audio engine and it is responsible
  27338. * to play, synchronize and analyse sounds throughout the application.
  27339. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27340. */
  27341. export interface IAudioEngine extends IDisposable {
  27342. /**
  27343. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27344. */
  27345. readonly canUseWebAudio: boolean;
  27346. /**
  27347. * Gets the current AudioContext if available.
  27348. */
  27349. readonly audioContext: Nullable<AudioContext>;
  27350. /**
  27351. * The master gain node defines the global audio volume of your audio engine.
  27352. */
  27353. readonly masterGain: GainNode;
  27354. /**
  27355. * Gets whether or not mp3 are supported by your browser.
  27356. */
  27357. readonly isMP3supported: boolean;
  27358. /**
  27359. * Gets whether or not ogg are supported by your browser.
  27360. */
  27361. readonly isOGGsupported: boolean;
  27362. /**
  27363. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27364. * @ignoreNaming
  27365. */
  27366. WarnedWebAudioUnsupported: boolean;
  27367. /**
  27368. * Defines if the audio engine relies on a custom unlocked button.
  27369. * In this case, the embedded button will not be displayed.
  27370. */
  27371. useCustomUnlockedButton: boolean;
  27372. /**
  27373. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27374. */
  27375. readonly unlocked: boolean;
  27376. /**
  27377. * Event raised when audio has been unlocked on the browser.
  27378. */
  27379. onAudioUnlockedObservable: Observable<AudioEngine>;
  27380. /**
  27381. * Event raised when audio has been locked on the browser.
  27382. */
  27383. onAudioLockedObservable: Observable<AudioEngine>;
  27384. /**
  27385. * Flags the audio engine in Locked state.
  27386. * This happens due to new browser policies preventing audio to autoplay.
  27387. */
  27388. lock(): void;
  27389. /**
  27390. * Unlocks the audio engine once a user action has been done on the dom.
  27391. * This is helpful to resume play once browser policies have been satisfied.
  27392. */
  27393. unlock(): void;
  27394. }
  27395. /**
  27396. * This represents the default audio engine used in babylon.
  27397. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27399. */
  27400. export class AudioEngine implements IAudioEngine {
  27401. private _audioContext;
  27402. private _audioContextInitialized;
  27403. private _muteButton;
  27404. private _hostElement;
  27405. /**
  27406. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27407. */
  27408. canUseWebAudio: boolean;
  27409. /**
  27410. * The master gain node defines the global audio volume of your audio engine.
  27411. */
  27412. masterGain: GainNode;
  27413. /**
  27414. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27415. * @ignoreNaming
  27416. */
  27417. WarnedWebAudioUnsupported: boolean;
  27418. /**
  27419. * Gets whether or not mp3 are supported by your browser.
  27420. */
  27421. isMP3supported: boolean;
  27422. /**
  27423. * Gets whether or not ogg are supported by your browser.
  27424. */
  27425. isOGGsupported: boolean;
  27426. /**
  27427. * Gets whether audio has been unlocked on the device.
  27428. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27429. * a user interaction has happened.
  27430. */
  27431. unlocked: boolean;
  27432. /**
  27433. * Defines if the audio engine relies on a custom unlocked button.
  27434. * In this case, the embedded button will not be displayed.
  27435. */
  27436. useCustomUnlockedButton: boolean;
  27437. /**
  27438. * Event raised when audio has been unlocked on the browser.
  27439. */
  27440. onAudioUnlockedObservable: Observable<AudioEngine>;
  27441. /**
  27442. * Event raised when audio has been locked on the browser.
  27443. */
  27444. onAudioLockedObservable: Observable<AudioEngine>;
  27445. /**
  27446. * Gets the current AudioContext if available.
  27447. */
  27448. readonly audioContext: Nullable<AudioContext>;
  27449. private _connectedAnalyser;
  27450. /**
  27451. * Instantiates a new audio engine.
  27452. *
  27453. * There should be only one per page as some browsers restrict the number
  27454. * of audio contexts you can create.
  27455. * @param hostElement defines the host element where to display the mute icon if necessary
  27456. */
  27457. constructor(hostElement?: Nullable<HTMLElement>);
  27458. /**
  27459. * Flags the audio engine in Locked state.
  27460. * This happens due to new browser policies preventing audio to autoplay.
  27461. */
  27462. lock(): void;
  27463. /**
  27464. * Unlocks the audio engine once a user action has been done on the dom.
  27465. * This is helpful to resume play once browser policies have been satisfied.
  27466. */
  27467. unlock(): void;
  27468. private _resumeAudioContext;
  27469. private _initializeAudioContext;
  27470. private _tryToRun;
  27471. private _triggerRunningState;
  27472. private _triggerSuspendedState;
  27473. private _displayMuteButton;
  27474. private _moveButtonToTopLeft;
  27475. private _onResize;
  27476. private _hideMuteButton;
  27477. /**
  27478. * Destroy and release the resources associated with the audio ccontext.
  27479. */
  27480. dispose(): void;
  27481. /**
  27482. * Gets the global volume sets on the master gain.
  27483. * @returns the global volume if set or -1 otherwise
  27484. */
  27485. getGlobalVolume(): number;
  27486. /**
  27487. * Sets the global volume of your experience (sets on the master gain).
  27488. * @param newVolume Defines the new global volume of the application
  27489. */
  27490. setGlobalVolume(newVolume: number): void;
  27491. /**
  27492. * Connect the audio engine to an audio analyser allowing some amazing
  27493. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27495. * @param analyser The analyser to connect to the engine
  27496. */
  27497. connectToAnalyser(analyser: Analyser): void;
  27498. }
  27499. }
  27500. declare module "babylonjs/Loading/loadingScreen" {
  27501. /**
  27502. * Interface used to present a loading screen while loading a scene
  27503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27504. */
  27505. export interface ILoadingScreen {
  27506. /**
  27507. * Function called to display the loading screen
  27508. */
  27509. displayLoadingUI: () => void;
  27510. /**
  27511. * Function called to hide the loading screen
  27512. */
  27513. hideLoadingUI: () => void;
  27514. /**
  27515. * Gets or sets the color to use for the background
  27516. */
  27517. loadingUIBackgroundColor: string;
  27518. /**
  27519. * Gets or sets the text to display while loading
  27520. */
  27521. loadingUIText: string;
  27522. }
  27523. /**
  27524. * Class used for the default loading screen
  27525. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27526. */
  27527. export class DefaultLoadingScreen implements ILoadingScreen {
  27528. private _renderingCanvas;
  27529. private _loadingText;
  27530. private _loadingDivBackgroundColor;
  27531. private _loadingDiv;
  27532. private _loadingTextDiv;
  27533. /**
  27534. * Creates a new default loading screen
  27535. * @param _renderingCanvas defines the canvas used to render the scene
  27536. * @param _loadingText defines the default text to display
  27537. * @param _loadingDivBackgroundColor defines the default background color
  27538. */
  27539. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27540. /**
  27541. * Function called to display the loading screen
  27542. */
  27543. displayLoadingUI(): void;
  27544. /**
  27545. * Function called to hide the loading screen
  27546. */
  27547. hideLoadingUI(): void;
  27548. /**
  27549. * Gets or sets the text to display while loading
  27550. */
  27551. loadingUIText: string;
  27552. /**
  27553. * Gets or sets the color to use for the background
  27554. */
  27555. loadingUIBackgroundColor: string;
  27556. private _resizeLoadingUI;
  27557. }
  27558. }
  27559. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27560. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27561. import { Engine } from "babylonjs/Engines/engine";
  27562. import { Nullable } from "babylonjs/types";
  27563. /** @hidden */
  27564. export class WebGLPipelineContext implements IPipelineContext {
  27565. engine: Engine;
  27566. program: Nullable<WebGLProgram>;
  27567. context?: WebGLRenderingContext;
  27568. vertexShader?: WebGLShader;
  27569. fragmentShader?: WebGLShader;
  27570. isParallelCompiled: boolean;
  27571. onCompiled?: () => void;
  27572. transformFeedback?: WebGLTransformFeedback | null;
  27573. readonly isAsync: boolean;
  27574. readonly isReady: boolean;
  27575. }
  27576. }
  27577. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27578. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27579. /** @hidden */
  27580. export class WebGLDataBuffer extends DataBuffer {
  27581. private _buffer;
  27582. constructor(resource: WebGLBuffer);
  27583. readonly underlyingResource: any;
  27584. }
  27585. }
  27586. declare module "babylonjs/Materials/Textures/videoTexture" {
  27587. import { Observable } from "babylonjs/Misc/observable";
  27588. import { Nullable } from "babylonjs/types";
  27589. import { Scene } from "babylonjs/scene";
  27590. import { Texture } from "babylonjs/Materials/Textures/texture";
  27591. /**
  27592. * Settings for finer control over video usage
  27593. */
  27594. export interface VideoTextureSettings {
  27595. /**
  27596. * Applies `autoplay` to video, if specified
  27597. */
  27598. autoPlay?: boolean;
  27599. /**
  27600. * Applies `loop` to video, if specified
  27601. */
  27602. loop?: boolean;
  27603. /**
  27604. * Automatically updates internal texture from video at every frame in the render loop
  27605. */
  27606. autoUpdateTexture: boolean;
  27607. /**
  27608. * Image src displayed during the video loading or until the user interacts with the video.
  27609. */
  27610. poster?: string;
  27611. }
  27612. /**
  27613. * If you want to display a video in your scene, this is the special texture for that.
  27614. * This special texture works similar to other textures, with the exception of a few parameters.
  27615. * @see https://doc.babylonjs.com/how_to/video_texture
  27616. */
  27617. export class VideoTexture extends Texture {
  27618. /**
  27619. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27620. */
  27621. readonly autoUpdateTexture: boolean;
  27622. /**
  27623. * The video instance used by the texture internally
  27624. */
  27625. readonly video: HTMLVideoElement;
  27626. private _onUserActionRequestedObservable;
  27627. /**
  27628. * Event triggerd when a dom action is required by the user to play the video.
  27629. * This happens due to recent changes in browser policies preventing video to auto start.
  27630. */
  27631. readonly onUserActionRequestedObservable: Observable<Texture>;
  27632. private _generateMipMaps;
  27633. private _engine;
  27634. private _stillImageCaptured;
  27635. private _displayingPosterTexture;
  27636. private _settings;
  27637. private _createInternalTextureOnEvent;
  27638. /**
  27639. * Creates a video texture.
  27640. * If you want to display a video in your scene, this is the special texture for that.
  27641. * This special texture works similar to other textures, with the exception of a few parameters.
  27642. * @see https://doc.babylonjs.com/how_to/video_texture
  27643. * @param name optional name, will detect from video source, if not defined
  27644. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27645. * @param scene is obviously the current scene.
  27646. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27647. * @param invertY is false by default but can be used to invert video on Y axis
  27648. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27649. * @param settings allows finer control over video usage
  27650. */
  27651. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27652. private _getName;
  27653. private _getVideo;
  27654. private _createInternalTexture;
  27655. private reset;
  27656. /**
  27657. * @hidden Internal method to initiate `update`.
  27658. */
  27659. _rebuild(): void;
  27660. /**
  27661. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27662. */
  27663. update(): void;
  27664. /**
  27665. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27666. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27667. */
  27668. updateTexture(isVisible: boolean): void;
  27669. protected _updateInternalTexture: () => void;
  27670. /**
  27671. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27672. * @param url New url.
  27673. */
  27674. updateURL(url: string): void;
  27675. /**
  27676. * Dispose the texture and release its associated resources.
  27677. */
  27678. dispose(): void;
  27679. /**
  27680. * Creates a video texture straight from a stream.
  27681. * @param scene Define the scene the texture should be created in
  27682. * @param stream Define the stream the texture should be created from
  27683. * @returns The created video texture as a promise
  27684. */
  27685. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27686. /**
  27687. * Creates a video texture straight from your WebCam video feed.
  27688. * @param scene Define the scene the texture should be created in
  27689. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27690. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27691. * @returns The created video texture as a promise
  27692. */
  27693. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27694. minWidth: number;
  27695. maxWidth: number;
  27696. minHeight: number;
  27697. maxHeight: number;
  27698. deviceId: string;
  27699. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27700. /**
  27701. * Creates a video texture straight from your WebCam video feed.
  27702. * @param scene Define the scene the texture should be created in
  27703. * @param onReady Define a callback to triggered once the texture will be ready
  27704. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27705. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27706. */
  27707. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27708. minWidth: number;
  27709. maxWidth: number;
  27710. minHeight: number;
  27711. maxHeight: number;
  27712. deviceId: string;
  27713. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27714. }
  27715. }
  27716. declare module "babylonjs/Engines/engine" {
  27717. import { Observable } from "babylonjs/Misc/observable";
  27718. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27719. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27720. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27721. import { Camera } from "babylonjs/Cameras/camera";
  27722. import { Scene } from "babylonjs/scene";
  27723. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27724. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27725. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27726. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27727. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27728. import { Material } from "babylonjs/Materials/material";
  27729. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27732. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27733. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27734. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27735. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27736. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27737. import { WebRequest } from "babylonjs/Misc/webRequest";
  27738. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27739. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27740. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27741. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27743. /**
  27744. * Interface for attribute information associated with buffer instanciation
  27745. */
  27746. export class InstancingAttributeInfo {
  27747. /**
  27748. * Index/offset of the attribute in the vertex shader
  27749. */
  27750. index: number;
  27751. /**
  27752. * size of the attribute, 1, 2, 3 or 4
  27753. */
  27754. attributeSize: number;
  27755. /**
  27756. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27757. * default is FLOAT
  27758. */
  27759. attribyteType: number;
  27760. /**
  27761. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27762. */
  27763. normalized: boolean;
  27764. /**
  27765. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27766. */
  27767. offset: number;
  27768. /**
  27769. * Name of the GLSL attribute, for debugging purpose only
  27770. */
  27771. attributeName: string;
  27772. }
  27773. /**
  27774. * Define options used to create a depth texture
  27775. */
  27776. export class DepthTextureCreationOptions {
  27777. /** Specifies whether or not a stencil should be allocated in the texture */
  27778. generateStencil?: boolean;
  27779. /** Specifies whether or not bilinear filtering is enable on the texture */
  27780. bilinearFiltering?: boolean;
  27781. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27782. comparisonFunction?: number;
  27783. /** Specifies if the created texture is a cube texture */
  27784. isCube?: boolean;
  27785. }
  27786. /**
  27787. * Class used to describe the capabilities of the engine relatively to the current browser
  27788. */
  27789. export class EngineCapabilities {
  27790. /** Maximum textures units per fragment shader */
  27791. maxTexturesImageUnits: number;
  27792. /** Maximum texture units per vertex shader */
  27793. maxVertexTextureImageUnits: number;
  27794. /** Maximum textures units in the entire pipeline */
  27795. maxCombinedTexturesImageUnits: number;
  27796. /** Maximum texture size */
  27797. maxTextureSize: number;
  27798. /** Maximum cube texture size */
  27799. maxCubemapTextureSize: number;
  27800. /** Maximum render texture size */
  27801. maxRenderTextureSize: number;
  27802. /** Maximum number of vertex attributes */
  27803. maxVertexAttribs: number;
  27804. /** Maximum number of varyings */
  27805. maxVaryingVectors: number;
  27806. /** Maximum number of uniforms per vertex shader */
  27807. maxVertexUniformVectors: number;
  27808. /** Maximum number of uniforms per fragment shader */
  27809. maxFragmentUniformVectors: number;
  27810. /** Defines if standard derivates (dx/dy) are supported */
  27811. standardDerivatives: boolean;
  27812. /** Defines if s3tc texture compression is supported */
  27813. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27814. /** Defines if pvrtc texture compression is supported */
  27815. pvrtc: any;
  27816. /** Defines if etc1 texture compression is supported */
  27817. etc1: any;
  27818. /** Defines if etc2 texture compression is supported */
  27819. etc2: any;
  27820. /** Defines if astc texture compression is supported */
  27821. astc: any;
  27822. /** Defines if float textures are supported */
  27823. textureFloat: boolean;
  27824. /** Defines if vertex array objects are supported */
  27825. vertexArrayObject: boolean;
  27826. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27827. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27828. /** Gets the maximum level of anisotropy supported */
  27829. maxAnisotropy: number;
  27830. /** Defines if instancing is supported */
  27831. instancedArrays: boolean;
  27832. /** Defines if 32 bits indices are supported */
  27833. uintIndices: boolean;
  27834. /** Defines if high precision shaders are supported */
  27835. highPrecisionShaderSupported: boolean;
  27836. /** Defines if depth reading in the fragment shader is supported */
  27837. fragmentDepthSupported: boolean;
  27838. /** Defines if float texture linear filtering is supported*/
  27839. textureFloatLinearFiltering: boolean;
  27840. /** Defines if rendering to float textures is supported */
  27841. textureFloatRender: boolean;
  27842. /** Defines if half float textures are supported*/
  27843. textureHalfFloat: boolean;
  27844. /** Defines if half float texture linear filtering is supported*/
  27845. textureHalfFloatLinearFiltering: boolean;
  27846. /** Defines if rendering to half float textures is supported */
  27847. textureHalfFloatRender: boolean;
  27848. /** Defines if textureLOD shader command is supported */
  27849. textureLOD: boolean;
  27850. /** Defines if draw buffers extension is supported */
  27851. drawBuffersExtension: boolean;
  27852. /** Defines if depth textures are supported */
  27853. depthTextureExtension: boolean;
  27854. /** Defines if float color buffer are supported */
  27855. colorBufferFloat: boolean;
  27856. /** Gets disjoint timer query extension (null if not supported) */
  27857. timerQuery: EXT_disjoint_timer_query;
  27858. /** Defines if timestamp can be used with timer query */
  27859. canUseTimestampForTimerQuery: boolean;
  27860. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27861. multiview: any;
  27862. /** Function used to let the system compiles shaders in background */
  27863. parallelShaderCompile: {
  27864. COMPLETION_STATUS_KHR: number;
  27865. };
  27866. }
  27867. /** Interface defining initialization parameters for Engine class */
  27868. export interface EngineOptions extends WebGLContextAttributes {
  27869. /**
  27870. * Defines if the engine should no exceed a specified device ratio
  27871. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27872. */
  27873. limitDeviceRatio?: number;
  27874. /**
  27875. * Defines if webvr should be enabled automatically
  27876. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27877. */
  27878. autoEnableWebVR?: boolean;
  27879. /**
  27880. * Defines if webgl2 should be turned off even if supported
  27881. * @see http://doc.babylonjs.com/features/webgl2
  27882. */
  27883. disableWebGL2Support?: boolean;
  27884. /**
  27885. * Defines if webaudio should be initialized as well
  27886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27887. */
  27888. audioEngine?: boolean;
  27889. /**
  27890. * Defines if animations should run using a deterministic lock step
  27891. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27892. */
  27893. deterministicLockstep?: boolean;
  27894. /** Defines the maximum steps to use with deterministic lock step mode */
  27895. lockstepMaxSteps?: number;
  27896. /**
  27897. * Defines that engine should ignore context lost events
  27898. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27899. */
  27900. doNotHandleContextLost?: boolean;
  27901. /**
  27902. * Defines that engine should ignore modifying touch action attribute and style
  27903. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27904. */
  27905. doNotHandleTouchAction?: boolean;
  27906. /**
  27907. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27908. */
  27909. useHighPrecisionFloats?: boolean;
  27910. }
  27911. /**
  27912. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27913. */
  27914. export class Engine {
  27915. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27916. static ExceptionList: ({
  27917. key: string;
  27918. capture: string;
  27919. captureConstraint: number;
  27920. targets: string[];
  27921. } | {
  27922. key: string;
  27923. capture: null;
  27924. captureConstraint: null;
  27925. targets: string[];
  27926. })[];
  27927. /** Gets the list of created engines */
  27928. static readonly Instances: Engine[];
  27929. /**
  27930. * Gets the latest created engine
  27931. */
  27932. static readonly LastCreatedEngine: Nullable<Engine>;
  27933. /**
  27934. * Gets the latest created scene
  27935. */
  27936. static readonly LastCreatedScene: Nullable<Scene>;
  27937. /**
  27938. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27939. * @param flag defines which part of the materials must be marked as dirty
  27940. * @param predicate defines a predicate used to filter which materials should be affected
  27941. */
  27942. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27943. /**
  27944. * Hidden
  27945. */
  27946. static _TextureLoaders: IInternalTextureLoader[];
  27947. /** Defines that alpha blending is disabled */
  27948. static readonly ALPHA_DISABLE: number;
  27949. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27950. static readonly ALPHA_ADD: number;
  27951. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27952. static readonly ALPHA_COMBINE: number;
  27953. /** Defines that alpha blending to DEST - SRC * DEST */
  27954. static readonly ALPHA_SUBTRACT: number;
  27955. /** Defines that alpha blending to SRC * DEST */
  27956. static readonly ALPHA_MULTIPLY: number;
  27957. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27958. static readonly ALPHA_MAXIMIZED: number;
  27959. /** Defines that alpha blending to SRC + DEST */
  27960. static readonly ALPHA_ONEONE: number;
  27961. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27962. static readonly ALPHA_PREMULTIPLIED: number;
  27963. /**
  27964. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27965. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27966. */
  27967. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27968. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27969. static readonly ALPHA_INTERPOLATE: number;
  27970. /**
  27971. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27972. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27973. */
  27974. static readonly ALPHA_SCREENMODE: number;
  27975. /** Defines that the ressource is not delayed*/
  27976. static readonly DELAYLOADSTATE_NONE: number;
  27977. /** Defines that the ressource was successfully delay loaded */
  27978. static readonly DELAYLOADSTATE_LOADED: number;
  27979. /** Defines that the ressource is currently delay loading */
  27980. static readonly DELAYLOADSTATE_LOADING: number;
  27981. /** Defines that the ressource is delayed and has not started loading */
  27982. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27983. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27984. static readonly NEVER: number;
  27985. /** 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 */
  27986. static readonly ALWAYS: number;
  27987. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27988. static readonly LESS: number;
  27989. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27990. static readonly EQUAL: number;
  27991. /** 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 */
  27992. static readonly LEQUAL: number;
  27993. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27994. static readonly GREATER: number;
  27995. /** 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 */
  27996. static readonly GEQUAL: number;
  27997. /** 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 */
  27998. static readonly NOTEQUAL: number;
  27999. /** Passed to stencilOperation to specify that stencil value must be kept */
  28000. static readonly KEEP: number;
  28001. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28002. static readonly REPLACE: number;
  28003. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28004. static readonly INCR: number;
  28005. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28006. static readonly DECR: number;
  28007. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28008. static readonly INVERT: number;
  28009. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28010. static readonly INCR_WRAP: number;
  28011. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28012. static readonly DECR_WRAP: number;
  28013. /** Texture is not repeating outside of 0..1 UVs */
  28014. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28015. /** Texture is repeating outside of 0..1 UVs */
  28016. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28017. /** Texture is repeating and mirrored */
  28018. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28019. /** ALPHA */
  28020. static readonly TEXTUREFORMAT_ALPHA: number;
  28021. /** LUMINANCE */
  28022. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28023. /** LUMINANCE_ALPHA */
  28024. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28025. /** RGB */
  28026. static readonly TEXTUREFORMAT_RGB: number;
  28027. /** RGBA */
  28028. static readonly TEXTUREFORMAT_RGBA: number;
  28029. /** RED */
  28030. static readonly TEXTUREFORMAT_RED: number;
  28031. /** RED (2nd reference) */
  28032. static readonly TEXTUREFORMAT_R: number;
  28033. /** RG */
  28034. static readonly TEXTUREFORMAT_RG: number;
  28035. /** RED_INTEGER */
  28036. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28037. /** RED_INTEGER (2nd reference) */
  28038. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28039. /** RG_INTEGER */
  28040. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28041. /** RGB_INTEGER */
  28042. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28043. /** RGBA_INTEGER */
  28044. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28045. /** UNSIGNED_BYTE */
  28046. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28047. /** UNSIGNED_BYTE (2nd reference) */
  28048. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28049. /** FLOAT */
  28050. static readonly TEXTURETYPE_FLOAT: number;
  28051. /** HALF_FLOAT */
  28052. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28053. /** BYTE */
  28054. static readonly TEXTURETYPE_BYTE: number;
  28055. /** SHORT */
  28056. static readonly TEXTURETYPE_SHORT: number;
  28057. /** UNSIGNED_SHORT */
  28058. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28059. /** INT */
  28060. static readonly TEXTURETYPE_INT: number;
  28061. /** UNSIGNED_INT */
  28062. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28063. /** UNSIGNED_SHORT_4_4_4_4 */
  28064. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28065. /** UNSIGNED_SHORT_5_5_5_1 */
  28066. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28067. /** UNSIGNED_SHORT_5_6_5 */
  28068. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28069. /** UNSIGNED_INT_2_10_10_10_REV */
  28070. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28071. /** UNSIGNED_INT_24_8 */
  28072. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28073. /** UNSIGNED_INT_10F_11F_11F_REV */
  28074. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28075. /** UNSIGNED_INT_5_9_9_9_REV */
  28076. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28077. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28078. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28079. /** nearest is mag = nearest and min = nearest and mip = linear */
  28080. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28081. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28082. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28083. /** Trilinear is mag = linear and min = linear and mip = linear */
  28084. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28085. /** nearest is mag = nearest and min = nearest and mip = linear */
  28086. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28087. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28088. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28089. /** Trilinear is mag = linear and min = linear and mip = linear */
  28090. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28091. /** mag = nearest and min = nearest and mip = nearest */
  28092. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28093. /** mag = nearest and min = linear and mip = nearest */
  28094. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28095. /** mag = nearest and min = linear and mip = linear */
  28096. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28097. /** mag = nearest and min = linear and mip = none */
  28098. static readonly TEXTURE_NEAREST_LINEAR: number;
  28099. /** mag = nearest and min = nearest and mip = none */
  28100. static readonly TEXTURE_NEAREST_NEAREST: number;
  28101. /** mag = linear and min = nearest and mip = nearest */
  28102. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28103. /** mag = linear and min = nearest and mip = linear */
  28104. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28105. /** mag = linear and min = linear and mip = none */
  28106. static readonly TEXTURE_LINEAR_LINEAR: number;
  28107. /** mag = linear and min = nearest and mip = none */
  28108. static readonly TEXTURE_LINEAR_NEAREST: number;
  28109. /** Explicit coordinates mode */
  28110. static readonly TEXTURE_EXPLICIT_MODE: number;
  28111. /** Spherical coordinates mode */
  28112. static readonly TEXTURE_SPHERICAL_MODE: number;
  28113. /** Planar coordinates mode */
  28114. static readonly TEXTURE_PLANAR_MODE: number;
  28115. /** Cubic coordinates mode */
  28116. static readonly TEXTURE_CUBIC_MODE: number;
  28117. /** Projection coordinates mode */
  28118. static readonly TEXTURE_PROJECTION_MODE: number;
  28119. /** Skybox coordinates mode */
  28120. static readonly TEXTURE_SKYBOX_MODE: number;
  28121. /** Inverse Cubic coordinates mode */
  28122. static readonly TEXTURE_INVCUBIC_MODE: number;
  28123. /** Equirectangular coordinates mode */
  28124. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28125. /** Equirectangular Fixed coordinates mode */
  28126. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28127. /** Equirectangular Fixed Mirrored coordinates mode */
  28128. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28129. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28130. static readonly SCALEMODE_FLOOR: number;
  28131. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28132. static readonly SCALEMODE_NEAREST: number;
  28133. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28134. static readonly SCALEMODE_CEILING: number;
  28135. /**
  28136. * Returns the current npm package of the sdk
  28137. */
  28138. static readonly NpmPackage: string;
  28139. /**
  28140. * Returns the current version of the framework
  28141. */
  28142. static readonly Version: string;
  28143. /**
  28144. * Returns a string describing the current engine
  28145. */
  28146. readonly description: string;
  28147. /**
  28148. * Gets or sets the epsilon value used by collision engine
  28149. */
  28150. static CollisionsEpsilon: number;
  28151. /**
  28152. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28153. */
  28154. static ShadersRepository: string;
  28155. /**
  28156. * Method called to create the default loading screen.
  28157. * This can be overriden in your own app.
  28158. * @param canvas The rendering canvas element
  28159. * @returns The loading screen
  28160. */
  28161. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28162. /**
  28163. * Method called to create the default rescale post process on each engine.
  28164. */
  28165. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28166. /**
  28167. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28168. */
  28169. forcePOTTextures: boolean;
  28170. /**
  28171. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28172. */
  28173. isFullscreen: boolean;
  28174. /**
  28175. * Gets a boolean indicating if the pointer is currently locked
  28176. */
  28177. isPointerLock: boolean;
  28178. /**
  28179. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28180. */
  28181. cullBackFaces: boolean;
  28182. /**
  28183. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28184. */
  28185. renderEvenInBackground: boolean;
  28186. /**
  28187. * Gets or sets a boolean indicating that cache can be kept between frames
  28188. */
  28189. preventCacheWipeBetweenFrames: boolean;
  28190. /**
  28191. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28192. **/
  28193. enableOfflineSupport: boolean;
  28194. /**
  28195. * 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)
  28196. **/
  28197. disableManifestCheck: boolean;
  28198. /**
  28199. * Gets the list of created scenes
  28200. */
  28201. scenes: Scene[];
  28202. /**
  28203. * Event raised when a new scene is created
  28204. */
  28205. onNewSceneAddedObservable: Observable<Scene>;
  28206. /**
  28207. * Gets the list of created postprocesses
  28208. */
  28209. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28210. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28211. validateShaderPrograms: boolean;
  28212. /**
  28213. * Observable event triggered each time the rendering canvas is resized
  28214. */
  28215. onResizeObservable: Observable<Engine>;
  28216. /**
  28217. * Observable event triggered each time the canvas loses focus
  28218. */
  28219. onCanvasBlurObservable: Observable<Engine>;
  28220. /**
  28221. * Observable event triggered each time the canvas gains focus
  28222. */
  28223. onCanvasFocusObservable: Observable<Engine>;
  28224. /**
  28225. * Observable event triggered each time the canvas receives pointerout event
  28226. */
  28227. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28228. /**
  28229. * Observable event triggered before each texture is initialized
  28230. */
  28231. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28232. /**
  28233. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28234. */
  28235. disableUniformBuffers: boolean;
  28236. /** @hidden */
  28237. _uniformBuffers: UniformBuffer[];
  28238. /**
  28239. * Gets a boolean indicating that the engine supports uniform buffers
  28240. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28241. */
  28242. readonly supportsUniformBuffers: boolean;
  28243. /**
  28244. * Observable raised when the engine begins a new frame
  28245. */
  28246. onBeginFrameObservable: Observable<Engine>;
  28247. /**
  28248. * If set, will be used to request the next animation frame for the render loop
  28249. */
  28250. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28251. /**
  28252. * Observable raised when the engine ends the current frame
  28253. */
  28254. onEndFrameObservable: Observable<Engine>;
  28255. /**
  28256. * Observable raised when the engine is about to compile a shader
  28257. */
  28258. onBeforeShaderCompilationObservable: Observable<Engine>;
  28259. /**
  28260. * Observable raised when the engine has jsut compiled a shader
  28261. */
  28262. onAfterShaderCompilationObservable: Observable<Engine>;
  28263. /** @hidden */
  28264. _gl: WebGLRenderingContext;
  28265. private _renderingCanvas;
  28266. private _windowIsBackground;
  28267. private _webGLVersion;
  28268. protected _highPrecisionShadersAllowed: boolean;
  28269. /** @hidden */
  28270. readonly _shouldUseHighPrecisionShader: boolean;
  28271. /**
  28272. * Gets a boolean indicating that only power of 2 textures are supported
  28273. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28274. */
  28275. readonly needPOTTextures: boolean;
  28276. /** @hidden */
  28277. _badOS: boolean;
  28278. /** @hidden */
  28279. _badDesktopOS: boolean;
  28280. /**
  28281. * Gets the audio engine
  28282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28283. * @ignorenaming
  28284. */
  28285. static audioEngine: IAudioEngine;
  28286. /**
  28287. * Default AudioEngine factory responsible of creating the Audio Engine.
  28288. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28289. */
  28290. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28291. /**
  28292. * Default offline support factory responsible of creating a tool used to store data locally.
  28293. * By default, this will create a Database object if the workload has been embedded.
  28294. */
  28295. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28296. private _onFocus;
  28297. private _onBlur;
  28298. private _onCanvasPointerOut;
  28299. private _onCanvasBlur;
  28300. private _onCanvasFocus;
  28301. private _onFullscreenChange;
  28302. private _onPointerLockChange;
  28303. private _hardwareScalingLevel;
  28304. /** @hidden */
  28305. _caps: EngineCapabilities;
  28306. private _pointerLockRequested;
  28307. private _isStencilEnable;
  28308. private _colorWrite;
  28309. private _loadingScreen;
  28310. /** @hidden */
  28311. _drawCalls: PerfCounter;
  28312. private _glVersion;
  28313. private _glRenderer;
  28314. private _glVendor;
  28315. private _videoTextureSupported;
  28316. private _renderingQueueLaunched;
  28317. private _activeRenderLoops;
  28318. private _deterministicLockstep;
  28319. private _lockstepMaxSteps;
  28320. /**
  28321. * Observable signaled when a context lost event is raised
  28322. */
  28323. onContextLostObservable: Observable<Engine>;
  28324. /**
  28325. * Observable signaled when a context restored event is raised
  28326. */
  28327. onContextRestoredObservable: Observable<Engine>;
  28328. private _onContextLost;
  28329. private _onContextRestored;
  28330. private _contextWasLost;
  28331. /** @hidden */
  28332. _doNotHandleContextLost: boolean;
  28333. /**
  28334. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28335. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28336. */
  28337. doNotHandleContextLost: boolean;
  28338. private _performanceMonitor;
  28339. private _fps;
  28340. private _deltaTime;
  28341. /**
  28342. * Turn this value on if you want to pause FPS computation when in background
  28343. */
  28344. disablePerformanceMonitorInBackground: boolean;
  28345. /**
  28346. * Gets the performance monitor attached to this engine
  28347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28348. */
  28349. readonly performanceMonitor: PerformanceMonitor;
  28350. /**
  28351. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28352. */
  28353. disableVertexArrayObjects: boolean;
  28354. /** @hidden */
  28355. protected _depthCullingState: _DepthCullingState;
  28356. /** @hidden */
  28357. protected _stencilState: _StencilState;
  28358. /** @hidden */
  28359. protected _alphaState: _AlphaState;
  28360. /** @hidden */
  28361. protected _alphaMode: number;
  28362. /** @hidden */
  28363. _internalTexturesCache: InternalTexture[];
  28364. /** @hidden */
  28365. protected _activeChannel: number;
  28366. private _currentTextureChannel;
  28367. /** @hidden */
  28368. protected _boundTexturesCache: {
  28369. [key: string]: Nullable<InternalTexture>;
  28370. };
  28371. /** @hidden */
  28372. protected _currentEffect: Nullable<Effect>;
  28373. /** @hidden */
  28374. protected _currentProgram: Nullable<WebGLProgram>;
  28375. private _compiledEffects;
  28376. private _vertexAttribArraysEnabled;
  28377. /** @hidden */
  28378. protected _cachedViewport: Nullable<Viewport>;
  28379. private _cachedVertexArrayObject;
  28380. /** @hidden */
  28381. protected _cachedVertexBuffers: any;
  28382. /** @hidden */
  28383. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28384. /** @hidden */
  28385. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28386. /** @hidden */
  28387. _currentRenderTarget: Nullable<InternalTexture>;
  28388. private _uintIndicesCurrentlySet;
  28389. private _currentBoundBuffer;
  28390. /** @hidden */
  28391. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28392. private _currentBufferPointers;
  28393. private _currentInstanceLocations;
  28394. private _currentInstanceBuffers;
  28395. private _textureUnits;
  28396. /** @hidden */
  28397. _workingCanvas: Nullable<HTMLCanvasElement>;
  28398. /** @hidden */
  28399. _workingContext: Nullable<CanvasRenderingContext2D>;
  28400. private _rescalePostProcess;
  28401. private _dummyFramebuffer;
  28402. private _externalData;
  28403. /** @hidden */
  28404. _bindedRenderFunction: any;
  28405. private _vaoRecordInProgress;
  28406. private _mustWipeVertexAttributes;
  28407. private _emptyTexture;
  28408. private _emptyCubeTexture;
  28409. private _emptyTexture3D;
  28410. /** @hidden */
  28411. _frameHandler: number;
  28412. private _nextFreeTextureSlots;
  28413. private _maxSimultaneousTextures;
  28414. private _activeRequests;
  28415. private _texturesSupported;
  28416. /** @hidden */
  28417. _textureFormatInUse: Nullable<string>;
  28418. /**
  28419. * Gets the list of texture formats supported
  28420. */
  28421. readonly texturesSupported: Array<string>;
  28422. /**
  28423. * Gets the list of texture formats in use
  28424. */
  28425. readonly textureFormatInUse: Nullable<string>;
  28426. /**
  28427. * Gets the current viewport
  28428. */
  28429. readonly currentViewport: Nullable<Viewport>;
  28430. /**
  28431. * Gets the default empty texture
  28432. */
  28433. readonly emptyTexture: InternalTexture;
  28434. /**
  28435. * Gets the default empty 3D texture
  28436. */
  28437. readonly emptyTexture3D: InternalTexture;
  28438. /**
  28439. * Gets the default empty cube texture
  28440. */
  28441. readonly emptyCubeTexture: InternalTexture;
  28442. /**
  28443. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28444. */
  28445. readonly premultipliedAlpha: boolean;
  28446. /**
  28447. * Creates a new engine
  28448. * @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
  28449. * @param antialias defines enable antialiasing (default: false)
  28450. * @param options defines further options to be sent to the getContext() function
  28451. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28452. */
  28453. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28454. /**
  28455. * Initializes a webVR display and starts listening to display change events
  28456. * The onVRDisplayChangedObservable will be notified upon these changes
  28457. * @returns The onVRDisplayChangedObservable
  28458. */
  28459. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28460. /** @hidden */
  28461. _prepareVRComponent(): void;
  28462. /** @hidden */
  28463. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28464. /** @hidden */
  28465. _submitVRFrame(): void;
  28466. /**
  28467. * Call this function to leave webVR mode
  28468. * Will do nothing if webVR is not supported or if there is no webVR device
  28469. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28470. */
  28471. disableVR(): void;
  28472. /**
  28473. * Gets a boolean indicating that the system is in VR mode and is presenting
  28474. * @returns true if VR mode is engaged
  28475. */
  28476. isVRPresenting(): boolean;
  28477. /** @hidden */
  28478. _requestVRFrame(): void;
  28479. private _disableTouchAction;
  28480. private _rebuildInternalTextures;
  28481. private _rebuildEffects;
  28482. /**
  28483. * Gets a boolean indicating if all created effects are ready
  28484. * @returns true if all effects are ready
  28485. */
  28486. areAllEffectsReady(): boolean;
  28487. private _rebuildBuffers;
  28488. private _initGLContext;
  28489. /**
  28490. * Gets version of the current webGL context
  28491. */
  28492. readonly webGLVersion: number;
  28493. /**
  28494. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28495. */
  28496. readonly isStencilEnable: boolean;
  28497. /** @hidden */
  28498. _prepareWorkingCanvas(): void;
  28499. /**
  28500. * Reset the texture cache to empty state
  28501. */
  28502. resetTextureCache(): void;
  28503. /**
  28504. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28506. * @returns true if engine is in deterministic lock step mode
  28507. */
  28508. isDeterministicLockStep(): boolean;
  28509. /**
  28510. * Gets the max steps when engine is running in deterministic lock step
  28511. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28512. * @returns the max steps
  28513. */
  28514. getLockstepMaxSteps(): number;
  28515. /**
  28516. * Gets an object containing information about the current webGL context
  28517. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28518. */
  28519. getGlInfo(): {
  28520. vendor: string;
  28521. renderer: string;
  28522. version: string;
  28523. };
  28524. /**
  28525. * Gets current aspect ratio
  28526. * @param camera defines the camera to use to get the aspect ratio
  28527. * @param useScreen defines if screen size must be used (or the current render target if any)
  28528. * @returns a number defining the aspect ratio
  28529. */
  28530. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28531. /**
  28532. * Gets current screen aspect ratio
  28533. * @returns a number defining the aspect ratio
  28534. */
  28535. getScreenAspectRatio(): number;
  28536. /**
  28537. * Gets the current render width
  28538. * @param useScreen defines if screen size must be used (or the current render target if any)
  28539. * @returns a number defining the current render width
  28540. */
  28541. getRenderWidth(useScreen?: boolean): number;
  28542. /**
  28543. * Gets the current render height
  28544. * @param useScreen defines if screen size must be used (or the current render target if any)
  28545. * @returns a number defining the current render height
  28546. */
  28547. getRenderHeight(useScreen?: boolean): number;
  28548. /**
  28549. * Gets the HTML canvas attached with the current webGL context
  28550. * @returns a HTML canvas
  28551. */
  28552. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28553. /**
  28554. * Gets the client rect of the HTML canvas attached with the current webGL context
  28555. * @returns a client rectanglee
  28556. */
  28557. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28558. /**
  28559. * Defines the hardware scaling level.
  28560. * By default the hardware scaling level is computed from the window device ratio.
  28561. * 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.
  28562. * @param level defines the level to use
  28563. */
  28564. setHardwareScalingLevel(level: number): void;
  28565. /**
  28566. * Gets the current hardware scaling level.
  28567. * By default the hardware scaling level is computed from the window device ratio.
  28568. * 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.
  28569. * @returns a number indicating the current hardware scaling level
  28570. */
  28571. getHardwareScalingLevel(): number;
  28572. /**
  28573. * Gets the list of loaded textures
  28574. * @returns an array containing all loaded textures
  28575. */
  28576. getLoadedTexturesCache(): InternalTexture[];
  28577. /**
  28578. * Gets the object containing all engine capabilities
  28579. * @returns the EngineCapabilities object
  28580. */
  28581. getCaps(): EngineCapabilities;
  28582. /**
  28583. * Gets the current depth function
  28584. * @returns a number defining the depth function
  28585. */
  28586. getDepthFunction(): Nullable<number>;
  28587. /**
  28588. * Sets the current depth function
  28589. * @param depthFunc defines the function to use
  28590. */
  28591. setDepthFunction(depthFunc: number): void;
  28592. /**
  28593. * Sets the current depth function to GREATER
  28594. */
  28595. setDepthFunctionToGreater(): void;
  28596. /**
  28597. * Sets the current depth function to GEQUAL
  28598. */
  28599. setDepthFunctionToGreaterOrEqual(): void;
  28600. /**
  28601. * Sets the current depth function to LESS
  28602. */
  28603. setDepthFunctionToLess(): void;
  28604. private _cachedStencilBuffer;
  28605. private _cachedStencilFunction;
  28606. private _cachedStencilMask;
  28607. private _cachedStencilOperationPass;
  28608. private _cachedStencilOperationFail;
  28609. private _cachedStencilOperationDepthFail;
  28610. private _cachedStencilReference;
  28611. /**
  28612. * Caches the the state of the stencil buffer
  28613. */
  28614. cacheStencilState(): void;
  28615. /**
  28616. * Restores the state of the stencil buffer
  28617. */
  28618. restoreStencilState(): void;
  28619. /**
  28620. * Sets the current depth function to LEQUAL
  28621. */
  28622. setDepthFunctionToLessOrEqual(): void;
  28623. /**
  28624. * Gets a boolean indicating if stencil buffer is enabled
  28625. * @returns the current stencil buffer state
  28626. */
  28627. getStencilBuffer(): boolean;
  28628. /**
  28629. * Enable or disable the stencil buffer
  28630. * @param enable defines if the stencil buffer must be enabled or disabled
  28631. */
  28632. setStencilBuffer(enable: boolean): void;
  28633. /**
  28634. * Gets the current stencil mask
  28635. * @returns a number defining the new stencil mask to use
  28636. */
  28637. getStencilMask(): number;
  28638. /**
  28639. * Sets the current stencil mask
  28640. * @param mask defines the new stencil mask to use
  28641. */
  28642. setStencilMask(mask: number): void;
  28643. /**
  28644. * Gets the current stencil function
  28645. * @returns a number defining the stencil function to use
  28646. */
  28647. getStencilFunction(): number;
  28648. /**
  28649. * Gets the current stencil reference value
  28650. * @returns a number defining the stencil reference value to use
  28651. */
  28652. getStencilFunctionReference(): number;
  28653. /**
  28654. * Gets the current stencil mask
  28655. * @returns a number defining the stencil mask to use
  28656. */
  28657. getStencilFunctionMask(): number;
  28658. /**
  28659. * Sets the current stencil function
  28660. * @param stencilFunc defines the new stencil function to use
  28661. */
  28662. setStencilFunction(stencilFunc: number): void;
  28663. /**
  28664. * Sets the current stencil reference
  28665. * @param reference defines the new stencil reference to use
  28666. */
  28667. setStencilFunctionReference(reference: number): void;
  28668. /**
  28669. * Sets the current stencil mask
  28670. * @param mask defines the new stencil mask to use
  28671. */
  28672. setStencilFunctionMask(mask: number): void;
  28673. /**
  28674. * Gets the current stencil operation when stencil fails
  28675. * @returns a number defining stencil operation to use when stencil fails
  28676. */
  28677. getStencilOperationFail(): number;
  28678. /**
  28679. * Gets the current stencil operation when depth fails
  28680. * @returns a number defining stencil operation to use when depth fails
  28681. */
  28682. getStencilOperationDepthFail(): number;
  28683. /**
  28684. * Gets the current stencil operation when stencil passes
  28685. * @returns a number defining stencil operation to use when stencil passes
  28686. */
  28687. getStencilOperationPass(): number;
  28688. /**
  28689. * Sets the stencil operation to use when stencil fails
  28690. * @param operation defines the stencil operation to use when stencil fails
  28691. */
  28692. setStencilOperationFail(operation: number): void;
  28693. /**
  28694. * Sets the stencil operation to use when depth fails
  28695. * @param operation defines the stencil operation to use when depth fails
  28696. */
  28697. setStencilOperationDepthFail(operation: number): void;
  28698. /**
  28699. * Sets the stencil operation to use when stencil passes
  28700. * @param operation defines the stencil operation to use when stencil passes
  28701. */
  28702. setStencilOperationPass(operation: number): void;
  28703. /**
  28704. * Sets a boolean indicating if the dithering state is enabled or disabled
  28705. * @param value defines the dithering state
  28706. */
  28707. setDitheringState(value: boolean): void;
  28708. /**
  28709. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28710. * @param value defines the rasterizer state
  28711. */
  28712. setRasterizerState(value: boolean): void;
  28713. /**
  28714. * stop executing a render loop function and remove it from the execution array
  28715. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28716. */
  28717. stopRenderLoop(renderFunction?: () => void): void;
  28718. /** @hidden */
  28719. _renderLoop(): void;
  28720. /**
  28721. * Register and execute a render loop. The engine can have more than one render function
  28722. * @param renderFunction defines the function to continuously execute
  28723. */
  28724. runRenderLoop(renderFunction: () => void): void;
  28725. /**
  28726. * Toggle full screen mode
  28727. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28728. */
  28729. switchFullscreen(requestPointerLock: boolean): void;
  28730. /**
  28731. * Enters full screen mode
  28732. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28733. */
  28734. enterFullscreen(requestPointerLock: boolean): void;
  28735. /**
  28736. * Exits full screen mode
  28737. */
  28738. exitFullscreen(): void;
  28739. /**
  28740. * Clear the current render buffer or the current render target (if any is set up)
  28741. * @param color defines the color to use
  28742. * @param backBuffer defines if the back buffer must be cleared
  28743. * @param depth defines if the depth buffer must be cleared
  28744. * @param stencil defines if the stencil buffer must be cleared
  28745. */
  28746. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28747. /**
  28748. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28749. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28750. * @param y defines the y-coordinate of the corner of the clear rectangle
  28751. * @param width defines the width of the clear rectangle
  28752. * @param height defines the height of the clear rectangle
  28753. * @param clearColor defines the clear color
  28754. */
  28755. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28756. /**
  28757. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28758. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28759. * @param y defines the y-coordinate of the corner of the clear rectangle
  28760. * @param width defines the width of the clear rectangle
  28761. * @param height defines the height of the clear rectangle
  28762. */
  28763. enableScissor(x: number, y: number, width: number, height: number): void;
  28764. /**
  28765. * Disable previously set scissor test rectangle
  28766. */
  28767. disableScissor(): void;
  28768. private _viewportCached;
  28769. /** @hidden */
  28770. _viewport(x: number, y: number, width: number, height: number): void;
  28771. /**
  28772. * Set the WebGL's viewport
  28773. * @param viewport defines the viewport element to be used
  28774. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28775. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28776. */
  28777. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28778. /**
  28779. * Directly set the WebGL Viewport
  28780. * @param x defines the x coordinate of the viewport (in screen space)
  28781. * @param y defines the y coordinate of the viewport (in screen space)
  28782. * @param width defines the width of the viewport (in screen space)
  28783. * @param height defines the height of the viewport (in screen space)
  28784. * @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
  28785. */
  28786. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28787. /**
  28788. * Begin a new frame
  28789. */
  28790. beginFrame(): void;
  28791. /**
  28792. * Enf the current frame
  28793. */
  28794. endFrame(): void;
  28795. /**
  28796. * Resize the view according to the canvas' size
  28797. */
  28798. resize(): void;
  28799. /**
  28800. * Force a specific size of the canvas
  28801. * @param width defines the new canvas' width
  28802. * @param height defines the new canvas' height
  28803. */
  28804. setSize(width: number, height: number): void;
  28805. /**
  28806. * Binds the frame buffer to the specified texture.
  28807. * @param texture The texture to render to or null for the default canvas
  28808. * @param faceIndex The face of the texture to render to in case of cube texture
  28809. * @param requiredWidth The width of the target to render to
  28810. * @param requiredHeight The height of the target to render to
  28811. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28812. * @param depthStencilTexture The depth stencil texture to use to render
  28813. * @param lodLevel defines le lod level to bind to the frame buffer
  28814. */
  28815. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28816. /** @hidden */
  28817. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28818. /**
  28819. * Unbind the current render target texture from the webGL context
  28820. * @param texture defines the render target texture to unbind
  28821. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28822. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28823. */
  28824. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28825. /**
  28826. * Force the mipmap generation for the given render target texture
  28827. * @param texture defines the render target texture to use
  28828. */
  28829. generateMipMapsForCubemap(texture: InternalTexture): void;
  28830. /**
  28831. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28832. */
  28833. flushFramebuffer(): void;
  28834. /**
  28835. * Unbind the current render target and bind the default framebuffer
  28836. */
  28837. restoreDefaultFramebuffer(): void;
  28838. /**
  28839. * Create an uniform buffer
  28840. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28841. * @param elements defines the content of the uniform buffer
  28842. * @returns the webGL uniform buffer
  28843. */
  28844. createUniformBuffer(elements: FloatArray): DataBuffer;
  28845. /**
  28846. * Create a dynamic uniform buffer
  28847. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28848. * @param elements defines the content of the uniform buffer
  28849. * @returns the webGL uniform buffer
  28850. */
  28851. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28852. /**
  28853. * Update an existing uniform buffer
  28854. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28855. * @param uniformBuffer defines the target uniform buffer
  28856. * @param elements defines the content to update
  28857. * @param offset defines the offset in the uniform buffer where update should start
  28858. * @param count defines the size of the data to update
  28859. */
  28860. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28861. private _resetVertexBufferBinding;
  28862. /**
  28863. * Creates a vertex buffer
  28864. * @param data the data for the vertex buffer
  28865. * @returns the new WebGL static buffer
  28866. */
  28867. createVertexBuffer(data: DataArray): DataBuffer;
  28868. /**
  28869. * Creates a dynamic vertex buffer
  28870. * @param data the data for the dynamic vertex buffer
  28871. * @returns the new WebGL dynamic buffer
  28872. */
  28873. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28874. /**
  28875. * Update a dynamic index buffer
  28876. * @param indexBuffer defines the target index buffer
  28877. * @param indices defines the data to update
  28878. * @param offset defines the offset in the target index buffer where update should start
  28879. */
  28880. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28881. /**
  28882. * Updates a dynamic vertex buffer.
  28883. * @param vertexBuffer the vertex buffer to update
  28884. * @param data the data used to update the vertex buffer
  28885. * @param byteOffset the byte offset of the data
  28886. * @param byteLength the byte length of the data
  28887. */
  28888. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28889. private _resetIndexBufferBinding;
  28890. /**
  28891. * Creates a new index buffer
  28892. * @param indices defines the content of the index buffer
  28893. * @param updatable defines if the index buffer must be updatable
  28894. * @returns a new webGL buffer
  28895. */
  28896. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28897. /**
  28898. * Bind a webGL buffer to the webGL context
  28899. * @param buffer defines the buffer to bind
  28900. */
  28901. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28902. /**
  28903. * Bind an uniform buffer to the current webGL context
  28904. * @param buffer defines the buffer to bind
  28905. */
  28906. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28907. /**
  28908. * Bind a buffer to the current webGL context at a given location
  28909. * @param buffer defines the buffer to bind
  28910. * @param location defines the index where to bind the buffer
  28911. */
  28912. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28913. /**
  28914. * Bind a specific block at a given index in a specific shader program
  28915. * @param pipelineContext defines the pipeline context to use
  28916. * @param blockName defines the block name
  28917. * @param index defines the index where to bind the block
  28918. */
  28919. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28920. private bindIndexBuffer;
  28921. private bindBuffer;
  28922. /**
  28923. * update the bound buffer with the given data
  28924. * @param data defines the data to update
  28925. */
  28926. updateArrayBuffer(data: Float32Array): void;
  28927. private _vertexAttribPointer;
  28928. private _bindIndexBufferWithCache;
  28929. private _bindVertexBuffersAttributes;
  28930. /**
  28931. * Records a vertex array object
  28932. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28933. * @param vertexBuffers defines the list of vertex buffers to store
  28934. * @param indexBuffer defines the index buffer to store
  28935. * @param effect defines the effect to store
  28936. * @returns the new vertex array object
  28937. */
  28938. recordVertexArrayObject(vertexBuffers: {
  28939. [key: string]: VertexBuffer;
  28940. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28941. /**
  28942. * Bind a specific vertex array object
  28943. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28944. * @param vertexArrayObject defines the vertex array object to bind
  28945. * @param indexBuffer defines the index buffer to bind
  28946. */
  28947. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28948. /**
  28949. * Bind webGl buffers directly to the webGL context
  28950. * @param vertexBuffer defines the vertex buffer to bind
  28951. * @param indexBuffer defines the index buffer to bind
  28952. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28953. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28954. * @param effect defines the effect associated with the vertex buffer
  28955. */
  28956. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28957. private _unbindVertexArrayObject;
  28958. /**
  28959. * Bind a list of vertex buffers to the webGL context
  28960. * @param vertexBuffers defines the list of vertex buffers to bind
  28961. * @param indexBuffer defines the index buffer to bind
  28962. * @param effect defines the effect associated with the vertex buffers
  28963. */
  28964. bindBuffers(vertexBuffers: {
  28965. [key: string]: Nullable<VertexBuffer>;
  28966. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28967. /**
  28968. * Unbind all instance attributes
  28969. */
  28970. unbindInstanceAttributes(): void;
  28971. /**
  28972. * Release and free the memory of a vertex array object
  28973. * @param vao defines the vertex array object to delete
  28974. */
  28975. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28976. /** @hidden */
  28977. _releaseBuffer(buffer: DataBuffer): boolean;
  28978. /**
  28979. * Creates a webGL buffer to use with instanciation
  28980. * @param capacity defines the size of the buffer
  28981. * @returns the webGL buffer
  28982. */
  28983. createInstancesBuffer(capacity: number): DataBuffer;
  28984. /**
  28985. * Delete a webGL buffer used with instanciation
  28986. * @param buffer defines the webGL buffer to delete
  28987. */
  28988. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28989. /**
  28990. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28991. * @param instancesBuffer defines the webGL buffer to update and bind
  28992. * @param data defines the data to store in the buffer
  28993. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28994. */
  28995. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28996. /**
  28997. * Apply all cached states (depth, culling, stencil and alpha)
  28998. */
  28999. applyStates(): void;
  29000. /**
  29001. * Send a draw order
  29002. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29003. * @param indexStart defines the starting index
  29004. * @param indexCount defines the number of index to draw
  29005. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29006. */
  29007. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29008. /**
  29009. * Draw a list of points
  29010. * @param verticesStart defines the index of first vertex to draw
  29011. * @param verticesCount defines the count of vertices to draw
  29012. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29013. */
  29014. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29015. /**
  29016. * Draw a list of unindexed primitives
  29017. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29018. * @param verticesStart defines the index of first vertex to draw
  29019. * @param verticesCount defines the count of vertices to draw
  29020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29021. */
  29022. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29023. /**
  29024. * Draw a list of indexed primitives
  29025. * @param fillMode defines the primitive to use
  29026. * @param indexStart defines the starting index
  29027. * @param indexCount defines the number of index to draw
  29028. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29029. */
  29030. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29031. /**
  29032. * Draw a list of unindexed primitives
  29033. * @param fillMode defines the primitive to use
  29034. * @param verticesStart defines the index of first vertex to draw
  29035. * @param verticesCount defines the count of vertices to draw
  29036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29037. */
  29038. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29039. private _drawMode;
  29040. /** @hidden */
  29041. _releaseEffect(effect: Effect): void;
  29042. /** @hidden */
  29043. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29044. /**
  29045. * Create a new effect (used to store vertex/fragment shaders)
  29046. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29047. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29048. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29049. * @param samplers defines an array of string used to represent textures
  29050. * @param defines defines the string containing the defines to use to compile the shaders
  29051. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29052. * @param onCompiled defines a function to call when the effect creation is successful
  29053. * @param onError defines a function to call when the effect creation has failed
  29054. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29055. * @returns the new Effect
  29056. */
  29057. 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;
  29058. private _compileShader;
  29059. private _compileRawShader;
  29060. /**
  29061. * Directly creates a webGL program
  29062. * @param pipelineContext defines the pipeline context to attach to
  29063. * @param vertexCode defines the vertex shader code to use
  29064. * @param fragmentCode defines the fragment shader code to use
  29065. * @param context defines the webGL context to use (if not set, the current one will be used)
  29066. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29067. * @returns the new webGL program
  29068. */
  29069. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29070. /**
  29071. * Creates a webGL program
  29072. * @param pipelineContext defines the pipeline context to attach to
  29073. * @param vertexCode defines the vertex shader code to use
  29074. * @param fragmentCode defines the fragment shader code to use
  29075. * @param defines defines the string containing the defines to use to compile the shaders
  29076. * @param context defines the webGL context to use (if not set, the current one will be used)
  29077. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29078. * @returns the new webGL program
  29079. */
  29080. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29081. /**
  29082. * Creates a new pipeline context
  29083. * @returns the new pipeline
  29084. */
  29085. createPipelineContext(): WebGLPipelineContext;
  29086. private _createShaderProgram;
  29087. private _finalizePipelineContext;
  29088. /** @hidden */
  29089. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29090. /** @hidden */
  29091. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29092. /** @hidden */
  29093. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29094. /**
  29095. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29096. * @param pipelineContext defines the pipeline context to use
  29097. * @param uniformsNames defines the list of uniform names
  29098. * @returns an array of webGL uniform locations
  29099. */
  29100. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29101. /**
  29102. * Gets the lsit of active attributes for a given webGL program
  29103. * @param pipelineContext defines the pipeline context to use
  29104. * @param attributesNames defines the list of attribute names to get
  29105. * @returns an array of indices indicating the offset of each attribute
  29106. */
  29107. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29108. /**
  29109. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29110. * @param effect defines the effect to activate
  29111. */
  29112. enableEffect(effect: Nullable<Effect>): void;
  29113. /**
  29114. * Set the value of an uniform to an array of int32
  29115. * @param uniform defines the webGL uniform location where to store the value
  29116. * @param array defines the array of int32 to store
  29117. */
  29118. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29119. /**
  29120. * Set the value of an uniform to an array of int32 (stored as vec2)
  29121. * @param uniform defines the webGL uniform location where to store the value
  29122. * @param array defines the array of int32 to store
  29123. */
  29124. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29125. /**
  29126. * Set the value of an uniform to an array of int32 (stored as vec3)
  29127. * @param uniform defines the webGL uniform location where to store the value
  29128. * @param array defines the array of int32 to store
  29129. */
  29130. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29131. /**
  29132. * Set the value of an uniform to an array of int32 (stored as vec4)
  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. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29137. /**
  29138. * Set the value of an uniform to an array of float32
  29139. * @param uniform defines the webGL uniform location where to store the value
  29140. * @param array defines the array of float32 to store
  29141. */
  29142. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29143. /**
  29144. * Set the value of an uniform to an array of float32 (stored as vec2)
  29145. * @param uniform defines the webGL uniform location where to store the value
  29146. * @param array defines the array of float32 to store
  29147. */
  29148. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29149. /**
  29150. * Set the value of an uniform to an array of float32 (stored as vec3)
  29151. * @param uniform defines the webGL uniform location where to store the value
  29152. * @param array defines the array of float32 to store
  29153. */
  29154. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29155. /**
  29156. * Set the value of an uniform to an array of float32 (stored as vec4)
  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. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29161. /**
  29162. * Set the value of an uniform to an array of number
  29163. * @param uniform defines the webGL uniform location where to store the value
  29164. * @param array defines the array of number to store
  29165. */
  29166. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29167. /**
  29168. * Set the value of an uniform to an array of number (stored as vec2)
  29169. * @param uniform defines the webGL uniform location where to store the value
  29170. * @param array defines the array of number to store
  29171. */
  29172. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29173. /**
  29174. * Set the value of an uniform to an array of number (stored as vec3)
  29175. * @param uniform defines the webGL uniform location where to store the value
  29176. * @param array defines the array of number to store
  29177. */
  29178. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29179. /**
  29180. * Set the value of an uniform to an array of number (stored as vec4)
  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. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29185. /**
  29186. * Set the value of an uniform to an array of float32 (stored as matrices)
  29187. * @param uniform defines the webGL uniform location where to store the value
  29188. * @param matrices defines the array of float32 to store
  29189. */
  29190. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29191. /**
  29192. * Set the value of an uniform to a matrix
  29193. * @param uniform defines the webGL uniform location where to store the value
  29194. * @param matrix defines the matrix to store
  29195. */
  29196. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29197. /**
  29198. * Set the value of an uniform to a matrix (3x3)
  29199. * @param uniform defines the webGL uniform location where to store the value
  29200. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29201. */
  29202. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29203. /**
  29204. * Set the value of an uniform to a matrix (2x2)
  29205. * @param uniform defines the webGL uniform location where to store the value
  29206. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29207. */
  29208. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29209. /**
  29210. * Set the value of an uniform to a number (int)
  29211. * @param uniform defines the webGL uniform location where to store the value
  29212. * @param value defines the int number to store
  29213. */
  29214. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29215. /**
  29216. * Set the value of an uniform to a number (float)
  29217. * @param uniform defines the webGL uniform location where to store the value
  29218. * @param value defines the float number to store
  29219. */
  29220. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29221. /**
  29222. * Set the value of an uniform to a vec2
  29223. * @param uniform defines the webGL uniform location where to store the value
  29224. * @param x defines the 1st component of the value
  29225. * @param y defines the 2nd component of the value
  29226. */
  29227. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29228. /**
  29229. * Set the value of an uniform to a vec3
  29230. * @param uniform defines the webGL uniform location where to store the value
  29231. * @param x defines the 1st component of the value
  29232. * @param y defines the 2nd component of the value
  29233. * @param z defines the 3rd component of the value
  29234. */
  29235. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29236. /**
  29237. * Set the value of an uniform to a boolean
  29238. * @param uniform defines the webGL uniform location where to store the value
  29239. * @param bool defines the boolean to store
  29240. */
  29241. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29242. /**
  29243. * Set the value of an uniform to a vec4
  29244. * @param uniform defines the webGL uniform location where to store the value
  29245. * @param x defines the 1st component of the value
  29246. * @param y defines the 2nd component of the value
  29247. * @param z defines the 3rd component of the value
  29248. * @param w defines the 4th component of the value
  29249. */
  29250. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29251. /**
  29252. * Set the value of an uniform to a Color3
  29253. * @param uniform defines the webGL uniform location where to store the value
  29254. * @param color3 defines the color to store
  29255. */
  29256. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29257. /**
  29258. * Set the value of an uniform to a Color3 and an alpha value
  29259. * @param uniform defines the webGL uniform location where to store the value
  29260. * @param color3 defines the color to store
  29261. * @param alpha defines the alpha component to store
  29262. */
  29263. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29264. /**
  29265. * Sets a Color4 on a uniform variable
  29266. * @param uniform defines the uniform location
  29267. * @param color4 defines the value to be set
  29268. */
  29269. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29270. /**
  29271. * Set various states to the webGL context
  29272. * @param culling defines backface culling state
  29273. * @param zOffset defines the value to apply to zOffset (0 by default)
  29274. * @param force defines if states must be applied even if cache is up to date
  29275. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29276. */
  29277. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29278. /**
  29279. * Set the z offset to apply to current rendering
  29280. * @param value defines the offset to apply
  29281. */
  29282. setZOffset(value: number): void;
  29283. /**
  29284. * Gets the current value of the zOffset
  29285. * @returns the current zOffset state
  29286. */
  29287. getZOffset(): number;
  29288. /**
  29289. * Enable or disable depth buffering
  29290. * @param enable defines the state to set
  29291. */
  29292. setDepthBuffer(enable: boolean): void;
  29293. /**
  29294. * Gets a boolean indicating if depth writing is enabled
  29295. * @returns the current depth writing state
  29296. */
  29297. getDepthWrite(): boolean;
  29298. /**
  29299. * Enable or disable depth writing
  29300. * @param enable defines the state to set
  29301. */
  29302. setDepthWrite(enable: boolean): void;
  29303. /**
  29304. * Enable or disable color writing
  29305. * @param enable defines the state to set
  29306. */
  29307. setColorWrite(enable: boolean): void;
  29308. /**
  29309. * Gets a boolean indicating if color writing is enabled
  29310. * @returns the current color writing state
  29311. */
  29312. getColorWrite(): boolean;
  29313. /**
  29314. * Sets alpha constants used by some alpha blending modes
  29315. * @param r defines the red component
  29316. * @param g defines the green component
  29317. * @param b defines the blue component
  29318. * @param a defines the alpha component
  29319. */
  29320. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29321. /**
  29322. * Sets the current alpha mode
  29323. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29324. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29325. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29326. */
  29327. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29328. /**
  29329. * Gets the current alpha mode
  29330. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29331. * @returns the current alpha mode
  29332. */
  29333. getAlphaMode(): number;
  29334. /**
  29335. * Clears the list of texture accessible through engine.
  29336. * This can help preventing texture load conflict due to name collision.
  29337. */
  29338. clearInternalTexturesCache(): void;
  29339. /**
  29340. * Force the entire cache to be cleared
  29341. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29342. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29343. */
  29344. wipeCaches(bruteForce?: boolean): void;
  29345. /**
  29346. * Set the compressed texture format to use, based on the formats you have, and the formats
  29347. * supported by the hardware / browser.
  29348. *
  29349. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29350. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29351. * to API arguments needed to compressed textures. This puts the burden on the container
  29352. * generator to house the arcane code for determining these for current & future formats.
  29353. *
  29354. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29355. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29356. *
  29357. * Note: The result of this call is not taken into account when a texture is base64.
  29358. *
  29359. * @param formatsAvailable defines the list of those format families you have created
  29360. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29361. *
  29362. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29363. * @returns The extension selected.
  29364. */
  29365. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29366. /** @hidden */
  29367. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29368. min: number;
  29369. mag: number;
  29370. };
  29371. /** @hidden */
  29372. _createTexture(): WebGLTexture;
  29373. /**
  29374. * Usually called from Texture.ts.
  29375. * Passed information to create a WebGLTexture
  29376. * @param urlArg defines a value which contains one of the following:
  29377. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29378. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29379. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29380. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29381. * @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)
  29382. * @param scene needed for loading to the correct scene
  29383. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29384. * @param onLoad optional callback to be called upon successful completion
  29385. * @param onError optional callback to be called upon failure
  29386. * @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
  29387. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29388. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29389. * @param forcedExtension defines the extension to use to pick the right loader
  29390. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29391. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29392. */
  29393. 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;
  29394. private _rescaleTexture;
  29395. private _unpackFlipYCached;
  29396. /**
  29397. * In case you are sharing the context with other applications, it might
  29398. * be interested to not cache the unpack flip y state to ensure a consistent
  29399. * value would be set.
  29400. */
  29401. enableUnpackFlipYCached: boolean;
  29402. /** @hidden */
  29403. _unpackFlipY(value: boolean): void;
  29404. /** @hidden */
  29405. _getUnpackAlignement(): number;
  29406. /**
  29407. * Creates a dynamic texture
  29408. * @param width defines the width of the texture
  29409. * @param height defines the height of the texture
  29410. * @param generateMipMaps defines if the engine should generate the mip levels
  29411. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29412. * @returns the dynamic texture inside an InternalTexture
  29413. */
  29414. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29415. /**
  29416. * Update the sampling mode of a given texture
  29417. * @param samplingMode defines the required sampling mode
  29418. * @param texture defines the texture to update
  29419. */
  29420. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29421. /**
  29422. * Update the content of a dynamic texture
  29423. * @param texture defines the texture to update
  29424. * @param canvas defines the canvas containing the source
  29425. * @param invertY defines if data must be stored with Y axis inverted
  29426. * @param premulAlpha defines if alpha is stored as premultiplied
  29427. * @param format defines the format of the data
  29428. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29429. */
  29430. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29431. /**
  29432. * Update a video texture
  29433. * @param texture defines the texture to update
  29434. * @param video defines the video element to use
  29435. * @param invertY defines if data must be stored with Y axis inverted
  29436. */
  29437. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29438. /**
  29439. * Updates a depth texture Comparison Mode and Function.
  29440. * If the comparison Function is equal to 0, the mode will be set to none.
  29441. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29442. * @param texture The texture to set the comparison function for
  29443. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29444. */
  29445. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29446. /** @hidden */
  29447. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29448. width: number;
  29449. height: number;
  29450. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29451. /**
  29452. * Creates a depth stencil texture.
  29453. * This is only available in WebGL 2 or with the depth texture extension available.
  29454. * @param size The size of face edge in the texture.
  29455. * @param options The options defining the texture.
  29456. * @returns The texture
  29457. */
  29458. createDepthStencilTexture(size: number | {
  29459. width: number;
  29460. height: number;
  29461. }, options: DepthTextureCreationOptions): InternalTexture;
  29462. /**
  29463. * Creates a depth stencil texture.
  29464. * This is only available in WebGL 2 or with the depth texture extension available.
  29465. * @param size The size of face edge in the texture.
  29466. * @param options The options defining the texture.
  29467. * @returns The texture
  29468. */
  29469. private _createDepthStencilTexture;
  29470. /**
  29471. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29472. * @param renderTarget The render target to set the frame buffer for
  29473. */
  29474. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29475. /**
  29476. * Creates a new render target texture
  29477. * @param size defines the size of the texture
  29478. * @param options defines the options used to create the texture
  29479. * @returns a new render target texture stored in an InternalTexture
  29480. */
  29481. createRenderTargetTexture(size: number | {
  29482. width: number;
  29483. height: number;
  29484. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29485. /** @hidden */
  29486. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29487. /**
  29488. * Updates the sample count of a render target texture
  29489. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29490. * @param texture defines the texture to update
  29491. * @param samples defines the sample count to set
  29492. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29493. */
  29494. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29495. /** @hidden */
  29496. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29497. /** @hidden */
  29498. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29499. /** @hidden */
  29500. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29501. /** @hidden */
  29502. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29503. /**
  29504. * @hidden
  29505. */
  29506. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29507. private _prepareWebGLTextureContinuation;
  29508. private _prepareWebGLTexture;
  29509. /** @hidden */
  29510. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29511. /** @hidden */
  29512. _releaseFramebufferObjects(texture: InternalTexture): void;
  29513. /** @hidden */
  29514. _releaseTexture(texture: InternalTexture): void;
  29515. private setProgram;
  29516. private _boundUniforms;
  29517. /**
  29518. * Binds an effect to the webGL context
  29519. * @param effect defines the effect to bind
  29520. */
  29521. bindSamplers(effect: Effect): void;
  29522. private _activateCurrentTexture;
  29523. /** @hidden */
  29524. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29525. /** @hidden */
  29526. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29527. /**
  29528. * Sets a texture to the webGL context from a postprocess
  29529. * @param channel defines the channel to use
  29530. * @param postProcess defines the source postprocess
  29531. */
  29532. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29533. /**
  29534. * Binds the output of the passed in post process to the texture channel specified
  29535. * @param channel The channel the texture should be bound to
  29536. * @param postProcess The post process which's output should be bound
  29537. */
  29538. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29539. /**
  29540. * Unbind all textures from the webGL context
  29541. */
  29542. unbindAllTextures(): void;
  29543. /**
  29544. * Sets a texture to the according uniform.
  29545. * @param channel The texture channel
  29546. * @param uniform The uniform to set
  29547. * @param texture The texture to apply
  29548. */
  29549. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29550. /**
  29551. * Sets a depth stencil texture from a render target to the according uniform.
  29552. * @param channel The texture channel
  29553. * @param uniform The uniform to set
  29554. * @param texture The render target texture containing the depth stencil texture to apply
  29555. */
  29556. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29557. private _bindSamplerUniformToChannel;
  29558. private _getTextureWrapMode;
  29559. private _setTexture;
  29560. /**
  29561. * Sets an array of texture to the webGL context
  29562. * @param channel defines the channel where the texture array must be set
  29563. * @param uniform defines the associated uniform location
  29564. * @param textures defines the array of textures to bind
  29565. */
  29566. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29567. /** @hidden */
  29568. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29569. private _setTextureParameterFloat;
  29570. private _setTextureParameterInteger;
  29571. /**
  29572. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29573. * @param x defines the x coordinate of the rectangle where pixels must be read
  29574. * @param y defines the y coordinate of the rectangle where pixels must be read
  29575. * @param width defines the width of the rectangle where pixels must be read
  29576. * @param height defines the height of the rectangle where pixels must be read
  29577. * @returns a Uint8Array containing RGBA colors
  29578. */
  29579. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29580. /**
  29581. * Add an externaly attached data from its key.
  29582. * This method call will fail and return false, if such key already exists.
  29583. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29584. * @param key the unique key that identifies the data
  29585. * @param data the data object to associate to the key for this Engine instance
  29586. * @return true if no such key were already present and the data was added successfully, false otherwise
  29587. */
  29588. addExternalData<T>(key: string, data: T): boolean;
  29589. /**
  29590. * Get an externaly attached data from its key
  29591. * @param key the unique key that identifies the data
  29592. * @return the associated data, if present (can be null), or undefined if not present
  29593. */
  29594. getExternalData<T>(key: string): T;
  29595. /**
  29596. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29597. * @param key the unique key that identifies the data
  29598. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29599. * @return the associated data, can be null if the factory returned null.
  29600. */
  29601. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29602. /**
  29603. * Remove an externaly attached data from the Engine instance
  29604. * @param key the unique key that identifies the data
  29605. * @return true if the data was successfully removed, false if it doesn't exist
  29606. */
  29607. removeExternalData(key: string): boolean;
  29608. /**
  29609. * Unbind all vertex attributes from the webGL context
  29610. */
  29611. unbindAllAttributes(): void;
  29612. /**
  29613. * 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
  29614. */
  29615. releaseEffects(): void;
  29616. /**
  29617. * Dispose and release all associated resources
  29618. */
  29619. dispose(): void;
  29620. /**
  29621. * Display the loading screen
  29622. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29623. */
  29624. displayLoadingUI(): void;
  29625. /**
  29626. * Hide the loading screen
  29627. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29628. */
  29629. hideLoadingUI(): void;
  29630. /**
  29631. * Gets the current loading screen object
  29632. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29633. */
  29634. /**
  29635. * Sets the current loading screen object
  29636. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29637. */
  29638. loadingScreen: ILoadingScreen;
  29639. /**
  29640. * Sets the current loading screen text
  29641. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29642. */
  29643. loadingUIText: string;
  29644. /**
  29645. * Sets the current loading screen background color
  29646. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29647. */
  29648. loadingUIBackgroundColor: string;
  29649. /**
  29650. * Attach a new callback raised when context lost event is fired
  29651. * @param callback defines the callback to call
  29652. */
  29653. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29654. /**
  29655. * Attach a new callback raised when context restored event is fired
  29656. * @param callback defines the callback to call
  29657. */
  29658. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29659. /**
  29660. * Gets the source code of the vertex shader associated with a specific webGL program
  29661. * @param program defines the program to use
  29662. * @returns a string containing the source code of the vertex shader associated with the program
  29663. */
  29664. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29665. /**
  29666. * Gets the source code of the fragment shader associated with a specific webGL program
  29667. * @param program defines the program to use
  29668. * @returns a string containing the source code of the fragment shader associated with the program
  29669. */
  29670. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29671. /**
  29672. * Get the current error code of the webGL context
  29673. * @returns the error code
  29674. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29675. */
  29676. getError(): number;
  29677. /**
  29678. * Gets the current framerate
  29679. * @returns a number representing the framerate
  29680. */
  29681. getFps(): number;
  29682. /**
  29683. * Gets the time spent between current and previous frame
  29684. * @returns a number representing the delta time in ms
  29685. */
  29686. getDeltaTime(): number;
  29687. private _measureFps;
  29688. /** @hidden */
  29689. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29690. private _canRenderToFloatFramebuffer;
  29691. private _canRenderToHalfFloatFramebuffer;
  29692. private _canRenderToFramebuffer;
  29693. /** @hidden */
  29694. _getWebGLTextureType(type: number): number;
  29695. /** @hidden */
  29696. _getInternalFormat(format: number): number;
  29697. /** @hidden */
  29698. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29699. /** @hidden */
  29700. _getRGBAMultiSampleBufferFormat(type: number): number;
  29701. /** @hidden */
  29702. _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;
  29703. /** @hidden */
  29704. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29705. /**
  29706. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29707. * @returns true if the engine can be created
  29708. * @ignorenaming
  29709. */
  29710. static isSupported(): boolean;
  29711. }
  29712. }
  29713. declare module "babylonjs/Materials/effect" {
  29714. import { Observable } from "babylonjs/Misc/observable";
  29715. import { Nullable } from "babylonjs/types";
  29716. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29717. import { IDisposable } from "babylonjs/scene";
  29718. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29719. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29720. import { Engine } from "babylonjs/Engines/engine";
  29721. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29723. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29724. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29726. /**
  29727. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29728. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29729. */
  29730. export class EffectFallbacks {
  29731. private _defines;
  29732. private _currentRank;
  29733. private _maxRank;
  29734. private _mesh;
  29735. /**
  29736. * Removes the fallback from the bound mesh.
  29737. */
  29738. unBindMesh(): void;
  29739. /**
  29740. * Adds a fallback on the specified property.
  29741. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29742. * @param define The name of the define in the shader
  29743. */
  29744. addFallback(rank: number, define: string): void;
  29745. /**
  29746. * Sets the mesh to use CPU skinning when needing to fallback.
  29747. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29748. * @param mesh The mesh to use the fallbacks.
  29749. */
  29750. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29751. /**
  29752. * Checks to see if more fallbacks are still availible.
  29753. */
  29754. readonly isMoreFallbacks: boolean;
  29755. /**
  29756. * Removes the defines that shoould be removed when falling back.
  29757. * @param currentDefines defines the current define statements for the shader.
  29758. * @param effect defines the current effect we try to compile
  29759. * @returns The resulting defines with defines of the current rank removed.
  29760. */
  29761. reduce(currentDefines: string, effect: Effect): string;
  29762. }
  29763. /**
  29764. * Options to be used when creating an effect.
  29765. */
  29766. export class EffectCreationOptions {
  29767. /**
  29768. * Atrributes that will be used in the shader.
  29769. */
  29770. attributes: string[];
  29771. /**
  29772. * Uniform varible names that will be set in the shader.
  29773. */
  29774. uniformsNames: string[];
  29775. /**
  29776. * Uniform buffer varible names that will be set in the shader.
  29777. */
  29778. uniformBuffersNames: string[];
  29779. /**
  29780. * Sampler texture variable names that will be set in the shader.
  29781. */
  29782. samplers: string[];
  29783. /**
  29784. * Define statements that will be set in the shader.
  29785. */
  29786. defines: any;
  29787. /**
  29788. * Possible fallbacks for this effect to improve performance when needed.
  29789. */
  29790. fallbacks: Nullable<EffectFallbacks>;
  29791. /**
  29792. * Callback that will be called when the shader is compiled.
  29793. */
  29794. onCompiled: Nullable<(effect: Effect) => void>;
  29795. /**
  29796. * Callback that will be called if an error occurs during shader compilation.
  29797. */
  29798. onError: Nullable<(effect: Effect, errors: string) => void>;
  29799. /**
  29800. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29801. */
  29802. indexParameters: any;
  29803. /**
  29804. * Max number of lights that can be used in the shader.
  29805. */
  29806. maxSimultaneousLights: number;
  29807. /**
  29808. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29809. */
  29810. transformFeedbackVaryings: Nullable<string[]>;
  29811. }
  29812. /**
  29813. * Effect containing vertex and fragment shader that can be executed on an object.
  29814. */
  29815. export class Effect implements IDisposable {
  29816. /**
  29817. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29818. */
  29819. static ShadersRepository: string;
  29820. /**
  29821. * Name of the effect.
  29822. */
  29823. name: any;
  29824. /**
  29825. * String container all the define statements that should be set on the shader.
  29826. */
  29827. defines: string;
  29828. /**
  29829. * Callback that will be called when the shader is compiled.
  29830. */
  29831. onCompiled: Nullable<(effect: Effect) => void>;
  29832. /**
  29833. * Callback that will be called if an error occurs during shader compilation.
  29834. */
  29835. onError: Nullable<(effect: Effect, errors: string) => void>;
  29836. /**
  29837. * Callback that will be called when effect is bound.
  29838. */
  29839. onBind: Nullable<(effect: Effect) => void>;
  29840. /**
  29841. * Unique ID of the effect.
  29842. */
  29843. uniqueId: number;
  29844. /**
  29845. * Observable that will be called when the shader is compiled.
  29846. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29847. */
  29848. onCompileObservable: Observable<Effect>;
  29849. /**
  29850. * Observable that will be called if an error occurs during shader compilation.
  29851. */
  29852. onErrorObservable: Observable<Effect>;
  29853. /** @hidden */
  29854. _onBindObservable: Nullable<Observable<Effect>>;
  29855. /**
  29856. * Observable that will be called when effect is bound.
  29857. */
  29858. readonly onBindObservable: Observable<Effect>;
  29859. /** @hidden */
  29860. _bonesComputationForcedToCPU: boolean;
  29861. private static _uniqueIdSeed;
  29862. private _engine;
  29863. private _uniformBuffersNames;
  29864. private _uniformsNames;
  29865. private _samplerList;
  29866. private _samplers;
  29867. private _isReady;
  29868. private _compilationError;
  29869. private _attributesNames;
  29870. private _attributes;
  29871. private _uniforms;
  29872. /**
  29873. * Key for the effect.
  29874. * @hidden
  29875. */
  29876. _key: string;
  29877. private _indexParameters;
  29878. private _fallbacks;
  29879. private _vertexSourceCode;
  29880. private _fragmentSourceCode;
  29881. private _vertexSourceCodeOverride;
  29882. private _fragmentSourceCodeOverride;
  29883. private _transformFeedbackVaryings;
  29884. /**
  29885. * Compiled shader to webGL program.
  29886. * @hidden
  29887. */
  29888. _pipelineContext: IPipelineContext;
  29889. private _valueCache;
  29890. private static _baseCache;
  29891. /**
  29892. * Instantiates an effect.
  29893. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29894. * @param baseName Name of the effect.
  29895. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29896. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29897. * @param samplers List of sampler variables that will be passed to the shader.
  29898. * @param engine Engine to be used to render the effect
  29899. * @param defines Define statements to be added to the shader.
  29900. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29901. * @param onCompiled Callback that will be called when the shader is compiled.
  29902. * @param onError Callback that will be called if an error occurs during shader compilation.
  29903. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29904. */
  29905. 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);
  29906. /**
  29907. * Unique key for this effect
  29908. */
  29909. readonly key: string;
  29910. /**
  29911. * If the effect has been compiled and prepared.
  29912. * @returns if the effect is compiled and prepared.
  29913. */
  29914. isReady(): boolean;
  29915. /**
  29916. * The engine the effect was initialized with.
  29917. * @returns the engine.
  29918. */
  29919. getEngine(): Engine;
  29920. /**
  29921. * The pipeline context for this effect
  29922. * @returns the associated pipeline context
  29923. */
  29924. getPipelineContext(): IPipelineContext;
  29925. /**
  29926. * The set of names of attribute variables for the shader.
  29927. * @returns An array of attribute names.
  29928. */
  29929. getAttributesNames(): string[];
  29930. /**
  29931. * Returns the attribute at the given index.
  29932. * @param index The index of the attribute.
  29933. * @returns The location of the attribute.
  29934. */
  29935. getAttributeLocation(index: number): number;
  29936. /**
  29937. * Returns the attribute based on the name of the variable.
  29938. * @param name of the attribute to look up.
  29939. * @returns the attribute location.
  29940. */
  29941. getAttributeLocationByName(name: string): number;
  29942. /**
  29943. * The number of attributes.
  29944. * @returns the numnber of attributes.
  29945. */
  29946. getAttributesCount(): number;
  29947. /**
  29948. * Gets the index of a uniform variable.
  29949. * @param uniformName of the uniform to look up.
  29950. * @returns the index.
  29951. */
  29952. getUniformIndex(uniformName: string): number;
  29953. /**
  29954. * Returns the attribute based on the name of the variable.
  29955. * @param uniformName of the uniform to look up.
  29956. * @returns the location of the uniform.
  29957. */
  29958. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29959. /**
  29960. * Returns an array of sampler variable names
  29961. * @returns The array of sampler variable neames.
  29962. */
  29963. getSamplers(): string[];
  29964. /**
  29965. * The error from the last compilation.
  29966. * @returns the error string.
  29967. */
  29968. getCompilationError(): string;
  29969. /**
  29970. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29971. * @param func The callback to be used.
  29972. */
  29973. executeWhenCompiled(func: (effect: Effect) => void): void;
  29974. private _checkIsReady;
  29975. /** @hidden */
  29976. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29977. /** @hidden */
  29978. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29979. /** @hidden */
  29980. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29981. private _processShaderConversion;
  29982. private _processIncludes;
  29983. private _processPrecision;
  29984. /**
  29985. * Recompiles the webGL program
  29986. * @param vertexSourceCode The source code for the vertex shader.
  29987. * @param fragmentSourceCode The source code for the fragment shader.
  29988. * @param onCompiled Callback called when completed.
  29989. * @param onError Callback called on error.
  29990. * @hidden
  29991. */
  29992. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29993. /**
  29994. * Prepares the effect
  29995. * @hidden
  29996. */
  29997. _prepareEffect(): void;
  29998. /**
  29999. * Checks if the effect is supported. (Must be called after compilation)
  30000. */
  30001. readonly isSupported: boolean;
  30002. /**
  30003. * Binds a texture to the engine to be used as output of the shader.
  30004. * @param channel Name of the output variable.
  30005. * @param texture Texture to bind.
  30006. * @hidden
  30007. */
  30008. _bindTexture(channel: string, texture: InternalTexture): void;
  30009. /**
  30010. * Sets a texture on the engine to be used in the shader.
  30011. * @param channel Name of the sampler variable.
  30012. * @param texture Texture to set.
  30013. */
  30014. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30015. /**
  30016. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30017. * @param channel Name of the sampler variable.
  30018. * @param texture Texture to set.
  30019. */
  30020. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30021. /**
  30022. * Sets an array of textures on the engine to be used in the shader.
  30023. * @param channel Name of the variable.
  30024. * @param textures Textures to set.
  30025. */
  30026. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30027. /**
  30028. * 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)
  30029. * @param channel Name of the sampler variable.
  30030. * @param postProcess Post process to get the input texture from.
  30031. */
  30032. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30033. /**
  30034. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30035. * 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)
  30036. * @param channel Name of the sampler variable.
  30037. * @param postProcess Post process to get the output texture from.
  30038. */
  30039. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30040. /** @hidden */
  30041. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30042. /** @hidden */
  30043. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30044. /** @hidden */
  30045. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30046. /** @hidden */
  30047. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30048. /**
  30049. * Binds a buffer to a uniform.
  30050. * @param buffer Buffer to bind.
  30051. * @param name Name of the uniform variable to bind to.
  30052. */
  30053. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30054. /**
  30055. * Binds block to a uniform.
  30056. * @param blockName Name of the block to bind.
  30057. * @param index Index to bind.
  30058. */
  30059. bindUniformBlock(blockName: string, index: number): void;
  30060. /**
  30061. * Sets an interger value on a uniform variable.
  30062. * @param uniformName Name of the variable.
  30063. * @param value Value to be set.
  30064. * @returns this effect.
  30065. */
  30066. setInt(uniformName: string, value: number): Effect;
  30067. /**
  30068. * Sets an int array on a uniform variable.
  30069. * @param uniformName Name of the variable.
  30070. * @param array array to be set.
  30071. * @returns this effect.
  30072. */
  30073. setIntArray(uniformName: string, array: Int32Array): Effect;
  30074. /**
  30075. * 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)
  30076. * @param uniformName Name of the variable.
  30077. * @param array array to be set.
  30078. * @returns this effect.
  30079. */
  30080. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30081. /**
  30082. * 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)
  30083. * @param uniformName Name of the variable.
  30084. * @param array array to be set.
  30085. * @returns this effect.
  30086. */
  30087. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30088. /**
  30089. * 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)
  30090. * @param uniformName Name of the variable.
  30091. * @param array array to be set.
  30092. * @returns this effect.
  30093. */
  30094. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30095. /**
  30096. * Sets an float array on a uniform variable.
  30097. * @param uniformName Name of the variable.
  30098. * @param array array to be set.
  30099. * @returns this effect.
  30100. */
  30101. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30102. /**
  30103. * 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)
  30104. * @param uniformName Name of the variable.
  30105. * @param array array to be set.
  30106. * @returns this effect.
  30107. */
  30108. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30109. /**
  30110. * 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)
  30111. * @param uniformName Name of the variable.
  30112. * @param array array to be set.
  30113. * @returns this effect.
  30114. */
  30115. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30116. /**
  30117. * 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)
  30118. * @param uniformName Name of the variable.
  30119. * @param array array to be set.
  30120. * @returns this effect.
  30121. */
  30122. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30123. /**
  30124. * Sets an array on a uniform variable.
  30125. * @param uniformName Name of the variable.
  30126. * @param array array to be set.
  30127. * @returns this effect.
  30128. */
  30129. setArray(uniformName: string, array: number[]): Effect;
  30130. /**
  30131. * 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)
  30132. * @param uniformName Name of the variable.
  30133. * @param array array to be set.
  30134. * @returns this effect.
  30135. */
  30136. setArray2(uniformName: string, array: number[]): Effect;
  30137. /**
  30138. * 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)
  30139. * @param uniformName Name of the variable.
  30140. * @param array array to be set.
  30141. * @returns this effect.
  30142. */
  30143. setArray3(uniformName: string, array: number[]): Effect;
  30144. /**
  30145. * 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)
  30146. * @param uniformName Name of the variable.
  30147. * @param array array to be set.
  30148. * @returns this effect.
  30149. */
  30150. setArray4(uniformName: string, array: number[]): Effect;
  30151. /**
  30152. * Sets matrices on a uniform variable.
  30153. * @param uniformName Name of the variable.
  30154. * @param matrices matrices to be set.
  30155. * @returns this effect.
  30156. */
  30157. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30158. /**
  30159. * Sets matrix on a uniform variable.
  30160. * @param uniformName Name of the variable.
  30161. * @param matrix matrix to be set.
  30162. * @returns this effect.
  30163. */
  30164. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30165. /**
  30166. * 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)
  30167. * @param uniformName Name of the variable.
  30168. * @param matrix matrix to be set.
  30169. * @returns this effect.
  30170. */
  30171. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30172. /**
  30173. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30174. * @param uniformName Name of the variable.
  30175. * @param matrix matrix to be set.
  30176. * @returns this effect.
  30177. */
  30178. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30179. /**
  30180. * Sets a float on a uniform variable.
  30181. * @param uniformName Name of the variable.
  30182. * @param value value to be set.
  30183. * @returns this effect.
  30184. */
  30185. setFloat(uniformName: string, value: number): Effect;
  30186. /**
  30187. * Sets a boolean on a uniform variable.
  30188. * @param uniformName Name of the variable.
  30189. * @param bool value to be set.
  30190. * @returns this effect.
  30191. */
  30192. setBool(uniformName: string, bool: boolean): Effect;
  30193. /**
  30194. * Sets a Vector2 on a uniform variable.
  30195. * @param uniformName Name of the variable.
  30196. * @param vector2 vector2 to be set.
  30197. * @returns this effect.
  30198. */
  30199. setVector2(uniformName: string, vector2: Vector2): Effect;
  30200. /**
  30201. * Sets a float2 on a uniform variable.
  30202. * @param uniformName Name of the variable.
  30203. * @param x First float in float2.
  30204. * @param y Second float in float2.
  30205. * @returns this effect.
  30206. */
  30207. setFloat2(uniformName: string, x: number, y: number): Effect;
  30208. /**
  30209. * Sets a Vector3 on a uniform variable.
  30210. * @param uniformName Name of the variable.
  30211. * @param vector3 Value to be set.
  30212. * @returns this effect.
  30213. */
  30214. setVector3(uniformName: string, vector3: Vector3): Effect;
  30215. /**
  30216. * Sets a float3 on a uniform variable.
  30217. * @param uniformName Name of the variable.
  30218. * @param x First float in float3.
  30219. * @param y Second float in float3.
  30220. * @param z Third float in float3.
  30221. * @returns this effect.
  30222. */
  30223. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30224. /**
  30225. * Sets a Vector4 on a uniform variable.
  30226. * @param uniformName Name of the variable.
  30227. * @param vector4 Value to be set.
  30228. * @returns this effect.
  30229. */
  30230. setVector4(uniformName: string, vector4: Vector4): Effect;
  30231. /**
  30232. * Sets a float4 on a uniform variable.
  30233. * @param uniformName Name of the variable.
  30234. * @param x First float in float4.
  30235. * @param y Second float in float4.
  30236. * @param z Third float in float4.
  30237. * @param w Fourth float in float4.
  30238. * @returns this effect.
  30239. */
  30240. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30241. /**
  30242. * Sets a Color3 on a uniform variable.
  30243. * @param uniformName Name of the variable.
  30244. * @param color3 Value to be set.
  30245. * @returns this effect.
  30246. */
  30247. setColor3(uniformName: string, color3: Color3): Effect;
  30248. /**
  30249. * Sets a Color4 on a uniform variable.
  30250. * @param uniformName Name of the variable.
  30251. * @param color3 Value to be set.
  30252. * @param alpha Alpha value to be set.
  30253. * @returns this effect.
  30254. */
  30255. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30256. /**
  30257. * Sets a Color4 on a uniform variable
  30258. * @param uniformName defines the name of the variable
  30259. * @param color4 defines the value to be set
  30260. * @returns this effect.
  30261. */
  30262. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30263. /** Release all associated resources */
  30264. dispose(): void;
  30265. /**
  30266. * This function will add a new shader to the shader store
  30267. * @param name the name of the shader
  30268. * @param pixelShader optional pixel shader content
  30269. * @param vertexShader optional vertex shader content
  30270. */
  30271. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30272. /**
  30273. * Store of each shader (The can be looked up using effect.key)
  30274. */
  30275. static ShadersStore: {
  30276. [key: string]: string;
  30277. };
  30278. /**
  30279. * Store of each included file for a shader (The can be looked up using effect.key)
  30280. */
  30281. static IncludesShadersStore: {
  30282. [key: string]: string;
  30283. };
  30284. /**
  30285. * Resets the cache of effects.
  30286. */
  30287. static ResetCache(): void;
  30288. }
  30289. }
  30290. declare module "babylonjs/Materials/colorCurves" {
  30291. import { Effect } from "babylonjs/Materials/effect";
  30292. /**
  30293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30295. * 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;
  30296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30297. */
  30298. export class ColorCurves {
  30299. private _dirty;
  30300. private _tempColor;
  30301. private _globalCurve;
  30302. private _highlightsCurve;
  30303. private _midtonesCurve;
  30304. private _shadowsCurve;
  30305. private _positiveCurve;
  30306. private _negativeCurve;
  30307. private _globalHue;
  30308. private _globalDensity;
  30309. private _globalSaturation;
  30310. private _globalExposure;
  30311. /**
  30312. * Gets the global Hue value.
  30313. * 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).
  30314. */
  30315. /**
  30316. * Sets the global Hue value.
  30317. * 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).
  30318. */
  30319. globalHue: number;
  30320. /**
  30321. * Gets the global Density value.
  30322. * 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.
  30323. * Values less than zero provide a filter of opposite hue.
  30324. */
  30325. /**
  30326. * Sets the global Density value.
  30327. * 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.
  30328. * Values less than zero provide a filter of opposite hue.
  30329. */
  30330. globalDensity: number;
  30331. /**
  30332. * Gets the global Saturation value.
  30333. * 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.
  30334. */
  30335. /**
  30336. * Sets the global Saturation value.
  30337. * 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.
  30338. */
  30339. globalSaturation: number;
  30340. /**
  30341. * Gets the global Exposure value.
  30342. * 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.
  30343. */
  30344. /**
  30345. * Sets the global Exposure value.
  30346. * 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.
  30347. */
  30348. globalExposure: number;
  30349. private _highlightsHue;
  30350. private _highlightsDensity;
  30351. private _highlightsSaturation;
  30352. private _highlightsExposure;
  30353. /**
  30354. * Gets the highlights Hue value.
  30355. * 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).
  30356. */
  30357. /**
  30358. * Sets the highlights Hue value.
  30359. * 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).
  30360. */
  30361. highlightsHue: number;
  30362. /**
  30363. * Gets the highlights Density value.
  30364. * 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.
  30365. * Values less than zero provide a filter of opposite hue.
  30366. */
  30367. /**
  30368. * Sets the highlights Density value.
  30369. * 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.
  30370. * Values less than zero provide a filter of opposite hue.
  30371. */
  30372. highlightsDensity: number;
  30373. /**
  30374. * Gets the highlights Saturation value.
  30375. * 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.
  30376. */
  30377. /**
  30378. * Sets the highlights Saturation value.
  30379. * 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.
  30380. */
  30381. highlightsSaturation: number;
  30382. /**
  30383. * Gets the highlights Exposure value.
  30384. * 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.
  30385. */
  30386. /**
  30387. * Sets the highlights Exposure value.
  30388. * 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.
  30389. */
  30390. highlightsExposure: number;
  30391. private _midtonesHue;
  30392. private _midtonesDensity;
  30393. private _midtonesSaturation;
  30394. private _midtonesExposure;
  30395. /**
  30396. * Gets the midtones Hue value.
  30397. * 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).
  30398. */
  30399. /**
  30400. * Sets the midtones Hue value.
  30401. * 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).
  30402. */
  30403. midtonesHue: number;
  30404. /**
  30405. * Gets the midtones Density value.
  30406. * 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.
  30407. * Values less than zero provide a filter of opposite hue.
  30408. */
  30409. /**
  30410. * Sets the midtones Density value.
  30411. * 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.
  30412. * Values less than zero provide a filter of opposite hue.
  30413. */
  30414. midtonesDensity: number;
  30415. /**
  30416. * Gets the midtones Saturation value.
  30417. * 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.
  30418. */
  30419. /**
  30420. * Sets the midtones Saturation value.
  30421. * 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.
  30422. */
  30423. midtonesSaturation: number;
  30424. /**
  30425. * Gets the midtones Exposure value.
  30426. * 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.
  30427. */
  30428. /**
  30429. * Sets the midtones Exposure value.
  30430. * 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.
  30431. */
  30432. midtonesExposure: number;
  30433. private _shadowsHue;
  30434. private _shadowsDensity;
  30435. private _shadowsSaturation;
  30436. private _shadowsExposure;
  30437. /**
  30438. * Gets the shadows Hue value.
  30439. * 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).
  30440. */
  30441. /**
  30442. * Sets the shadows Hue value.
  30443. * 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).
  30444. */
  30445. shadowsHue: number;
  30446. /**
  30447. * Gets the shadows Density value.
  30448. * 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.
  30449. * Values less than zero provide a filter of opposite hue.
  30450. */
  30451. /**
  30452. * Sets the shadows Density value.
  30453. * 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.
  30454. * Values less than zero provide a filter of opposite hue.
  30455. */
  30456. shadowsDensity: number;
  30457. /**
  30458. * Gets the shadows Saturation value.
  30459. * 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.
  30460. */
  30461. /**
  30462. * Sets the shadows Saturation value.
  30463. * 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.
  30464. */
  30465. shadowsSaturation: number;
  30466. /**
  30467. * Gets the shadows Exposure value.
  30468. * 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.
  30469. */
  30470. /**
  30471. * Sets the shadows Exposure value.
  30472. * 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.
  30473. */
  30474. shadowsExposure: number;
  30475. /**
  30476. * Returns the class name
  30477. * @returns The class name
  30478. */
  30479. getClassName(): string;
  30480. /**
  30481. * Binds the color curves to the shader.
  30482. * @param colorCurves The color curve to bind
  30483. * @param effect The effect to bind to
  30484. * @param positiveUniform The positive uniform shader parameter
  30485. * @param neutralUniform The neutral uniform shader parameter
  30486. * @param negativeUniform The negative uniform shader parameter
  30487. */
  30488. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30489. /**
  30490. * Prepare the list of uniforms associated with the ColorCurves effects.
  30491. * @param uniformsList The list of uniforms used in the effect
  30492. */
  30493. static PrepareUniforms(uniformsList: string[]): void;
  30494. /**
  30495. * Returns color grading data based on a hue, density, saturation and exposure value.
  30496. * @param filterHue The hue of the color filter.
  30497. * @param filterDensity The density of the color filter.
  30498. * @param saturation The saturation.
  30499. * @param exposure The exposure.
  30500. * @param result The result data container.
  30501. */
  30502. private getColorGradingDataToRef;
  30503. /**
  30504. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30505. * @param value The input slider value in range [-100,100].
  30506. * @returns Adjusted value.
  30507. */
  30508. private static applyColorGradingSliderNonlinear;
  30509. /**
  30510. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30511. * @param hue The hue (H) input.
  30512. * @param saturation The saturation (S) input.
  30513. * @param brightness The brightness (B) input.
  30514. * @result An RGBA color represented as Vector4.
  30515. */
  30516. private static fromHSBToRef;
  30517. /**
  30518. * Returns a value clamped between min and max
  30519. * @param value The value to clamp
  30520. * @param min The minimum of value
  30521. * @param max The maximum of value
  30522. * @returns The clamped value.
  30523. */
  30524. private static clamp;
  30525. /**
  30526. * Clones the current color curve instance.
  30527. * @return The cloned curves
  30528. */
  30529. clone(): ColorCurves;
  30530. /**
  30531. * Serializes the current color curve instance to a json representation.
  30532. * @return a JSON representation
  30533. */
  30534. serialize(): any;
  30535. /**
  30536. * Parses the color curve from a json representation.
  30537. * @param source the JSON source to parse
  30538. * @return The parsed curves
  30539. */
  30540. static Parse(source: any): ColorCurves;
  30541. }
  30542. }
  30543. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30544. import { Observable } from "babylonjs/Misc/observable";
  30545. import { Nullable } from "babylonjs/types";
  30546. import { Color4 } from "babylonjs/Maths/math";
  30547. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30548. import { Effect } from "babylonjs/Materials/effect";
  30549. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30550. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30551. /**
  30552. * Interface to follow in your material defines to integrate easily the
  30553. * Image proccessing functions.
  30554. * @hidden
  30555. */
  30556. export interface IImageProcessingConfigurationDefines {
  30557. IMAGEPROCESSING: boolean;
  30558. VIGNETTE: boolean;
  30559. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30560. VIGNETTEBLENDMODEOPAQUE: boolean;
  30561. TONEMAPPING: boolean;
  30562. TONEMAPPING_ACES: boolean;
  30563. CONTRAST: boolean;
  30564. EXPOSURE: boolean;
  30565. COLORCURVES: boolean;
  30566. COLORGRADING: boolean;
  30567. COLORGRADING3D: boolean;
  30568. SAMPLER3DGREENDEPTH: boolean;
  30569. SAMPLER3DBGRMAP: boolean;
  30570. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30571. }
  30572. /**
  30573. * @hidden
  30574. */
  30575. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30576. IMAGEPROCESSING: boolean;
  30577. VIGNETTE: boolean;
  30578. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30579. VIGNETTEBLENDMODEOPAQUE: boolean;
  30580. TONEMAPPING: boolean;
  30581. TONEMAPPING_ACES: boolean;
  30582. CONTRAST: boolean;
  30583. COLORCURVES: boolean;
  30584. COLORGRADING: boolean;
  30585. COLORGRADING3D: boolean;
  30586. SAMPLER3DGREENDEPTH: boolean;
  30587. SAMPLER3DBGRMAP: boolean;
  30588. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30589. EXPOSURE: boolean;
  30590. constructor();
  30591. }
  30592. /**
  30593. * This groups together the common properties used for image processing either in direct forward pass
  30594. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30595. * or not.
  30596. */
  30597. export class ImageProcessingConfiguration {
  30598. /**
  30599. * Default tone mapping applied in BabylonJS.
  30600. */
  30601. static readonly TONEMAPPING_STANDARD: number;
  30602. /**
  30603. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30604. * to other engines rendering to increase portability.
  30605. */
  30606. static readonly TONEMAPPING_ACES: number;
  30607. /**
  30608. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30609. */
  30610. colorCurves: Nullable<ColorCurves>;
  30611. private _colorCurvesEnabled;
  30612. /**
  30613. * Gets wether the color curves effect is enabled.
  30614. */
  30615. /**
  30616. * Sets wether the color curves effect is enabled.
  30617. */
  30618. colorCurvesEnabled: boolean;
  30619. private _colorGradingTexture;
  30620. /**
  30621. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30622. */
  30623. /**
  30624. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30625. */
  30626. colorGradingTexture: Nullable<BaseTexture>;
  30627. private _colorGradingEnabled;
  30628. /**
  30629. * Gets wether the color grading effect is enabled.
  30630. */
  30631. /**
  30632. * Sets wether the color grading effect is enabled.
  30633. */
  30634. colorGradingEnabled: boolean;
  30635. private _colorGradingWithGreenDepth;
  30636. /**
  30637. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30638. */
  30639. /**
  30640. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30641. */
  30642. colorGradingWithGreenDepth: boolean;
  30643. private _colorGradingBGR;
  30644. /**
  30645. * Gets wether the color grading texture contains BGR values.
  30646. */
  30647. /**
  30648. * Sets wether the color grading texture contains BGR values.
  30649. */
  30650. colorGradingBGR: boolean;
  30651. /** @hidden */
  30652. _exposure: number;
  30653. /**
  30654. * Gets the Exposure used in the effect.
  30655. */
  30656. /**
  30657. * Sets the Exposure used in the effect.
  30658. */
  30659. exposure: number;
  30660. private _toneMappingEnabled;
  30661. /**
  30662. * Gets wether the tone mapping effect is enabled.
  30663. */
  30664. /**
  30665. * Sets wether the tone mapping effect is enabled.
  30666. */
  30667. toneMappingEnabled: boolean;
  30668. private _toneMappingType;
  30669. /**
  30670. * Gets the type of tone mapping effect.
  30671. */
  30672. /**
  30673. * Sets the type of tone mapping effect used in BabylonJS.
  30674. */
  30675. toneMappingType: number;
  30676. protected _contrast: number;
  30677. /**
  30678. * Gets the contrast used in the effect.
  30679. */
  30680. /**
  30681. * Sets the contrast used in the effect.
  30682. */
  30683. contrast: number;
  30684. /**
  30685. * Vignette stretch size.
  30686. */
  30687. vignetteStretch: number;
  30688. /**
  30689. * Vignette centre X Offset.
  30690. */
  30691. vignetteCentreX: number;
  30692. /**
  30693. * Vignette centre Y Offset.
  30694. */
  30695. vignetteCentreY: number;
  30696. /**
  30697. * Vignette weight or intensity of the vignette effect.
  30698. */
  30699. vignetteWeight: number;
  30700. /**
  30701. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30702. * if vignetteEnabled is set to true.
  30703. */
  30704. vignetteColor: Color4;
  30705. /**
  30706. * Camera field of view used by the Vignette effect.
  30707. */
  30708. vignetteCameraFov: number;
  30709. private _vignetteBlendMode;
  30710. /**
  30711. * Gets the vignette blend mode allowing different kind of effect.
  30712. */
  30713. /**
  30714. * Sets the vignette blend mode allowing different kind of effect.
  30715. */
  30716. vignetteBlendMode: number;
  30717. private _vignetteEnabled;
  30718. /**
  30719. * Gets wether the vignette effect is enabled.
  30720. */
  30721. /**
  30722. * Sets wether the vignette effect is enabled.
  30723. */
  30724. vignetteEnabled: boolean;
  30725. private _applyByPostProcess;
  30726. /**
  30727. * Gets wether the image processing is applied through a post process or not.
  30728. */
  30729. /**
  30730. * Sets wether the image processing is applied through a post process or not.
  30731. */
  30732. applyByPostProcess: boolean;
  30733. private _isEnabled;
  30734. /**
  30735. * Gets wether the image processing is enabled or not.
  30736. */
  30737. /**
  30738. * Sets wether the image processing is enabled or not.
  30739. */
  30740. isEnabled: boolean;
  30741. /**
  30742. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30743. */
  30744. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30745. /**
  30746. * Method called each time the image processing information changes requires to recompile the effect.
  30747. */
  30748. protected _updateParameters(): void;
  30749. /**
  30750. * Gets the current class name.
  30751. * @return "ImageProcessingConfiguration"
  30752. */
  30753. getClassName(): string;
  30754. /**
  30755. * Prepare the list of uniforms associated with the Image Processing effects.
  30756. * @param uniforms The list of uniforms used in the effect
  30757. * @param defines the list of defines currently in use
  30758. */
  30759. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30760. /**
  30761. * Prepare the list of samplers associated with the Image Processing effects.
  30762. * @param samplersList The list of uniforms used in the effect
  30763. * @param defines the list of defines currently in use
  30764. */
  30765. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30766. /**
  30767. * Prepare the list of defines associated to the shader.
  30768. * @param defines the list of defines to complete
  30769. * @param forPostProcess Define if we are currently in post process mode or not
  30770. */
  30771. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30772. /**
  30773. * Returns true if all the image processing information are ready.
  30774. * @returns True if ready, otherwise, false
  30775. */
  30776. isReady(): boolean;
  30777. /**
  30778. * Binds the image processing to the shader.
  30779. * @param effect The effect to bind to
  30780. * @param aspectRatio Define the current aspect ratio of the effect
  30781. */
  30782. bind(effect: Effect, aspectRatio?: number): void;
  30783. /**
  30784. * Clones the current image processing instance.
  30785. * @return The cloned image processing
  30786. */
  30787. clone(): ImageProcessingConfiguration;
  30788. /**
  30789. * Serializes the current image processing instance to a json representation.
  30790. * @return a JSON representation
  30791. */
  30792. serialize(): any;
  30793. /**
  30794. * Parses the image processing from a json representation.
  30795. * @param source the JSON source to parse
  30796. * @return The parsed image processing
  30797. */
  30798. static Parse(source: any): ImageProcessingConfiguration;
  30799. private static _VIGNETTEMODE_MULTIPLY;
  30800. private static _VIGNETTEMODE_OPAQUE;
  30801. /**
  30802. * Used to apply the vignette as a mix with the pixel color.
  30803. */
  30804. static readonly VIGNETTEMODE_MULTIPLY: number;
  30805. /**
  30806. * Used to apply the vignette as a replacement of the pixel color.
  30807. */
  30808. static readonly VIGNETTEMODE_OPAQUE: number;
  30809. }
  30810. }
  30811. declare module "babylonjs/Materials/fresnelParameters" {
  30812. import { Color3 } from "babylonjs/Maths/math";
  30813. /**
  30814. * This represents all the required information to add a fresnel effect on a material:
  30815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30816. */
  30817. export class FresnelParameters {
  30818. private _isEnabled;
  30819. /**
  30820. * Define if the fresnel effect is enable or not.
  30821. */
  30822. isEnabled: boolean;
  30823. /**
  30824. * Define the color used on edges (grazing angle)
  30825. */
  30826. leftColor: Color3;
  30827. /**
  30828. * Define the color used on center
  30829. */
  30830. rightColor: Color3;
  30831. /**
  30832. * Define bias applied to computed fresnel term
  30833. */
  30834. bias: number;
  30835. /**
  30836. * Defined the power exponent applied to fresnel term
  30837. */
  30838. power: number;
  30839. /**
  30840. * Clones the current fresnel and its valuues
  30841. * @returns a clone fresnel configuration
  30842. */
  30843. clone(): FresnelParameters;
  30844. /**
  30845. * Serializes the current fresnel parameters to a JSON representation.
  30846. * @return the JSON serialization
  30847. */
  30848. serialize(): any;
  30849. /**
  30850. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30851. * @param parsedFresnelParameters Define the JSON representation
  30852. * @returns the parsed parameters
  30853. */
  30854. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30855. }
  30856. }
  30857. declare module "babylonjs/Misc/decorators" {
  30858. import { Nullable } from "babylonjs/types";
  30859. import { Scene } from "babylonjs/scene";
  30860. import { IAnimatable } from "babylonjs/Misc/tools";
  30861. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30862. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30863. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30864. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30865. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30866. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30867. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30868. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30869. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30870. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30871. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30872. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30873. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30874. /**
  30875. * Decorator used to define property that can be serialized as reference to a camera
  30876. * @param sourceName defines the name of the property to decorate
  30877. */
  30878. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30879. /**
  30880. * Class used to help serialization objects
  30881. */
  30882. export class SerializationHelper {
  30883. /** hidden */
  30884. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30885. /** hidden */
  30886. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30887. /** hidden */
  30888. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30889. /** hidden */
  30890. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30891. /**
  30892. * Appends the serialized animations from the source animations
  30893. * @param source Source containing the animations
  30894. * @param destination Target to store the animations
  30895. */
  30896. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30897. /**
  30898. * Static function used to serialized a specific entity
  30899. * @param entity defines the entity to serialize
  30900. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30901. * @returns a JSON compatible object representing the serialization of the entity
  30902. */
  30903. static Serialize<T>(entity: T, serializationObject?: any): any;
  30904. /**
  30905. * Creates a new entity from a serialization data object
  30906. * @param creationFunction defines a function used to instanciated the new entity
  30907. * @param source defines the source serialization data
  30908. * @param scene defines the hosting scene
  30909. * @param rootUrl defines the root url for resources
  30910. * @returns a new entity
  30911. */
  30912. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30913. /**
  30914. * Clones an object
  30915. * @param creationFunction defines the function used to instanciate the new object
  30916. * @param source defines the source object
  30917. * @returns the cloned object
  30918. */
  30919. static Clone<T>(creationFunction: () => T, source: T): T;
  30920. /**
  30921. * Instanciates a new object based on a source one (some data will be shared between both object)
  30922. * @param creationFunction defines the function used to instanciate the new object
  30923. * @param source defines the source object
  30924. * @returns the new object
  30925. */
  30926. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30927. }
  30928. }
  30929. declare module "babylonjs/Cameras/camera" {
  30930. import { SmartArray } from "babylonjs/Misc/smartArray";
  30931. import { Observable } from "babylonjs/Misc/observable";
  30932. import { Nullable } from "babylonjs/types";
  30933. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30934. import { Scene } from "babylonjs/scene";
  30935. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30936. import { Node } from "babylonjs/node";
  30937. import { Mesh } from "babylonjs/Meshes/mesh";
  30938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30939. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30940. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30941. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30942. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30943. import { Ray } from "babylonjs/Culling/ray";
  30944. /**
  30945. * This is the base class of all the camera used in the application.
  30946. * @see http://doc.babylonjs.com/features/cameras
  30947. */
  30948. export class Camera extends Node {
  30949. /** @hidden */
  30950. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30951. /**
  30952. * This is the default projection mode used by the cameras.
  30953. * It helps recreating a feeling of perspective and better appreciate depth.
  30954. * This is the best way to simulate real life cameras.
  30955. */
  30956. static readonly PERSPECTIVE_CAMERA: number;
  30957. /**
  30958. * This helps creating camera with an orthographic mode.
  30959. * 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.
  30960. */
  30961. static readonly ORTHOGRAPHIC_CAMERA: number;
  30962. /**
  30963. * This is the default FOV mode for perspective cameras.
  30964. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30965. */
  30966. static readonly FOVMODE_VERTICAL_FIXED: number;
  30967. /**
  30968. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30969. */
  30970. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30971. /**
  30972. * This specifies ther is no need for a camera rig.
  30973. * Basically only one eye is rendered corresponding to the camera.
  30974. */
  30975. static readonly RIG_MODE_NONE: number;
  30976. /**
  30977. * Simulates a camera Rig with one blue eye and one red eye.
  30978. * This can be use with 3d blue and red glasses.
  30979. */
  30980. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30981. /**
  30982. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30983. */
  30984. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30985. /**
  30986. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30987. */
  30988. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30989. /**
  30990. * Defines that both eyes of the camera will be rendered over under each other.
  30991. */
  30992. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30993. /**
  30994. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30995. */
  30996. static readonly RIG_MODE_VR: number;
  30997. /**
  30998. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30999. */
  31000. static readonly RIG_MODE_WEBVR: number;
  31001. /**
  31002. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31003. */
  31004. static readonly RIG_MODE_CUSTOM: number;
  31005. /**
  31006. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31007. */
  31008. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31009. /**
  31010. * Define the input manager associated with the camera.
  31011. */
  31012. inputs: CameraInputsManager<Camera>;
  31013. /** @hidden */
  31014. _position: Vector3;
  31015. /**
  31016. * Define the current local position of the camera in the scene
  31017. */
  31018. position: Vector3;
  31019. /**
  31020. * The vector the camera should consider as up.
  31021. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31022. */
  31023. upVector: Vector3;
  31024. /**
  31025. * Define the current limit on the left side for an orthographic camera
  31026. * In scene unit
  31027. */
  31028. orthoLeft: Nullable<number>;
  31029. /**
  31030. * Define the current limit on the right side for an orthographic camera
  31031. * In scene unit
  31032. */
  31033. orthoRight: Nullable<number>;
  31034. /**
  31035. * Define the current limit on the bottom side for an orthographic camera
  31036. * In scene unit
  31037. */
  31038. orthoBottom: Nullable<number>;
  31039. /**
  31040. * Define the current limit on the top side for an orthographic camera
  31041. * In scene unit
  31042. */
  31043. orthoTop: Nullable<number>;
  31044. /**
  31045. * Field Of View is set in Radians. (default is 0.8)
  31046. */
  31047. fov: number;
  31048. /**
  31049. * Define the minimum distance the camera can see from.
  31050. * This is important to note that the depth buffer are not infinite and the closer it starts
  31051. * the more your scene might encounter depth fighting issue.
  31052. */
  31053. minZ: number;
  31054. /**
  31055. * Define the maximum distance the camera can see to.
  31056. * This is important to note that the depth buffer are not infinite and the further it end
  31057. * the more your scene might encounter depth fighting issue.
  31058. */
  31059. maxZ: number;
  31060. /**
  31061. * Define the default inertia of the camera.
  31062. * This helps giving a smooth feeling to the camera movement.
  31063. */
  31064. inertia: number;
  31065. /**
  31066. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31067. */
  31068. mode: number;
  31069. /**
  31070. * Define wether the camera is intermediate.
  31071. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31072. */
  31073. isIntermediate: boolean;
  31074. /**
  31075. * Define the viewport of the camera.
  31076. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31077. */
  31078. viewport: Viewport;
  31079. /**
  31080. * Restricts the camera to viewing objects with the same layerMask.
  31081. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31082. */
  31083. layerMask: number;
  31084. /**
  31085. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31086. */
  31087. fovMode: number;
  31088. /**
  31089. * Rig mode of the camera.
  31090. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31091. * This is normally controlled byt the camera themselves as internal use.
  31092. */
  31093. cameraRigMode: number;
  31094. /**
  31095. * Defines the distance between both "eyes" in case of a RIG
  31096. */
  31097. interaxialDistance: number;
  31098. /**
  31099. * Defines if stereoscopic rendering is done side by side or over under.
  31100. */
  31101. isStereoscopicSideBySide: boolean;
  31102. /**
  31103. * 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
  31104. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31105. * else in the scene.
  31106. */
  31107. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31108. /**
  31109. * When set, the camera will render to this render target instead of the default canvas
  31110. */
  31111. outputRenderTarget: Nullable<RenderTargetTexture>;
  31112. /**
  31113. * Observable triggered when the camera view matrix has changed.
  31114. */
  31115. onViewMatrixChangedObservable: Observable<Camera>;
  31116. /**
  31117. * Observable triggered when the camera Projection matrix has changed.
  31118. */
  31119. onProjectionMatrixChangedObservable: Observable<Camera>;
  31120. /**
  31121. * Observable triggered when the inputs have been processed.
  31122. */
  31123. onAfterCheckInputsObservable: Observable<Camera>;
  31124. /**
  31125. * Observable triggered when reset has been called and applied to the camera.
  31126. */
  31127. onRestoreStateObservable: Observable<Camera>;
  31128. /** @hidden */
  31129. _cameraRigParams: any;
  31130. /** @hidden */
  31131. _rigCameras: Camera[];
  31132. /** @hidden */
  31133. _rigPostProcess: Nullable<PostProcess>;
  31134. protected _webvrViewMatrix: Matrix;
  31135. /** @hidden */
  31136. _skipRendering: boolean;
  31137. /** @hidden */
  31138. _projectionMatrix: Matrix;
  31139. /** @hidden */
  31140. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31141. /** @hidden */
  31142. _activeMeshes: SmartArray<AbstractMesh>;
  31143. protected _globalPosition: Vector3;
  31144. /** hidden */
  31145. _computedViewMatrix: Matrix;
  31146. private _doNotComputeProjectionMatrix;
  31147. private _transformMatrix;
  31148. private _frustumPlanes;
  31149. private _refreshFrustumPlanes;
  31150. private _storedFov;
  31151. private _stateStored;
  31152. /**
  31153. * Instantiates a new camera object.
  31154. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31155. * @see http://doc.babylonjs.com/features/cameras
  31156. * @param name Defines the name of the camera in the scene
  31157. * @param position Defines the position of the camera
  31158. * @param scene Defines the scene the camera belongs too
  31159. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31160. */
  31161. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31162. /**
  31163. * Store current camera state (fov, position, etc..)
  31164. * @returns the camera
  31165. */
  31166. storeState(): Camera;
  31167. /**
  31168. * Restores the camera state values if it has been stored. You must call storeState() first
  31169. */
  31170. protected _restoreStateValues(): boolean;
  31171. /**
  31172. * Restored camera state. You must call storeState() first.
  31173. * @returns true if restored and false otherwise
  31174. */
  31175. restoreState(): boolean;
  31176. /**
  31177. * Gets the class name of the camera.
  31178. * @returns the class name
  31179. */
  31180. getClassName(): string;
  31181. /** @hidden */
  31182. readonly _isCamera: boolean;
  31183. /**
  31184. * Gets a string representation of the camera useful for debug purpose.
  31185. * @param fullDetails Defines that a more verboe level of logging is required
  31186. * @returns the string representation
  31187. */
  31188. toString(fullDetails?: boolean): string;
  31189. /**
  31190. * Gets the current world space position of the camera.
  31191. */
  31192. readonly globalPosition: Vector3;
  31193. /**
  31194. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31195. * @returns the active meshe list
  31196. */
  31197. getActiveMeshes(): SmartArray<AbstractMesh>;
  31198. /**
  31199. * Check wether a mesh is part of the current active mesh list of the camera
  31200. * @param mesh Defines the mesh to check
  31201. * @returns true if active, false otherwise
  31202. */
  31203. isActiveMesh(mesh: Mesh): boolean;
  31204. /**
  31205. * Is this camera ready to be used/rendered
  31206. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31207. * @return true if the camera is ready
  31208. */
  31209. isReady(completeCheck?: boolean): boolean;
  31210. /** @hidden */
  31211. _initCache(): void;
  31212. /** @hidden */
  31213. _updateCache(ignoreParentClass?: boolean): void;
  31214. /** @hidden */
  31215. _isSynchronized(): boolean;
  31216. /** @hidden */
  31217. _isSynchronizedViewMatrix(): boolean;
  31218. /** @hidden */
  31219. _isSynchronizedProjectionMatrix(): boolean;
  31220. /**
  31221. * Attach the input controls to a specific dom element to get the input from.
  31222. * @param element Defines the element the controls should be listened from
  31223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31224. */
  31225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31226. /**
  31227. * Detach the current controls from the specified dom element.
  31228. * @param element Defines the element to stop listening the inputs from
  31229. */
  31230. detachControl(element: HTMLElement): void;
  31231. /**
  31232. * Update the camera state according to the different inputs gathered during the frame.
  31233. */
  31234. update(): void;
  31235. /** @hidden */
  31236. _checkInputs(): void;
  31237. /** @hidden */
  31238. readonly rigCameras: Camera[];
  31239. /**
  31240. * Gets the post process used by the rig cameras
  31241. */
  31242. readonly rigPostProcess: Nullable<PostProcess>;
  31243. /**
  31244. * Internal, gets the first post proces.
  31245. * @returns the first post process to be run on this camera.
  31246. */
  31247. _getFirstPostProcess(): Nullable<PostProcess>;
  31248. private _cascadePostProcessesToRigCams;
  31249. /**
  31250. * Attach a post process to the camera.
  31251. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31252. * @param postProcess The post process to attach to the camera
  31253. * @param insertAt The position of the post process in case several of them are in use in the scene
  31254. * @returns the position the post process has been inserted at
  31255. */
  31256. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31257. /**
  31258. * Detach a post process to the camera.
  31259. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31260. * @param postProcess The post process to detach from the camera
  31261. */
  31262. detachPostProcess(postProcess: PostProcess): void;
  31263. /**
  31264. * Gets the current world matrix of the camera
  31265. */
  31266. getWorldMatrix(): Matrix;
  31267. /** @hidden */
  31268. _getViewMatrix(): Matrix;
  31269. /**
  31270. * Gets the current view matrix of the camera.
  31271. * @param force forces the camera to recompute the matrix without looking at the cached state
  31272. * @returns the view matrix
  31273. */
  31274. getViewMatrix(force?: boolean): Matrix;
  31275. /**
  31276. * Freeze the projection matrix.
  31277. * It will prevent the cache check of the camera projection compute and can speed up perf
  31278. * if no parameter of the camera are meant to change
  31279. * @param projection Defines manually a projection if necessary
  31280. */
  31281. freezeProjectionMatrix(projection?: Matrix): void;
  31282. /**
  31283. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31284. */
  31285. unfreezeProjectionMatrix(): void;
  31286. /**
  31287. * Gets the current projection matrix of the camera.
  31288. * @param force forces the camera to recompute the matrix without looking at the cached state
  31289. * @returns the projection matrix
  31290. */
  31291. getProjectionMatrix(force?: boolean): Matrix;
  31292. /**
  31293. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31294. * @returns a Matrix
  31295. */
  31296. getTransformationMatrix(): Matrix;
  31297. private _updateFrustumPlanes;
  31298. /**
  31299. * Checks if a cullable object (mesh...) is in the camera frustum
  31300. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31301. * @param target The object to check
  31302. * @returns true if the object is in frustum otherwise false
  31303. */
  31304. isInFrustum(target: ICullable): boolean;
  31305. /**
  31306. * Checks if a cullable object (mesh...) is in the camera frustum
  31307. * Unlike isInFrustum this cheks the full bounding box
  31308. * @param target The object to check
  31309. * @returns true if the object is in frustum otherwise false
  31310. */
  31311. isCompletelyInFrustum(target: ICullable): boolean;
  31312. /**
  31313. * Gets a ray in the forward direction from the camera.
  31314. * @param length Defines the length of the ray to create
  31315. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31316. * @param origin Defines the start point of the ray which defaults to the camera position
  31317. * @returns the forward ray
  31318. */
  31319. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31320. /**
  31321. * Releases resources associated with this node.
  31322. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31323. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31324. */
  31325. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31326. /** @hidden */
  31327. _isLeftCamera: boolean;
  31328. /**
  31329. * Gets the left camera of a rig setup in case of Rigged Camera
  31330. */
  31331. readonly isLeftCamera: boolean;
  31332. /** @hidden */
  31333. _isRightCamera: boolean;
  31334. /**
  31335. * Gets the right camera of a rig setup in case of Rigged Camera
  31336. */
  31337. readonly isRightCamera: boolean;
  31338. /**
  31339. * Gets the left camera of a rig setup in case of Rigged Camera
  31340. */
  31341. readonly leftCamera: Nullable<FreeCamera>;
  31342. /**
  31343. * Gets the right camera of a rig setup in case of Rigged Camera
  31344. */
  31345. readonly rightCamera: Nullable<FreeCamera>;
  31346. /**
  31347. * Gets the left camera target of a rig setup in case of Rigged Camera
  31348. * @returns the target position
  31349. */
  31350. getLeftTarget(): Nullable<Vector3>;
  31351. /**
  31352. * Gets the right camera target of a rig setup in case of Rigged Camera
  31353. * @returns the target position
  31354. */
  31355. getRightTarget(): Nullable<Vector3>;
  31356. /**
  31357. * @hidden
  31358. */
  31359. setCameraRigMode(mode: number, rigParams: any): void;
  31360. /** @hidden */
  31361. static _setStereoscopicRigMode(camera: Camera): void;
  31362. /** @hidden */
  31363. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31364. /** @hidden */
  31365. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31366. /** @hidden */
  31367. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31368. /** @hidden */
  31369. _getVRProjectionMatrix(): Matrix;
  31370. protected _updateCameraRotationMatrix(): void;
  31371. protected _updateWebVRCameraRotationMatrix(): void;
  31372. /**
  31373. * This function MUST be overwritten by the different WebVR cameras available.
  31374. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31375. * @hidden
  31376. */
  31377. _getWebVRProjectionMatrix(): Matrix;
  31378. /**
  31379. * This function MUST be overwritten by the different WebVR cameras available.
  31380. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31381. * @hidden
  31382. */
  31383. _getWebVRViewMatrix(): Matrix;
  31384. /** @hidden */
  31385. setCameraRigParameter(name: string, value: any): void;
  31386. /**
  31387. * needs to be overridden by children so sub has required properties to be copied
  31388. * @hidden
  31389. */
  31390. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31391. /**
  31392. * May need to be overridden by children
  31393. * @hidden
  31394. */
  31395. _updateRigCameras(): void;
  31396. /** @hidden */
  31397. _setupInputs(): void;
  31398. /**
  31399. * Serialiaze the camera setup to a json represention
  31400. * @returns the JSON representation
  31401. */
  31402. serialize(): any;
  31403. /**
  31404. * Clones the current camera.
  31405. * @param name The cloned camera name
  31406. * @returns the cloned camera
  31407. */
  31408. clone(name: string): Camera;
  31409. /**
  31410. * Gets the direction of the camera relative to a given local axis.
  31411. * @param localAxis Defines the reference axis to provide a relative direction.
  31412. * @return the direction
  31413. */
  31414. getDirection(localAxis: Vector3): Vector3;
  31415. /**
  31416. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31417. * @param localAxis Defines the reference axis to provide a relative direction.
  31418. * @param result Defines the vector to store the result in
  31419. */
  31420. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31421. /**
  31422. * Gets a camera constructor for a given camera type
  31423. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31424. * @param name The name of the camera the result will be able to instantiate
  31425. * @param scene The scene the result will construct the camera in
  31426. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31427. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31428. * @returns a factory method to construc the camera
  31429. */
  31430. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31431. /**
  31432. * Compute the world matrix of the camera.
  31433. * @returns the camera workd matrix
  31434. */
  31435. computeWorldMatrix(): Matrix;
  31436. /**
  31437. * Parse a JSON and creates the camera from the parsed information
  31438. * @param parsedCamera The JSON to parse
  31439. * @param scene The scene to instantiate the camera in
  31440. * @returns the newly constructed camera
  31441. */
  31442. static Parse(parsedCamera: any, scene: Scene): Camera;
  31443. }
  31444. }
  31445. declare module "babylonjs/Misc/tools" {
  31446. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31447. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31448. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31449. import { Observable } from "babylonjs/Misc/observable";
  31450. import { DomManagement } from "babylonjs/Misc/domManagement";
  31451. import { WebRequest } from "babylonjs/Misc/webRequest";
  31452. import { Camera } from "babylonjs/Cameras/camera";
  31453. import { Engine } from "babylonjs/Engines/engine";
  31454. import { Animation } from "babylonjs/Animations/animation";
  31455. /**
  31456. * Interface for any object that can request an animation frame
  31457. */
  31458. export interface ICustomAnimationFrameRequester {
  31459. /**
  31460. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31461. */
  31462. renderFunction?: Function;
  31463. /**
  31464. * Called to request the next frame to render to
  31465. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31466. */
  31467. requestAnimationFrame: Function;
  31468. /**
  31469. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31470. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31471. */
  31472. requestID?: number;
  31473. }
  31474. /**
  31475. * Interface containing an array of animations
  31476. */
  31477. export interface IAnimatable {
  31478. /**
  31479. * Array of animations
  31480. */
  31481. animations: Nullable<Array<Animation>>;
  31482. }
  31483. /** Interface used by value gradients (color, factor, ...) */
  31484. export interface IValueGradient {
  31485. /**
  31486. * Gets or sets the gradient value (between 0 and 1)
  31487. */
  31488. gradient: number;
  31489. }
  31490. /** Class used to store color4 gradient */
  31491. export class ColorGradient implements IValueGradient {
  31492. /**
  31493. * Gets or sets the gradient value (between 0 and 1)
  31494. */
  31495. gradient: number;
  31496. /**
  31497. * Gets or sets first associated color
  31498. */
  31499. color1: Color4;
  31500. /**
  31501. * Gets or sets second associated color
  31502. */
  31503. color2?: Color4;
  31504. /**
  31505. * Will get a color picked randomly between color1 and color2.
  31506. * If color2 is undefined then color1 will be used
  31507. * @param result defines the target Color4 to store the result in
  31508. */
  31509. getColorToRef(result: Color4): void;
  31510. }
  31511. /** Class used to store color 3 gradient */
  31512. export class Color3Gradient implements IValueGradient {
  31513. /**
  31514. * Gets or sets the gradient value (between 0 and 1)
  31515. */
  31516. gradient: number;
  31517. /**
  31518. * Gets or sets the associated color
  31519. */
  31520. color: Color3;
  31521. }
  31522. /** Class used to store factor gradient */
  31523. export class FactorGradient implements IValueGradient {
  31524. /**
  31525. * Gets or sets the gradient value (between 0 and 1)
  31526. */
  31527. gradient: number;
  31528. /**
  31529. * Gets or sets first associated factor
  31530. */
  31531. factor1: number;
  31532. /**
  31533. * Gets or sets second associated factor
  31534. */
  31535. factor2?: number;
  31536. /**
  31537. * Will get a number picked randomly between factor1 and factor2.
  31538. * If factor2 is undefined then factor1 will be used
  31539. * @returns the picked number
  31540. */
  31541. getFactor(): number;
  31542. }
  31543. /**
  31544. * @ignore
  31545. * Application error to support additional information when loading a file
  31546. */
  31547. export class LoadFileError extends Error {
  31548. /** defines the optional web request */
  31549. request?: WebRequest | undefined;
  31550. private static _setPrototypeOf;
  31551. /**
  31552. * Creates a new LoadFileError
  31553. * @param message defines the message of the error
  31554. * @param request defines the optional web request
  31555. */
  31556. constructor(message: string,
  31557. /** defines the optional web request */
  31558. request?: WebRequest | undefined);
  31559. }
  31560. /**
  31561. * Class used to define a retry strategy when error happens while loading assets
  31562. */
  31563. export class RetryStrategy {
  31564. /**
  31565. * Function used to defines an exponential back off strategy
  31566. * @param maxRetries defines the maximum number of retries (3 by default)
  31567. * @param baseInterval defines the interval between retries
  31568. * @returns the strategy function to use
  31569. */
  31570. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31571. }
  31572. /**
  31573. * File request interface
  31574. */
  31575. export interface IFileRequest {
  31576. /**
  31577. * Raised when the request is complete (success or error).
  31578. */
  31579. onCompleteObservable: Observable<IFileRequest>;
  31580. /**
  31581. * Aborts the request for a file.
  31582. */
  31583. abort: () => void;
  31584. }
  31585. /**
  31586. * Class containing a set of static utilities functions
  31587. */
  31588. export class Tools {
  31589. /**
  31590. * Gets or sets the base URL to use to load assets
  31591. */
  31592. static BaseUrl: string;
  31593. /**
  31594. * Enable/Disable Custom HTTP Request Headers globally.
  31595. * default = false
  31596. * @see CustomRequestHeaders
  31597. */
  31598. static UseCustomRequestHeaders: boolean;
  31599. /**
  31600. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31601. * i.e. when loading files, where the server/service expects an Authorization header
  31602. */
  31603. static CustomRequestHeaders: {
  31604. [key: string]: string;
  31605. };
  31606. /**
  31607. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31608. */
  31609. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31610. /**
  31611. * Default behaviour for cors in the application.
  31612. * It can be a string if the expected behavior is identical in the entire app.
  31613. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31614. */
  31615. static CorsBehavior: string | ((url: string | string[]) => string);
  31616. /**
  31617. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31618. * @ignorenaming
  31619. */
  31620. static UseFallbackTexture: boolean;
  31621. /**
  31622. * Use this object to register external classes like custom textures or material
  31623. * to allow the laoders to instantiate them
  31624. */
  31625. static RegisteredExternalClasses: {
  31626. [key: string]: Object;
  31627. };
  31628. /**
  31629. * Texture content used if a texture cannot loaded
  31630. * @ignorenaming
  31631. */
  31632. static fallbackTexture: string;
  31633. /**
  31634. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31635. * @param u defines the coordinate on X axis
  31636. * @param v defines the coordinate on Y axis
  31637. * @param width defines the width of the source data
  31638. * @param height defines the height of the source data
  31639. * @param pixels defines the source byte array
  31640. * @param color defines the output color
  31641. */
  31642. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31643. /**
  31644. * Interpolates between a and b via alpha
  31645. * @param a The lower value (returned when alpha = 0)
  31646. * @param b The upper value (returned when alpha = 1)
  31647. * @param alpha The interpolation-factor
  31648. * @return The mixed value
  31649. */
  31650. static Mix(a: number, b: number, alpha: number): number;
  31651. /**
  31652. * Tries to instantiate a new object from a given class name
  31653. * @param className defines the class name to instantiate
  31654. * @returns the new object or null if the system was not able to do the instantiation
  31655. */
  31656. static Instantiate(className: string): any;
  31657. /**
  31658. * Provides a slice function that will work even on IE
  31659. * @param data defines the array to slice
  31660. * @param start defines the start of the data (optional)
  31661. * @param end defines the end of the data (optional)
  31662. * @returns the new sliced array
  31663. */
  31664. static Slice<T>(data: T, start?: number, end?: number): T;
  31665. /**
  31666. * Polyfill for setImmediate
  31667. * @param action defines the action to execute after the current execution block
  31668. */
  31669. static SetImmediate(action: () => void): void;
  31670. /**
  31671. * Function indicating if a number is an exponent of 2
  31672. * @param value defines the value to test
  31673. * @returns true if the value is an exponent of 2
  31674. */
  31675. static IsExponentOfTwo(value: number): boolean;
  31676. private static _tmpFloatArray;
  31677. /**
  31678. * Returns the nearest 32-bit single precision float representation of a Number
  31679. * @param value A Number. If the parameter is of a different type, it will get converted
  31680. * to a number or to NaN if it cannot be converted
  31681. * @returns number
  31682. */
  31683. static FloatRound(value: number): number;
  31684. /**
  31685. * Find the next highest power of two.
  31686. * @param x Number to start search from.
  31687. * @return Next highest power of two.
  31688. */
  31689. static CeilingPOT(x: number): number;
  31690. /**
  31691. * Find the next lowest power of two.
  31692. * @param x Number to start search from.
  31693. * @return Next lowest power of two.
  31694. */
  31695. static FloorPOT(x: number): number;
  31696. /**
  31697. * Find the nearest power of two.
  31698. * @param x Number to start search from.
  31699. * @return Next nearest power of two.
  31700. */
  31701. static NearestPOT(x: number): number;
  31702. /**
  31703. * Get the closest exponent of two
  31704. * @param value defines the value to approximate
  31705. * @param max defines the maximum value to return
  31706. * @param mode defines how to define the closest value
  31707. * @returns closest exponent of two of the given value
  31708. */
  31709. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31710. /**
  31711. * Extracts the filename from a path
  31712. * @param path defines the path to use
  31713. * @returns the filename
  31714. */
  31715. static GetFilename(path: string): string;
  31716. /**
  31717. * Extracts the "folder" part of a path (everything before the filename).
  31718. * @param uri The URI to extract the info from
  31719. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31720. * @returns The "folder" part of the path
  31721. */
  31722. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31723. /**
  31724. * Extracts text content from a DOM element hierarchy
  31725. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31726. */
  31727. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31728. /**
  31729. * Convert an angle in radians to degrees
  31730. * @param angle defines the angle to convert
  31731. * @returns the angle in degrees
  31732. */
  31733. static ToDegrees(angle: number): number;
  31734. /**
  31735. * Convert an angle in degrees to radians
  31736. * @param angle defines the angle to convert
  31737. * @returns the angle in radians
  31738. */
  31739. static ToRadians(angle: number): number;
  31740. /**
  31741. * Encode a buffer to a base64 string
  31742. * @param buffer defines the buffer to encode
  31743. * @returns the encoded string
  31744. */
  31745. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31746. /**
  31747. * Extracts minimum and maximum values from a list of indexed positions
  31748. * @param positions defines the positions to use
  31749. * @param indices defines the indices to the positions
  31750. * @param indexStart defines the start index
  31751. * @param indexCount defines the end index
  31752. * @param bias defines bias value to add to the result
  31753. * @return minimum and maximum values
  31754. */
  31755. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31756. minimum: Vector3;
  31757. maximum: Vector3;
  31758. };
  31759. /**
  31760. * Extracts minimum and maximum values from a list of positions
  31761. * @param positions defines the positions to use
  31762. * @param start defines the start index in the positions array
  31763. * @param count defines the number of positions to handle
  31764. * @param bias defines bias value to add to the result
  31765. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31766. * @return minimum and maximum values
  31767. */
  31768. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31769. minimum: Vector3;
  31770. maximum: Vector3;
  31771. };
  31772. /**
  31773. * Returns an array if obj is not an array
  31774. * @param obj defines the object to evaluate as an array
  31775. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31776. * @returns either obj directly if obj is an array or a new array containing obj
  31777. */
  31778. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31779. /**
  31780. * Gets the pointer prefix to use
  31781. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31782. */
  31783. static GetPointerPrefix(): string;
  31784. /**
  31785. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31786. * @param func - the function to be called
  31787. * @param requester - the object that will request the next frame. Falls back to window.
  31788. * @returns frame number
  31789. */
  31790. static QueueNewFrame(func: () => void, requester?: any): number;
  31791. /**
  31792. * Ask the browser to promote the current element to fullscreen rendering mode
  31793. * @param element defines the DOM element to promote
  31794. */
  31795. static RequestFullscreen(element: HTMLElement): void;
  31796. /**
  31797. * Asks the browser to exit fullscreen mode
  31798. */
  31799. static ExitFullscreen(): void;
  31800. /**
  31801. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31802. * @param url define the url we are trying
  31803. * @param element define the dom element where to configure the cors policy
  31804. */
  31805. static SetCorsBehavior(url: string | string[], element: {
  31806. crossOrigin: string | null;
  31807. }): void;
  31808. /**
  31809. * Removes unwanted characters from an url
  31810. * @param url defines the url to clean
  31811. * @returns the cleaned url
  31812. */
  31813. static CleanUrl(url: string): string;
  31814. /**
  31815. * Gets or sets a function used to pre-process url before using them to load assets
  31816. */
  31817. static PreprocessUrl: (url: string) => string;
  31818. /**
  31819. * Loads an image as an HTMLImageElement.
  31820. * @param input url string, ArrayBuffer, or Blob to load
  31821. * @param onLoad callback called when the image successfully loads
  31822. * @param onError callback called when the image fails to load
  31823. * @param offlineProvider offline provider for caching
  31824. * @returns the HTMLImageElement of the loaded image
  31825. */
  31826. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31827. /**
  31828. * Loads a file
  31829. * @param url url string, ArrayBuffer, or Blob to load
  31830. * @param onSuccess callback called when the file successfully loads
  31831. * @param onProgress callback called while file is loading (if the server supports this mode)
  31832. * @param offlineProvider defines the offline provider for caching
  31833. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31834. * @param onError callback called when the file fails to load
  31835. * @returns a file request object
  31836. */
  31837. 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;
  31838. /**
  31839. * Load a script (identified by an url). When the url returns, the
  31840. * content of this file is added into a new script element, attached to the DOM (body element)
  31841. * @param scriptUrl defines the url of the script to laod
  31842. * @param onSuccess defines the callback called when the script is loaded
  31843. * @param onError defines the callback to call if an error occurs
  31844. * @param scriptId defines the id of the script element
  31845. */
  31846. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31847. /**
  31848. * Load an asynchronous script (identified by an url). When the url returns, the
  31849. * content of this file is added into a new script element, attached to the DOM (body element)
  31850. * @param scriptUrl defines the url of the script to laod
  31851. * @param scriptId defines the id of the script element
  31852. * @returns a promise request object
  31853. */
  31854. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31855. /**
  31856. * Loads a file from a blob
  31857. * @param fileToLoad defines the blob to use
  31858. * @param callback defines the callback to call when data is loaded
  31859. * @param progressCallback defines the callback to call during loading process
  31860. * @returns a file request object
  31861. */
  31862. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31863. /**
  31864. * Loads a file
  31865. * @param fileToLoad defines the file to load
  31866. * @param callback defines the callback to call when data is loaded
  31867. * @param progressCallBack defines the callback to call during loading process
  31868. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31869. * @returns a file request object
  31870. */
  31871. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31872. /**
  31873. * Creates a data url from a given string content
  31874. * @param content defines the content to convert
  31875. * @returns the new data url link
  31876. */
  31877. static FileAsURL(content: string): string;
  31878. /**
  31879. * Format the given number to a specific decimal format
  31880. * @param value defines the number to format
  31881. * @param decimals defines the number of decimals to use
  31882. * @returns the formatted string
  31883. */
  31884. static Format(value: number, decimals?: number): string;
  31885. /**
  31886. * Checks if a given vector is inside a specific range
  31887. * @param v defines the vector to test
  31888. * @param min defines the minimum range
  31889. * @param max defines the maximum range
  31890. */
  31891. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31892. /**
  31893. * Tries to copy an object by duplicating every property
  31894. * @param source defines the source object
  31895. * @param destination defines the target object
  31896. * @param doNotCopyList defines a list of properties to avoid
  31897. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31898. */
  31899. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31900. /**
  31901. * Gets a boolean indicating if the given object has no own property
  31902. * @param obj defines the object to test
  31903. * @returns true if object has no own property
  31904. */
  31905. static IsEmpty(obj: any): boolean;
  31906. /**
  31907. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31908. * @param str Source string
  31909. * @param suffix Suffix to search for in the source string
  31910. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31911. */
  31912. static EndsWith(str: string, suffix: string): boolean;
  31913. /**
  31914. * Function used to register events at window level
  31915. * @param events defines the events to register
  31916. */
  31917. static RegisterTopRootEvents(events: {
  31918. name: string;
  31919. handler: Nullable<(e: FocusEvent) => any>;
  31920. }[]): void;
  31921. /**
  31922. * Function used to unregister events from window level
  31923. * @param events defines the events to unregister
  31924. */
  31925. static UnregisterTopRootEvents(events: {
  31926. name: string;
  31927. handler: Nullable<(e: FocusEvent) => any>;
  31928. }[]): void;
  31929. /**
  31930. * @ignore
  31931. */
  31932. static _ScreenshotCanvas: HTMLCanvasElement;
  31933. /**
  31934. * Dumps the current bound framebuffer
  31935. * @param width defines the rendering width
  31936. * @param height defines the rendering height
  31937. * @param engine defines the hosting engine
  31938. * @param successCallback defines the callback triggered once the data are available
  31939. * @param mimeType defines the mime type of the result
  31940. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31941. */
  31942. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31943. /**
  31944. * Converts the canvas data to blob.
  31945. * This acts as a polyfill for browsers not supporting the to blob function.
  31946. * @param canvas Defines the canvas to extract the data from
  31947. * @param successCallback Defines the callback triggered once the data are available
  31948. * @param mimeType Defines the mime type of the result
  31949. */
  31950. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31951. /**
  31952. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31953. * @param successCallback defines the callback triggered once the data are available
  31954. * @param mimeType defines the mime type of the result
  31955. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31956. */
  31957. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31958. /**
  31959. * Downloads a blob in the browser
  31960. * @param blob defines the blob to download
  31961. * @param fileName defines the name of the downloaded file
  31962. */
  31963. static Download(blob: Blob, fileName: string): void;
  31964. /**
  31965. * Captures a screenshot of the current rendering
  31966. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31967. * @param engine defines the rendering engine
  31968. * @param camera defines the source camera
  31969. * @param size This parameter can be set to a single number or to an object with the
  31970. * following (optional) properties: precision, width, height. If a single number is passed,
  31971. * it will be used for both width and height. If an object is passed, the screenshot size
  31972. * will be derived from the parameters. The precision property is a multiplier allowing
  31973. * rendering at a higher or lower resolution
  31974. * @param successCallback defines the callback receives a single parameter which contains the
  31975. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31976. * src parameter of an <img> to display it
  31977. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31978. * Check your browser for supported MIME types
  31979. */
  31980. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31981. /**
  31982. * Generates an image screenshot from the specified camera.
  31983. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31984. * @param engine The engine to use for rendering
  31985. * @param camera The camera to use for rendering
  31986. * @param size This parameter can be set to a single number or to an object with the
  31987. * following (optional) properties: precision, width, height. If a single number is passed,
  31988. * it will be used for both width and height. If an object is passed, the screenshot size
  31989. * will be derived from the parameters. The precision property is a multiplier allowing
  31990. * rendering at a higher or lower resolution
  31991. * @param successCallback The callback receives a single parameter which contains the
  31992. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31993. * src parameter of an <img> to display it
  31994. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31995. * Check your browser for supported MIME types
  31996. * @param samples Texture samples (default: 1)
  31997. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31998. * @param fileName A name for for the downloaded file.
  31999. */
  32000. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32001. /**
  32002. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32003. * Be aware Math.random() could cause collisions, but:
  32004. * "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"
  32005. * @returns a pseudo random id
  32006. */
  32007. static RandomId(): string;
  32008. /**
  32009. * Test if the given uri is a base64 string
  32010. * @param uri The uri to test
  32011. * @return True if the uri is a base64 string or false otherwise
  32012. */
  32013. static IsBase64(uri: string): boolean;
  32014. /**
  32015. * Decode the given base64 uri.
  32016. * @param uri The uri to decode
  32017. * @return The decoded base64 data.
  32018. */
  32019. static DecodeBase64(uri: string): ArrayBuffer;
  32020. /**
  32021. * Gets the absolute url.
  32022. * @param url the input url
  32023. * @return the absolute url
  32024. */
  32025. static GetAbsoluteUrl(url: string): string;
  32026. /**
  32027. * No log
  32028. */
  32029. static readonly NoneLogLevel: number;
  32030. /**
  32031. * Only message logs
  32032. */
  32033. static readonly MessageLogLevel: number;
  32034. /**
  32035. * Only warning logs
  32036. */
  32037. static readonly WarningLogLevel: number;
  32038. /**
  32039. * Only error logs
  32040. */
  32041. static readonly ErrorLogLevel: number;
  32042. /**
  32043. * All logs
  32044. */
  32045. static readonly AllLogLevel: number;
  32046. /**
  32047. * Gets a value indicating the number of loading errors
  32048. * @ignorenaming
  32049. */
  32050. static readonly errorsCount: number;
  32051. /**
  32052. * Callback called when a new log is added
  32053. */
  32054. static OnNewCacheEntry: (entry: string) => void;
  32055. /**
  32056. * Log a message to the console
  32057. * @param message defines the message to log
  32058. */
  32059. static Log(message: string): void;
  32060. /**
  32061. * Write a warning message to the console
  32062. * @param message defines the message to log
  32063. */
  32064. static Warn(message: string): void;
  32065. /**
  32066. * Write an error message to the console
  32067. * @param message defines the message to log
  32068. */
  32069. static Error(message: string): void;
  32070. /**
  32071. * Gets current log cache (list of logs)
  32072. */
  32073. static readonly LogCache: string;
  32074. /**
  32075. * Clears the log cache
  32076. */
  32077. static ClearLogCache(): void;
  32078. /**
  32079. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32080. */
  32081. static LogLevels: number;
  32082. /**
  32083. * Checks if the loaded document was accessed via `file:`-Protocol.
  32084. * @returns boolean
  32085. */
  32086. static IsFileURL(): boolean;
  32087. /**
  32088. * Checks if the window object exists
  32089. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32090. */
  32091. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32092. /**
  32093. * No performance log
  32094. */
  32095. static readonly PerformanceNoneLogLevel: number;
  32096. /**
  32097. * Use user marks to log performance
  32098. */
  32099. static readonly PerformanceUserMarkLogLevel: number;
  32100. /**
  32101. * Log performance to the console
  32102. */
  32103. static readonly PerformanceConsoleLogLevel: number;
  32104. private static _performance;
  32105. /**
  32106. * Sets the current performance log level
  32107. */
  32108. static PerformanceLogLevel: number;
  32109. private static _StartPerformanceCounterDisabled;
  32110. private static _EndPerformanceCounterDisabled;
  32111. private static _StartUserMark;
  32112. private static _EndUserMark;
  32113. private static _StartPerformanceConsole;
  32114. private static _EndPerformanceConsole;
  32115. /**
  32116. * Starts a performance counter
  32117. */
  32118. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32119. /**
  32120. * Ends a specific performance coutner
  32121. */
  32122. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32123. /**
  32124. * Gets either window.performance.now() if supported or Date.now() else
  32125. */
  32126. static readonly Now: number;
  32127. /**
  32128. * This method will return the name of the class used to create the instance of the given object.
  32129. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32130. * @param object the object to get the class name from
  32131. * @param isType defines if the object is actually a type
  32132. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32133. */
  32134. static GetClassName(object: any, isType?: boolean): string;
  32135. /**
  32136. * Gets the first element of an array satisfying a given predicate
  32137. * @param array defines the array to browse
  32138. * @param predicate defines the predicate to use
  32139. * @returns null if not found or the element
  32140. */
  32141. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32142. /**
  32143. * This method will return the name of the full name of the class, including its owning module (if any).
  32144. * 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).
  32145. * @param object the object to get the class name from
  32146. * @param isType defines if the object is actually a type
  32147. * @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.
  32148. * @ignorenaming
  32149. */
  32150. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32151. /**
  32152. * Returns a promise that resolves after the given amount of time.
  32153. * @param delay Number of milliseconds to delay
  32154. * @returns Promise that resolves after the given amount of time
  32155. */
  32156. static DelayAsync(delay: number): Promise<void>;
  32157. /**
  32158. * Gets the current gradient from an array of IValueGradient
  32159. * @param ratio defines the current ratio to get
  32160. * @param gradients defines the array of IValueGradient
  32161. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32162. */
  32163. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32164. }
  32165. /**
  32166. * This class is used to track a performance counter which is number based.
  32167. * The user has access to many properties which give statistics of different nature.
  32168. *
  32169. * The implementer can track two kinds of Performance Counter: time and count.
  32170. * 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.
  32171. * 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.
  32172. */
  32173. export class PerfCounter {
  32174. /**
  32175. * Gets or sets a global boolean to turn on and off all the counters
  32176. */
  32177. static Enabled: boolean;
  32178. /**
  32179. * Returns the smallest value ever
  32180. */
  32181. readonly min: number;
  32182. /**
  32183. * Returns the biggest value ever
  32184. */
  32185. readonly max: number;
  32186. /**
  32187. * Returns the average value since the performance counter is running
  32188. */
  32189. readonly average: number;
  32190. /**
  32191. * Returns the average value of the last second the counter was monitored
  32192. */
  32193. readonly lastSecAverage: number;
  32194. /**
  32195. * Returns the current value
  32196. */
  32197. readonly current: number;
  32198. /**
  32199. * Gets the accumulated total
  32200. */
  32201. readonly total: number;
  32202. /**
  32203. * Gets the total value count
  32204. */
  32205. readonly count: number;
  32206. /**
  32207. * Creates a new counter
  32208. */
  32209. constructor();
  32210. /**
  32211. * Call this method to start monitoring a new frame.
  32212. * 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.
  32213. */
  32214. fetchNewFrame(): void;
  32215. /**
  32216. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32217. * @param newCount the count value to add to the monitored count
  32218. * @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.
  32219. */
  32220. addCount(newCount: number, fetchResult: boolean): void;
  32221. /**
  32222. * Start monitoring this performance counter
  32223. */
  32224. beginMonitoring(): void;
  32225. /**
  32226. * Compute the time lapsed since the previous beginMonitoring() call.
  32227. * @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
  32228. */
  32229. endMonitoring(newFrame?: boolean): void;
  32230. private _fetchResult;
  32231. private _startMonitoringTime;
  32232. private _min;
  32233. private _max;
  32234. private _average;
  32235. private _current;
  32236. private _totalValueCount;
  32237. private _totalAccumulated;
  32238. private _lastSecAverage;
  32239. private _lastSecAccumulated;
  32240. private _lastSecTime;
  32241. private _lastSecValueCount;
  32242. }
  32243. /**
  32244. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32245. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32246. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32247. * @param name The name of the class, case should be preserved
  32248. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32249. */
  32250. export function className(name: string, module?: string): (target: Object) => void;
  32251. /**
  32252. * An implementation of a loop for asynchronous functions.
  32253. */
  32254. export class AsyncLoop {
  32255. /**
  32256. * Defines the number of iterations for the loop
  32257. */
  32258. iterations: number;
  32259. /**
  32260. * Defines the current index of the loop.
  32261. */
  32262. index: number;
  32263. private _done;
  32264. private _fn;
  32265. private _successCallback;
  32266. /**
  32267. * Constructor.
  32268. * @param iterations the number of iterations.
  32269. * @param func the function to run each iteration
  32270. * @param successCallback the callback that will be called upon succesful execution
  32271. * @param offset starting offset.
  32272. */
  32273. constructor(
  32274. /**
  32275. * Defines the number of iterations for the loop
  32276. */
  32277. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32278. /**
  32279. * Execute the next iteration. Must be called after the last iteration was finished.
  32280. */
  32281. executeNext(): void;
  32282. /**
  32283. * Break the loop and run the success callback.
  32284. */
  32285. breakLoop(): void;
  32286. /**
  32287. * Create and run an async loop.
  32288. * @param iterations the number of iterations.
  32289. * @param fn the function to run each iteration
  32290. * @param successCallback the callback that will be called upon succesful execution
  32291. * @param offset starting offset.
  32292. * @returns the created async loop object
  32293. */
  32294. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32295. /**
  32296. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32297. * @param iterations total number of iterations
  32298. * @param syncedIterations number of synchronous iterations in each async iteration.
  32299. * @param fn the function to call each iteration.
  32300. * @param callback a success call back that will be called when iterating stops.
  32301. * @param breakFunction a break condition (optional)
  32302. * @param timeout timeout settings for the setTimeout function. default - 0.
  32303. * @returns the created async loop object
  32304. */
  32305. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32306. }
  32307. }
  32308. declare module "babylonjs/Collisions/collisionCoordinator" {
  32309. import { Nullable } from "babylonjs/types";
  32310. import { Scene } from "babylonjs/scene";
  32311. import { Vector3 } from "babylonjs/Maths/math";
  32312. import { Collider } from "babylonjs/Collisions/collider";
  32313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32314. /** @hidden */
  32315. export interface ICollisionCoordinator {
  32316. createCollider(): Collider;
  32317. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32318. init(scene: Scene): void;
  32319. }
  32320. /** @hidden */
  32321. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32322. private _scene;
  32323. private _scaledPosition;
  32324. private _scaledVelocity;
  32325. private _finalPosition;
  32326. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32327. createCollider(): Collider;
  32328. init(scene: Scene): void;
  32329. private _collideWithWorld;
  32330. }
  32331. }
  32332. declare module "babylonjs/Inputs/scene.inputManager" {
  32333. import { Nullable } from "babylonjs/types";
  32334. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32335. import { Vector2 } from "babylonjs/Maths/math";
  32336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32337. import { Scene } from "babylonjs/scene";
  32338. /**
  32339. * Class used to manage all inputs for the scene.
  32340. */
  32341. export class InputManager {
  32342. /** The distance in pixel that you have to move to prevent some events */
  32343. static DragMovementThreshold: number;
  32344. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32345. static LongPressDelay: number;
  32346. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32347. static DoubleClickDelay: number;
  32348. /** If you need to check double click without raising a single click at first click, enable this flag */
  32349. static ExclusiveDoubleClickMode: boolean;
  32350. private _wheelEventName;
  32351. private _onPointerMove;
  32352. private _onPointerDown;
  32353. private _onPointerUp;
  32354. private _initClickEvent;
  32355. private _initActionManager;
  32356. private _delayedSimpleClick;
  32357. private _delayedSimpleClickTimeout;
  32358. private _previousDelayedSimpleClickTimeout;
  32359. private _meshPickProceed;
  32360. private _previousButtonPressed;
  32361. private _currentPickResult;
  32362. private _previousPickResult;
  32363. private _totalPointersPressed;
  32364. private _doubleClickOccured;
  32365. private _pointerOverMesh;
  32366. private _pickedDownMesh;
  32367. private _pickedUpMesh;
  32368. private _pointerX;
  32369. private _pointerY;
  32370. private _unTranslatedPointerX;
  32371. private _unTranslatedPointerY;
  32372. private _startingPointerPosition;
  32373. private _previousStartingPointerPosition;
  32374. private _startingPointerTime;
  32375. private _previousStartingPointerTime;
  32376. private _pointerCaptures;
  32377. private _onKeyDown;
  32378. private _onKeyUp;
  32379. private _onCanvasFocusObserver;
  32380. private _onCanvasBlurObserver;
  32381. private _scene;
  32382. /**
  32383. * Creates a new InputManager
  32384. * @param scene defines the hosting scene
  32385. */
  32386. constructor(scene: Scene);
  32387. /**
  32388. * Gets the mesh that is currently under the pointer
  32389. */
  32390. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32391. /**
  32392. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32393. */
  32394. readonly unTranslatedPointer: Vector2;
  32395. /**
  32396. * Gets or sets the current on-screen X position of the pointer
  32397. */
  32398. pointerX: number;
  32399. /**
  32400. * Gets or sets the current on-screen Y position of the pointer
  32401. */
  32402. pointerY: number;
  32403. private _updatePointerPosition;
  32404. private _processPointerMove;
  32405. private _setRayOnPointerInfo;
  32406. private _checkPrePointerObservable;
  32407. /**
  32408. * Use this method to simulate a pointer move on a mesh
  32409. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32410. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32411. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32412. */
  32413. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32414. /**
  32415. * Use this method to simulate a pointer down on a mesh
  32416. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32417. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32418. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32419. */
  32420. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32421. private _processPointerDown;
  32422. /** @hidden */
  32423. _isPointerSwiping(): boolean;
  32424. /**
  32425. * Use this method to simulate a pointer up on a mesh
  32426. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32427. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32428. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32429. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32430. */
  32431. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32432. private _processPointerUp;
  32433. /**
  32434. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32435. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32436. * @returns true if the pointer was captured
  32437. */
  32438. isPointerCaptured(pointerId?: number): boolean;
  32439. /**
  32440. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32441. * @param attachUp defines if you want to attach events to pointerup
  32442. * @param attachDown defines if you want to attach events to pointerdown
  32443. * @param attachMove defines if you want to attach events to pointermove
  32444. */
  32445. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32446. /**
  32447. * Detaches all event handlers
  32448. */
  32449. detachControl(): void;
  32450. /**
  32451. * Force the value of meshUnderPointer
  32452. * @param mesh defines the mesh to use
  32453. */
  32454. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32455. /**
  32456. * Gets the mesh under the pointer
  32457. * @returns a Mesh or null if no mesh is under the pointer
  32458. */
  32459. getPointerOverMesh(): Nullable<AbstractMesh>;
  32460. }
  32461. }
  32462. declare module "babylonjs/Animations/animationGroup" {
  32463. import { Animatable } from "babylonjs/Animations/animatable";
  32464. import { Animation } from "babylonjs/Animations/animation";
  32465. import { Scene, IDisposable } from "babylonjs/scene";
  32466. import { Observable } from "babylonjs/Misc/observable";
  32467. import { Nullable } from "babylonjs/types";
  32468. /**
  32469. * This class defines the direct association between an animation and a target
  32470. */
  32471. export class TargetedAnimation {
  32472. /**
  32473. * Animation to perform
  32474. */
  32475. animation: Animation;
  32476. /**
  32477. * Target to animate
  32478. */
  32479. target: any;
  32480. }
  32481. /**
  32482. * Use this class to create coordinated animations on multiple targets
  32483. */
  32484. export class AnimationGroup implements IDisposable {
  32485. /** The name of the animation group */
  32486. name: string;
  32487. private _scene;
  32488. private _targetedAnimations;
  32489. private _animatables;
  32490. private _from;
  32491. private _to;
  32492. private _isStarted;
  32493. private _isPaused;
  32494. private _speedRatio;
  32495. /**
  32496. * Gets or sets the unique id of the node
  32497. */
  32498. uniqueId: number;
  32499. /**
  32500. * This observable will notify when one animation have ended
  32501. */
  32502. onAnimationEndObservable: Observable<TargetedAnimation>;
  32503. /**
  32504. * Observer raised when one animation loops
  32505. */
  32506. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32507. /**
  32508. * This observable will notify when all animations have ended.
  32509. */
  32510. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32511. /**
  32512. * This observable will notify when all animations have paused.
  32513. */
  32514. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32515. /**
  32516. * This observable will notify when all animations are playing.
  32517. */
  32518. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32519. /**
  32520. * Gets the first frame
  32521. */
  32522. readonly from: number;
  32523. /**
  32524. * Gets the last frame
  32525. */
  32526. readonly to: number;
  32527. /**
  32528. * Define if the animations are started
  32529. */
  32530. readonly isStarted: boolean;
  32531. /**
  32532. * Gets a value indicating that the current group is playing
  32533. */
  32534. readonly isPlaying: boolean;
  32535. /**
  32536. * Gets or sets the speed ratio to use for all animations
  32537. */
  32538. /**
  32539. * Gets or sets the speed ratio to use for all animations
  32540. */
  32541. speedRatio: number;
  32542. /**
  32543. * Gets the targeted animations for this animation group
  32544. */
  32545. readonly targetedAnimations: Array<TargetedAnimation>;
  32546. /**
  32547. * returning the list of animatables controlled by this animation group.
  32548. */
  32549. readonly animatables: Array<Animatable>;
  32550. /**
  32551. * Instantiates a new Animation Group.
  32552. * This helps managing several animations at once.
  32553. * @see http://doc.babylonjs.com/how_to/group
  32554. * @param name Defines the name of the group
  32555. * @param scene Defines the scene the group belongs to
  32556. */
  32557. constructor(
  32558. /** The name of the animation group */
  32559. name: string, scene?: Nullable<Scene>);
  32560. /**
  32561. * Add an animation (with its target) in the group
  32562. * @param animation defines the animation we want to add
  32563. * @param target defines the target of the animation
  32564. * @returns the TargetedAnimation object
  32565. */
  32566. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32567. /**
  32568. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32569. * It can add constant keys at begin or end
  32570. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32571. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32572. * @returns the animation group
  32573. */
  32574. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32575. /**
  32576. * Start all animations on given targets
  32577. * @param loop defines if animations must loop
  32578. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32579. * @param from defines the from key (optional)
  32580. * @param to defines the to key (optional)
  32581. * @returns the current animation group
  32582. */
  32583. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32584. /**
  32585. * Pause all animations
  32586. * @returns the animation group
  32587. */
  32588. pause(): AnimationGroup;
  32589. /**
  32590. * Play all animations to initial state
  32591. * This function will start() the animations if they were not started or will restart() them if they were paused
  32592. * @param loop defines if animations must loop
  32593. * @returns the animation group
  32594. */
  32595. play(loop?: boolean): AnimationGroup;
  32596. /**
  32597. * Reset all animations to initial state
  32598. * @returns the animation group
  32599. */
  32600. reset(): AnimationGroup;
  32601. /**
  32602. * Restart animations from key 0
  32603. * @returns the animation group
  32604. */
  32605. restart(): AnimationGroup;
  32606. /**
  32607. * Stop all animations
  32608. * @returns the animation group
  32609. */
  32610. stop(): AnimationGroup;
  32611. /**
  32612. * Set animation weight for all animatables
  32613. * @param weight defines the weight to use
  32614. * @return the animationGroup
  32615. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32616. */
  32617. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32618. /**
  32619. * Synchronize and normalize all animatables with a source animatable
  32620. * @param root defines the root animatable to synchronize with
  32621. * @return the animationGroup
  32622. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32623. */
  32624. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32625. /**
  32626. * Goes to a specific frame in this animation group
  32627. * @param frame the frame number to go to
  32628. * @return the animationGroup
  32629. */
  32630. goToFrame(frame: number): AnimationGroup;
  32631. /**
  32632. * Dispose all associated resources
  32633. */
  32634. dispose(): void;
  32635. private _checkAnimationGroupEnded;
  32636. /**
  32637. * Clone the current animation group and returns a copy
  32638. * @param newName defines the name of the new group
  32639. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32640. * @returns the new aniamtion group
  32641. */
  32642. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32643. /**
  32644. * Returns a new AnimationGroup object parsed from the source provided.
  32645. * @param parsedAnimationGroup defines the source
  32646. * @param scene defines the scene that will receive the animationGroup
  32647. * @returns a new AnimationGroup
  32648. */
  32649. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32650. /**
  32651. * Returns the string "AnimationGroup"
  32652. * @returns "AnimationGroup"
  32653. */
  32654. getClassName(): string;
  32655. /**
  32656. * Creates a detailled string about the object
  32657. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32658. * @returns a string representing the object
  32659. */
  32660. toString(fullDetails?: boolean): string;
  32661. }
  32662. }
  32663. declare module "babylonjs/scene" {
  32664. import { Nullable } from "babylonjs/types";
  32665. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32666. import { Observable } from "babylonjs/Misc/observable";
  32667. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32668. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32669. import { Geometry } from "babylonjs/Meshes/geometry";
  32670. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32671. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32673. import { Mesh } from "babylonjs/Meshes/mesh";
  32674. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32675. import { Bone } from "babylonjs/Bones/bone";
  32676. import { Skeleton } from "babylonjs/Bones/skeleton";
  32677. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32678. import { Camera } from "babylonjs/Cameras/camera";
  32679. import { AbstractScene } from "babylonjs/abstractScene";
  32680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32681. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32682. import { Material } from "babylonjs/Materials/material";
  32683. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32684. import { Effect } from "babylonjs/Materials/effect";
  32685. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32686. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32687. import { Light } from "babylonjs/Lights/light";
  32688. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32689. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32690. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32691. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32692. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32693. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32694. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32695. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32696. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32697. import { Engine } from "babylonjs/Engines/engine";
  32698. import { Node } from "babylonjs/node";
  32699. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32700. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32701. import { WebRequest } from "babylonjs/Misc/webRequest";
  32702. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32703. import { Ray } from "babylonjs/Culling/ray";
  32704. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32705. import { Animation } from "babylonjs/Animations/animation";
  32706. import { Animatable } from "babylonjs/Animations/animatable";
  32707. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32708. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32709. import { Collider } from "babylonjs/Collisions/collider";
  32710. /**
  32711. * Define an interface for all classes that will hold resources
  32712. */
  32713. export interface IDisposable {
  32714. /**
  32715. * Releases all held resources
  32716. */
  32717. dispose(): void;
  32718. }
  32719. /** Interface defining initialization parameters for Scene class */
  32720. export interface SceneOptions {
  32721. /**
  32722. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32723. * It will improve performance when the number of geometries becomes important.
  32724. */
  32725. useGeometryUniqueIdsMap?: boolean;
  32726. /**
  32727. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32728. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32729. */
  32730. useMaterialMeshMap?: boolean;
  32731. /**
  32732. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32733. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32734. */
  32735. useClonedMeshhMap?: boolean;
  32736. }
  32737. /**
  32738. * Represents a scene to be rendered by the engine.
  32739. * @see http://doc.babylonjs.com/features/scene
  32740. */
  32741. export class Scene extends AbstractScene implements IAnimatable {
  32742. private static _uniqueIdCounter;
  32743. /** The fog is deactivated */
  32744. static readonly FOGMODE_NONE: number;
  32745. /** The fog density is following an exponential function */
  32746. static readonly FOGMODE_EXP: number;
  32747. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32748. static readonly FOGMODE_EXP2: number;
  32749. /** The fog density is following a linear function. */
  32750. static readonly FOGMODE_LINEAR: number;
  32751. /**
  32752. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32754. */
  32755. static MinDeltaTime: number;
  32756. /**
  32757. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32759. */
  32760. static MaxDeltaTime: number;
  32761. /**
  32762. * Factory used to create the default material.
  32763. * @param name The name of the material to create
  32764. * @param scene The scene to create the material for
  32765. * @returns The default material
  32766. */
  32767. static DefaultMaterialFactory(scene: Scene): Material;
  32768. /**
  32769. * Factory used to create the a collision coordinator.
  32770. * @returns The collision coordinator
  32771. */
  32772. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32773. /** @hidden */
  32774. _inputManager: InputManager;
  32775. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32776. cameraToUseForPointers: Nullable<Camera>;
  32777. /** @hidden */
  32778. readonly _isScene: boolean;
  32779. /**
  32780. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32781. */
  32782. autoClear: boolean;
  32783. /**
  32784. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32785. */
  32786. autoClearDepthAndStencil: boolean;
  32787. /**
  32788. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32789. */
  32790. clearColor: Color4;
  32791. /**
  32792. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32793. */
  32794. ambientColor: Color3;
  32795. /**
  32796. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32797. * It should only be one of the following (if not the default embedded one):
  32798. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32799. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32800. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32801. * The material properties need to be setup according to the type of texture in use.
  32802. */
  32803. environmentBRDFTexture: BaseTexture;
  32804. /** @hidden */
  32805. protected _environmentTexture: Nullable<BaseTexture>;
  32806. /**
  32807. * Texture used in all pbr material as the reflection texture.
  32808. * As in the majority of the scene they are the same (exception for multi room and so on),
  32809. * this is easier to reference from here than from all the materials.
  32810. */
  32811. /**
  32812. * Texture used in all pbr material as the reflection texture.
  32813. * As in the majority of the scene they are the same (exception for multi room and so on),
  32814. * this is easier to set here than in all the materials.
  32815. */
  32816. environmentTexture: Nullable<BaseTexture>;
  32817. /** @hidden */
  32818. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32819. /**
  32820. * Default image processing configuration used either in the rendering
  32821. * Forward main pass or through the imageProcessingPostProcess if present.
  32822. * As in the majority of the scene they are the same (exception for multi camera),
  32823. * this is easier to reference from here than from all the materials and post process.
  32824. *
  32825. * No setter as we it is a shared configuration, you can set the values instead.
  32826. */
  32827. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32828. private _forceWireframe;
  32829. /**
  32830. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32831. */
  32832. forceWireframe: boolean;
  32833. private _forcePointsCloud;
  32834. /**
  32835. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32836. */
  32837. forcePointsCloud: boolean;
  32838. /**
  32839. * Gets or sets the active clipplane 1
  32840. */
  32841. clipPlane: Nullable<Plane>;
  32842. /**
  32843. * Gets or sets the active clipplane 2
  32844. */
  32845. clipPlane2: Nullable<Plane>;
  32846. /**
  32847. * Gets or sets the active clipplane 3
  32848. */
  32849. clipPlane3: Nullable<Plane>;
  32850. /**
  32851. * Gets or sets the active clipplane 4
  32852. */
  32853. clipPlane4: Nullable<Plane>;
  32854. /**
  32855. * Gets or sets a boolean indicating if animations are enabled
  32856. */
  32857. animationsEnabled: boolean;
  32858. private _animationPropertiesOverride;
  32859. /**
  32860. * Gets or sets the animation properties override
  32861. */
  32862. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32863. /**
  32864. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32865. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32866. */
  32867. useConstantAnimationDeltaTime: boolean;
  32868. /**
  32869. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32870. * Please note that it requires to run a ray cast through the scene on every frame
  32871. */
  32872. constantlyUpdateMeshUnderPointer: boolean;
  32873. /**
  32874. * Defines the HTML cursor to use when hovering over interactive elements
  32875. */
  32876. hoverCursor: string;
  32877. /**
  32878. * Defines the HTML default cursor to use (empty by default)
  32879. */
  32880. defaultCursor: string;
  32881. /**
  32882. * This is used to call preventDefault() on pointer down
  32883. * in order to block unwanted artifacts like system double clicks
  32884. */
  32885. preventDefaultOnPointerDown: boolean;
  32886. /**
  32887. * This is used to call preventDefault() on pointer up
  32888. * in order to block unwanted artifacts like system double clicks
  32889. */
  32890. preventDefaultOnPointerUp: boolean;
  32891. /**
  32892. * Gets or sets user defined metadata
  32893. */
  32894. metadata: any;
  32895. /**
  32896. * For internal use only. Please do not use.
  32897. */
  32898. reservedDataStore: any;
  32899. /**
  32900. * Gets the name of the plugin used to load this scene (null by default)
  32901. */
  32902. loadingPluginName: string;
  32903. /**
  32904. * Use this array to add regular expressions used to disable offline support for specific urls
  32905. */
  32906. disableOfflineSupportExceptionRules: RegExp[];
  32907. /**
  32908. * An event triggered when the scene is disposed.
  32909. */
  32910. onDisposeObservable: Observable<Scene>;
  32911. private _onDisposeObserver;
  32912. /** Sets a function to be executed when this scene is disposed. */
  32913. onDispose: () => void;
  32914. /**
  32915. * An event triggered before rendering the scene (right after animations and physics)
  32916. */
  32917. onBeforeRenderObservable: Observable<Scene>;
  32918. private _onBeforeRenderObserver;
  32919. /** Sets a function to be executed before rendering this scene */
  32920. beforeRender: Nullable<() => void>;
  32921. /**
  32922. * An event triggered after rendering the scene
  32923. */
  32924. onAfterRenderObservable: Observable<Scene>;
  32925. private _onAfterRenderObserver;
  32926. /** Sets a function to be executed after rendering this scene */
  32927. afterRender: Nullable<() => void>;
  32928. /**
  32929. * An event triggered before animating the scene
  32930. */
  32931. onBeforeAnimationsObservable: Observable<Scene>;
  32932. /**
  32933. * An event triggered after animations processing
  32934. */
  32935. onAfterAnimationsObservable: Observable<Scene>;
  32936. /**
  32937. * An event triggered before draw calls are ready to be sent
  32938. */
  32939. onBeforeDrawPhaseObservable: Observable<Scene>;
  32940. /**
  32941. * An event triggered after draw calls have been sent
  32942. */
  32943. onAfterDrawPhaseObservable: Observable<Scene>;
  32944. /**
  32945. * An event triggered when the scene is ready
  32946. */
  32947. onReadyObservable: Observable<Scene>;
  32948. /**
  32949. * An event triggered before rendering a camera
  32950. */
  32951. onBeforeCameraRenderObservable: Observable<Camera>;
  32952. private _onBeforeCameraRenderObserver;
  32953. /** Sets a function to be executed before rendering a camera*/
  32954. beforeCameraRender: () => void;
  32955. /**
  32956. * An event triggered after rendering a camera
  32957. */
  32958. onAfterCameraRenderObservable: Observable<Camera>;
  32959. private _onAfterCameraRenderObserver;
  32960. /** Sets a function to be executed after rendering a camera*/
  32961. afterCameraRender: () => void;
  32962. /**
  32963. * An event triggered when active meshes evaluation is about to start
  32964. */
  32965. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32966. /**
  32967. * An event triggered when active meshes evaluation is done
  32968. */
  32969. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32970. /**
  32971. * An event triggered when particles rendering is about to start
  32972. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32973. */
  32974. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32975. /**
  32976. * An event triggered when particles rendering is done
  32977. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32978. */
  32979. onAfterParticlesRenderingObservable: Observable<Scene>;
  32980. /**
  32981. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32982. */
  32983. onDataLoadedObservable: Observable<Scene>;
  32984. /**
  32985. * An event triggered when a camera is created
  32986. */
  32987. onNewCameraAddedObservable: Observable<Camera>;
  32988. /**
  32989. * An event triggered when a camera is removed
  32990. */
  32991. onCameraRemovedObservable: Observable<Camera>;
  32992. /**
  32993. * An event triggered when a light is created
  32994. */
  32995. onNewLightAddedObservable: Observable<Light>;
  32996. /**
  32997. * An event triggered when a light is removed
  32998. */
  32999. onLightRemovedObservable: Observable<Light>;
  33000. /**
  33001. * An event triggered when a geometry is created
  33002. */
  33003. onNewGeometryAddedObservable: Observable<Geometry>;
  33004. /**
  33005. * An event triggered when a geometry is removed
  33006. */
  33007. onGeometryRemovedObservable: Observable<Geometry>;
  33008. /**
  33009. * An event triggered when a transform node is created
  33010. */
  33011. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33012. /**
  33013. * An event triggered when a transform node is removed
  33014. */
  33015. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33016. /**
  33017. * An event triggered when a mesh is created
  33018. */
  33019. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33020. /**
  33021. * An event triggered when a mesh is removed
  33022. */
  33023. onMeshRemovedObservable: Observable<AbstractMesh>;
  33024. /**
  33025. * An event triggered when a skeleton is created
  33026. */
  33027. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33028. /**
  33029. * An event triggered when a skeleton is removed
  33030. */
  33031. onSkeletonRemovedObservable: Observable<Skeleton>;
  33032. /**
  33033. * An event triggered when a material is created
  33034. */
  33035. onNewMaterialAddedObservable: Observable<Material>;
  33036. /**
  33037. * An event triggered when a material is removed
  33038. */
  33039. onMaterialRemovedObservable: Observable<Material>;
  33040. /**
  33041. * An event triggered when a texture is created
  33042. */
  33043. onNewTextureAddedObservable: Observable<BaseTexture>;
  33044. /**
  33045. * An event triggered when a texture is removed
  33046. */
  33047. onTextureRemovedObservable: Observable<BaseTexture>;
  33048. /**
  33049. * An event triggered when render targets are about to be rendered
  33050. * Can happen multiple times per frame.
  33051. */
  33052. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33053. /**
  33054. * An event triggered when render targets were rendered.
  33055. * Can happen multiple times per frame.
  33056. */
  33057. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33058. /**
  33059. * An event triggered before calculating deterministic simulation step
  33060. */
  33061. onBeforeStepObservable: Observable<Scene>;
  33062. /**
  33063. * An event triggered after calculating deterministic simulation step
  33064. */
  33065. onAfterStepObservable: Observable<Scene>;
  33066. /**
  33067. * An event triggered when the activeCamera property is updated
  33068. */
  33069. onActiveCameraChanged: Observable<Scene>;
  33070. /**
  33071. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33072. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33073. * 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)
  33074. */
  33075. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33076. /**
  33077. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33078. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33079. * 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)
  33080. */
  33081. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33082. /**
  33083. * This Observable will when a mesh has been imported into the scene.
  33084. */
  33085. onMeshImportedObservable: Observable<AbstractMesh>;
  33086. /**
  33087. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33088. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33089. */
  33090. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33091. /** @hidden */
  33092. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33093. /**
  33094. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33095. */
  33096. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33097. /**
  33098. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33099. */
  33100. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33101. /**
  33102. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33103. */
  33104. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33105. /** Callback called when a pointer move is detected */
  33106. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33107. /** Callback called when a pointer down is detected */
  33108. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33109. /** Callback called when a pointer up is detected */
  33110. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33111. /** Callback called when a pointer pick is detected */
  33112. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33113. /**
  33114. * 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).
  33115. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33116. */
  33117. onPrePointerObservable: Observable<PointerInfoPre>;
  33118. /**
  33119. * Observable event triggered each time an input event is received from the rendering canvas
  33120. */
  33121. onPointerObservable: Observable<PointerInfo>;
  33122. /**
  33123. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33124. */
  33125. readonly unTranslatedPointer: Vector2;
  33126. /**
  33127. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33128. */
  33129. static DragMovementThreshold: number;
  33130. /**
  33131. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33132. */
  33133. static LongPressDelay: number;
  33134. /**
  33135. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33136. */
  33137. static DoubleClickDelay: number;
  33138. /** If you need to check double click without raising a single click at first click, enable this flag */
  33139. static ExclusiveDoubleClickMode: boolean;
  33140. /** @hidden */
  33141. _mirroredCameraPosition: Nullable<Vector3>;
  33142. /**
  33143. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33144. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33145. */
  33146. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33147. /**
  33148. * Observable event triggered each time an keyboard event is received from the hosting window
  33149. */
  33150. onKeyboardObservable: Observable<KeyboardInfo>;
  33151. private _useRightHandedSystem;
  33152. /**
  33153. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33154. */
  33155. useRightHandedSystem: boolean;
  33156. private _timeAccumulator;
  33157. private _currentStepId;
  33158. private _currentInternalStep;
  33159. /**
  33160. * Sets the step Id used by deterministic lock step
  33161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33162. * @param newStepId defines the step Id
  33163. */
  33164. setStepId(newStepId: number): void;
  33165. /**
  33166. * Gets the step Id used by deterministic lock step
  33167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33168. * @returns the step Id
  33169. */
  33170. getStepId(): number;
  33171. /**
  33172. * Gets the internal step used by deterministic lock step
  33173. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33174. * @returns the internal step
  33175. */
  33176. getInternalStep(): number;
  33177. private _fogEnabled;
  33178. /**
  33179. * Gets or sets a boolean indicating if fog is enabled on this scene
  33180. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33181. * (Default is true)
  33182. */
  33183. fogEnabled: boolean;
  33184. private _fogMode;
  33185. /**
  33186. * Gets or sets the fog mode to use
  33187. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33188. * | mode | value |
  33189. * | --- | --- |
  33190. * | FOGMODE_NONE | 0 |
  33191. * | FOGMODE_EXP | 1 |
  33192. * | FOGMODE_EXP2 | 2 |
  33193. * | FOGMODE_LINEAR | 3 |
  33194. */
  33195. fogMode: number;
  33196. /**
  33197. * Gets or sets the fog color to use
  33198. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33199. * (Default is Color3(0.2, 0.2, 0.3))
  33200. */
  33201. fogColor: Color3;
  33202. /**
  33203. * Gets or sets the fog density to use
  33204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33205. * (Default is 0.1)
  33206. */
  33207. fogDensity: number;
  33208. /**
  33209. * Gets or sets the fog start distance to use
  33210. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33211. * (Default is 0)
  33212. */
  33213. fogStart: number;
  33214. /**
  33215. * Gets or sets the fog end distance to use
  33216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33217. * (Default is 1000)
  33218. */
  33219. fogEnd: number;
  33220. private _shadowsEnabled;
  33221. /**
  33222. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33223. */
  33224. shadowsEnabled: boolean;
  33225. private _lightsEnabled;
  33226. /**
  33227. * Gets or sets a boolean indicating if lights are enabled on this scene
  33228. */
  33229. lightsEnabled: boolean;
  33230. /** All of the active cameras added to this scene. */
  33231. activeCameras: Camera[];
  33232. /** @hidden */
  33233. _activeCamera: Nullable<Camera>;
  33234. /** Gets or sets the current active camera */
  33235. activeCamera: Nullable<Camera>;
  33236. private _defaultMaterial;
  33237. /** The default material used on meshes when no material is affected */
  33238. /** The default material used on meshes when no material is affected */
  33239. defaultMaterial: Material;
  33240. private _texturesEnabled;
  33241. /**
  33242. * Gets or sets a boolean indicating if textures are enabled on this scene
  33243. */
  33244. texturesEnabled: boolean;
  33245. /**
  33246. * Gets or sets a boolean indicating if particles are enabled on this scene
  33247. */
  33248. particlesEnabled: boolean;
  33249. /**
  33250. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33251. */
  33252. spritesEnabled: boolean;
  33253. private _skeletonsEnabled;
  33254. /**
  33255. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33256. */
  33257. skeletonsEnabled: boolean;
  33258. /**
  33259. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33260. */
  33261. lensFlaresEnabled: boolean;
  33262. /**
  33263. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33264. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33265. */
  33266. collisionsEnabled: boolean;
  33267. private _collisionCoordinator;
  33268. /** @hidden */
  33269. readonly collisionCoordinator: ICollisionCoordinator;
  33270. /**
  33271. * Defines the gravity applied to this scene (used only for collisions)
  33272. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33273. */
  33274. gravity: Vector3;
  33275. /**
  33276. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33277. */
  33278. postProcessesEnabled: boolean;
  33279. /**
  33280. * The list of postprocesses added to the scene
  33281. */
  33282. postProcesses: PostProcess[];
  33283. /**
  33284. * Gets the current postprocess manager
  33285. */
  33286. postProcessManager: PostProcessManager;
  33287. /**
  33288. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33289. */
  33290. renderTargetsEnabled: boolean;
  33291. /**
  33292. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33293. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33294. */
  33295. dumpNextRenderTargets: boolean;
  33296. /**
  33297. * The list of user defined render targets added to the scene
  33298. */
  33299. customRenderTargets: RenderTargetTexture[];
  33300. /**
  33301. * Defines if texture loading must be delayed
  33302. * If true, textures will only be loaded when they need to be rendered
  33303. */
  33304. useDelayedTextureLoading: boolean;
  33305. /**
  33306. * Gets the list of meshes imported to the scene through SceneLoader
  33307. */
  33308. importedMeshesFiles: String[];
  33309. /**
  33310. * Gets or sets a boolean indicating if probes are enabled on this scene
  33311. */
  33312. probesEnabled: boolean;
  33313. /**
  33314. * Gets or sets the current offline provider to use to store scene data
  33315. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33316. */
  33317. offlineProvider: IOfflineProvider;
  33318. /**
  33319. * Gets or sets the action manager associated with the scene
  33320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33321. */
  33322. actionManager: AbstractActionManager;
  33323. private _meshesForIntersections;
  33324. /**
  33325. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33326. */
  33327. proceduralTexturesEnabled: boolean;
  33328. private _engine;
  33329. private _totalVertices;
  33330. /** @hidden */
  33331. _activeIndices: PerfCounter;
  33332. /** @hidden */
  33333. _activeParticles: PerfCounter;
  33334. /** @hidden */
  33335. _activeBones: PerfCounter;
  33336. private _animationRatio;
  33337. /** @hidden */
  33338. _animationTimeLast: number;
  33339. /** @hidden */
  33340. _animationTime: number;
  33341. /**
  33342. * Gets or sets a general scale for animation speed
  33343. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33344. */
  33345. animationTimeScale: number;
  33346. /** @hidden */
  33347. _cachedMaterial: Nullable<Material>;
  33348. /** @hidden */
  33349. _cachedEffect: Nullable<Effect>;
  33350. /** @hidden */
  33351. _cachedVisibility: Nullable<number>;
  33352. private _renderId;
  33353. private _frameId;
  33354. private _executeWhenReadyTimeoutId;
  33355. private _intermediateRendering;
  33356. private _viewUpdateFlag;
  33357. private _projectionUpdateFlag;
  33358. /** @hidden */
  33359. _toBeDisposed: Nullable<IDisposable>[];
  33360. private _activeRequests;
  33361. /** @hidden */
  33362. _pendingData: any[];
  33363. private _isDisposed;
  33364. /**
  33365. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33366. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33367. */
  33368. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33369. private _activeMeshes;
  33370. private _processedMaterials;
  33371. private _renderTargets;
  33372. /** @hidden */
  33373. _activeParticleSystems: SmartArray<IParticleSystem>;
  33374. private _activeSkeletons;
  33375. private _softwareSkinnedMeshes;
  33376. private _renderingManager;
  33377. /** @hidden */
  33378. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33379. private _transformMatrix;
  33380. private _sceneUbo;
  33381. /** @hidden */
  33382. _viewMatrix: Matrix;
  33383. private _projectionMatrix;
  33384. /** @hidden */
  33385. _forcedViewPosition: Nullable<Vector3>;
  33386. /** @hidden */
  33387. _frustumPlanes: Plane[];
  33388. /**
  33389. * Gets the list of frustum planes (built from the active camera)
  33390. */
  33391. readonly frustumPlanes: Plane[];
  33392. /**
  33393. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33394. * This is useful if there are more lights that the maximum simulteanous authorized
  33395. */
  33396. requireLightSorting: boolean;
  33397. /** @hidden */
  33398. readonly useMaterialMeshMap: boolean;
  33399. /** @hidden */
  33400. readonly useClonedMeshhMap: boolean;
  33401. private _externalData;
  33402. private _uid;
  33403. /**
  33404. * @hidden
  33405. * Backing store of defined scene components.
  33406. */
  33407. _components: ISceneComponent[];
  33408. /**
  33409. * @hidden
  33410. * Backing store of defined scene components.
  33411. */
  33412. _serializableComponents: ISceneSerializableComponent[];
  33413. /**
  33414. * List of components to register on the next registration step.
  33415. */
  33416. private _transientComponents;
  33417. /**
  33418. * Registers the transient components if needed.
  33419. */
  33420. private _registerTransientComponents;
  33421. /**
  33422. * @hidden
  33423. * Add a component to the scene.
  33424. * Note that the ccomponent could be registered on th next frame if this is called after
  33425. * the register component stage.
  33426. * @param component Defines the component to add to the scene
  33427. */
  33428. _addComponent(component: ISceneComponent): void;
  33429. /**
  33430. * @hidden
  33431. * Gets a component from the scene.
  33432. * @param name defines the name of the component to retrieve
  33433. * @returns the component or null if not present
  33434. */
  33435. _getComponent(name: string): Nullable<ISceneComponent>;
  33436. /**
  33437. * @hidden
  33438. * Defines the actions happening before camera updates.
  33439. */
  33440. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33441. /**
  33442. * @hidden
  33443. * Defines the actions happening before clear the canvas.
  33444. */
  33445. _beforeClearStage: Stage<SimpleStageAction>;
  33446. /**
  33447. * @hidden
  33448. * Defines the actions when collecting render targets for the frame.
  33449. */
  33450. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33451. /**
  33452. * @hidden
  33453. * Defines the actions happening for one camera in the frame.
  33454. */
  33455. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33456. /**
  33457. * @hidden
  33458. * Defines the actions happening during the per mesh ready checks.
  33459. */
  33460. _isReadyForMeshStage: Stage<MeshStageAction>;
  33461. /**
  33462. * @hidden
  33463. * Defines the actions happening before evaluate active mesh checks.
  33464. */
  33465. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33466. /**
  33467. * @hidden
  33468. * Defines the actions happening during the evaluate sub mesh checks.
  33469. */
  33470. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33471. /**
  33472. * @hidden
  33473. * Defines the actions happening during the active mesh stage.
  33474. */
  33475. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33476. /**
  33477. * @hidden
  33478. * Defines the actions happening during the per camera render target step.
  33479. */
  33480. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33481. /**
  33482. * @hidden
  33483. * Defines the actions happening just before the active camera is drawing.
  33484. */
  33485. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33486. /**
  33487. * @hidden
  33488. * Defines the actions happening just before a render target is drawing.
  33489. */
  33490. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33491. /**
  33492. * @hidden
  33493. * Defines the actions happening just before a rendering group is drawing.
  33494. */
  33495. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33496. /**
  33497. * @hidden
  33498. * Defines the actions happening just before a mesh is drawing.
  33499. */
  33500. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33501. /**
  33502. * @hidden
  33503. * Defines the actions happening just after a mesh has been drawn.
  33504. */
  33505. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33506. /**
  33507. * @hidden
  33508. * Defines the actions happening just after a rendering group has been drawn.
  33509. */
  33510. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33511. /**
  33512. * @hidden
  33513. * Defines the actions happening just after the active camera has been drawn.
  33514. */
  33515. _afterCameraDrawStage: Stage<CameraStageAction>;
  33516. /**
  33517. * @hidden
  33518. * Defines the actions happening just after a render target has been drawn.
  33519. */
  33520. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33521. /**
  33522. * @hidden
  33523. * Defines the actions happening just after rendering all cameras and computing intersections.
  33524. */
  33525. _afterRenderStage: Stage<SimpleStageAction>;
  33526. /**
  33527. * @hidden
  33528. * Defines the actions happening when a pointer move event happens.
  33529. */
  33530. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33531. /**
  33532. * @hidden
  33533. * Defines the actions happening when a pointer down event happens.
  33534. */
  33535. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33536. /**
  33537. * @hidden
  33538. * Defines the actions happening when a pointer up event happens.
  33539. */
  33540. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33541. /**
  33542. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33543. */
  33544. private geometriesByUniqueId;
  33545. /**
  33546. * Creates a new Scene
  33547. * @param engine defines the engine to use to render this scene
  33548. * @param options defines the scene options
  33549. */
  33550. constructor(engine: Engine, options?: SceneOptions);
  33551. /**
  33552. * Gets a string idenfifying the name of the class
  33553. * @returns "Scene" string
  33554. */
  33555. getClassName(): string;
  33556. private _defaultMeshCandidates;
  33557. /**
  33558. * @hidden
  33559. */
  33560. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33561. private _defaultSubMeshCandidates;
  33562. /**
  33563. * @hidden
  33564. */
  33565. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33566. /**
  33567. * Sets the default candidate providers for the scene.
  33568. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33569. * and getCollidingSubMeshCandidates to their default function
  33570. */
  33571. setDefaultCandidateProviders(): void;
  33572. /**
  33573. * Gets the mesh that is currently under the pointer
  33574. */
  33575. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33576. /**
  33577. * Gets or sets the current on-screen X position of the pointer
  33578. */
  33579. pointerX: number;
  33580. /**
  33581. * Gets or sets the current on-screen Y position of the pointer
  33582. */
  33583. pointerY: number;
  33584. /**
  33585. * Gets the cached material (ie. the latest rendered one)
  33586. * @returns the cached material
  33587. */
  33588. getCachedMaterial(): Nullable<Material>;
  33589. /**
  33590. * Gets the cached effect (ie. the latest rendered one)
  33591. * @returns the cached effect
  33592. */
  33593. getCachedEffect(): Nullable<Effect>;
  33594. /**
  33595. * Gets the cached visibility state (ie. the latest rendered one)
  33596. * @returns the cached visibility state
  33597. */
  33598. getCachedVisibility(): Nullable<number>;
  33599. /**
  33600. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33601. * @param material defines the current material
  33602. * @param effect defines the current effect
  33603. * @param visibility defines the current visibility state
  33604. * @returns true if one parameter is not cached
  33605. */
  33606. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33607. /**
  33608. * Gets the engine associated with the scene
  33609. * @returns an Engine
  33610. */
  33611. getEngine(): Engine;
  33612. /**
  33613. * Gets the total number of vertices rendered per frame
  33614. * @returns the total number of vertices rendered per frame
  33615. */
  33616. getTotalVertices(): number;
  33617. /**
  33618. * Gets the performance counter for total vertices
  33619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33620. */
  33621. readonly totalVerticesPerfCounter: PerfCounter;
  33622. /**
  33623. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33624. * @returns the total number of active indices rendered per frame
  33625. */
  33626. getActiveIndices(): number;
  33627. /**
  33628. * Gets the performance counter for active indices
  33629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33630. */
  33631. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33632. /**
  33633. * Gets the total number of active particles rendered per frame
  33634. * @returns the total number of active particles rendered per frame
  33635. */
  33636. getActiveParticles(): number;
  33637. /**
  33638. * Gets the performance counter for active particles
  33639. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33640. */
  33641. readonly activeParticlesPerfCounter: PerfCounter;
  33642. /**
  33643. * Gets the total number of active bones rendered per frame
  33644. * @returns the total number of active bones rendered per frame
  33645. */
  33646. getActiveBones(): number;
  33647. /**
  33648. * Gets the performance counter for active bones
  33649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33650. */
  33651. readonly activeBonesPerfCounter: PerfCounter;
  33652. /**
  33653. * Gets the array of active meshes
  33654. * @returns an array of AbstractMesh
  33655. */
  33656. getActiveMeshes(): SmartArray<AbstractMesh>;
  33657. /**
  33658. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33659. * @returns a number
  33660. */
  33661. getAnimationRatio(): number;
  33662. /**
  33663. * Gets an unique Id for the current render phase
  33664. * @returns a number
  33665. */
  33666. getRenderId(): number;
  33667. /**
  33668. * Gets an unique Id for the current frame
  33669. * @returns a number
  33670. */
  33671. getFrameId(): number;
  33672. /** Call this function if you want to manually increment the render Id*/
  33673. incrementRenderId(): void;
  33674. private _createUbo;
  33675. /**
  33676. * Use this method to simulate a pointer move on a mesh
  33677. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33678. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33679. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33680. * @returns the current scene
  33681. */
  33682. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33683. /**
  33684. * Use this method to simulate a pointer down on a mesh
  33685. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33686. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33687. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33688. * @returns the current scene
  33689. */
  33690. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33691. /**
  33692. * Use this method to simulate a pointer up on a mesh
  33693. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33694. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33695. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33696. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33697. * @returns the current scene
  33698. */
  33699. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33700. /**
  33701. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33702. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33703. * @returns true if the pointer was captured
  33704. */
  33705. isPointerCaptured(pointerId?: number): boolean;
  33706. /**
  33707. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33708. * @param attachUp defines if you want to attach events to pointerup
  33709. * @param attachDown defines if you want to attach events to pointerdown
  33710. * @param attachMove defines if you want to attach events to pointermove
  33711. */
  33712. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33713. /** Detaches all event handlers*/
  33714. detachControl(): void;
  33715. /**
  33716. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33717. * Delay loaded resources are not taking in account
  33718. * @return true if all required resources are ready
  33719. */
  33720. isReady(): boolean;
  33721. /** Resets all cached information relative to material (including effect and visibility) */
  33722. resetCachedMaterial(): void;
  33723. /**
  33724. * Registers a function to be called before every frame render
  33725. * @param func defines the function to register
  33726. */
  33727. registerBeforeRender(func: () => void): void;
  33728. /**
  33729. * Unregisters a function called before every frame render
  33730. * @param func defines the function to unregister
  33731. */
  33732. unregisterBeforeRender(func: () => void): void;
  33733. /**
  33734. * Registers a function to be called after every frame render
  33735. * @param func defines the function to register
  33736. */
  33737. registerAfterRender(func: () => void): void;
  33738. /**
  33739. * Unregisters a function called after every frame render
  33740. * @param func defines the function to unregister
  33741. */
  33742. unregisterAfterRender(func: () => void): void;
  33743. private _executeOnceBeforeRender;
  33744. /**
  33745. * The provided function will run before render once and will be disposed afterwards.
  33746. * A timeout delay can be provided so that the function will be executed in N ms.
  33747. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33748. * @param func The function to be executed.
  33749. * @param timeout optional delay in ms
  33750. */
  33751. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33752. /** @hidden */
  33753. _addPendingData(data: any): void;
  33754. /** @hidden */
  33755. _removePendingData(data: any): void;
  33756. /**
  33757. * Returns the number of items waiting to be loaded
  33758. * @returns the number of items waiting to be loaded
  33759. */
  33760. getWaitingItemsCount(): number;
  33761. /**
  33762. * Returns a boolean indicating if the scene is still loading data
  33763. */
  33764. readonly isLoading: boolean;
  33765. /**
  33766. * Registers a function to be executed when the scene is ready
  33767. * @param {Function} func - the function to be executed
  33768. */
  33769. executeWhenReady(func: () => void): void;
  33770. /**
  33771. * Returns a promise that resolves when the scene is ready
  33772. * @returns A promise that resolves when the scene is ready
  33773. */
  33774. whenReadyAsync(): Promise<void>;
  33775. /** @hidden */
  33776. _checkIsReady(): void;
  33777. /**
  33778. * Gets all animatable attached to the scene
  33779. */
  33780. readonly animatables: Animatable[];
  33781. /**
  33782. * Resets the last animation time frame.
  33783. * Useful to override when animations start running when loading a scene for the first time.
  33784. */
  33785. resetLastAnimationTimeFrame(): void;
  33786. /**
  33787. * Gets the current view matrix
  33788. * @returns a Matrix
  33789. */
  33790. getViewMatrix(): Matrix;
  33791. /**
  33792. * Gets the current projection matrix
  33793. * @returns a Matrix
  33794. */
  33795. getProjectionMatrix(): Matrix;
  33796. /**
  33797. * Gets the current transform matrix
  33798. * @returns a Matrix made of View * Projection
  33799. */
  33800. getTransformMatrix(): Matrix;
  33801. /**
  33802. * Sets the current transform matrix
  33803. * @param viewL defines the View matrix to use
  33804. * @param projectionL defines the Projection matrix to use
  33805. * @param viewR defines the right View matrix to use (if provided)
  33806. * @param projectionR defines the right Projection matrix to use (if provided)
  33807. */
  33808. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33809. /**
  33810. * Gets the uniform buffer used to store scene data
  33811. * @returns a UniformBuffer
  33812. */
  33813. getSceneUniformBuffer(): UniformBuffer;
  33814. /**
  33815. * Gets an unique (relatively to the current scene) Id
  33816. * @returns an unique number for the scene
  33817. */
  33818. getUniqueId(): number;
  33819. /**
  33820. * Add a mesh to the list of scene's meshes
  33821. * @param newMesh defines the mesh to add
  33822. * @param recursive if all child meshes should also be added to the scene
  33823. */
  33824. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33825. /**
  33826. * Remove a mesh for the list of scene's meshes
  33827. * @param toRemove defines the mesh to remove
  33828. * @param recursive if all child meshes should also be removed from the scene
  33829. * @returns the index where the mesh was in the mesh list
  33830. */
  33831. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33832. /**
  33833. * Add a transform node to the list of scene's transform nodes
  33834. * @param newTransformNode defines the transform node to add
  33835. */
  33836. addTransformNode(newTransformNode: TransformNode): void;
  33837. /**
  33838. * Remove a transform node for the list of scene's transform nodes
  33839. * @param toRemove defines the transform node to remove
  33840. * @returns the index where the transform node was in the transform node list
  33841. */
  33842. removeTransformNode(toRemove: TransformNode): number;
  33843. /**
  33844. * Remove a skeleton for the list of scene's skeletons
  33845. * @param toRemove defines the skeleton to remove
  33846. * @returns the index where the skeleton was in the skeleton list
  33847. */
  33848. removeSkeleton(toRemove: Skeleton): number;
  33849. /**
  33850. * Remove a morph target for the list of scene's morph targets
  33851. * @param toRemove defines the morph target to remove
  33852. * @returns the index where the morph target was in the morph target list
  33853. */
  33854. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33855. /**
  33856. * Remove a light for the list of scene's lights
  33857. * @param toRemove defines the light to remove
  33858. * @returns the index where the light was in the light list
  33859. */
  33860. removeLight(toRemove: Light): number;
  33861. /**
  33862. * Remove a camera for the list of scene's cameras
  33863. * @param toRemove defines the camera to remove
  33864. * @returns the index where the camera was in the camera list
  33865. */
  33866. removeCamera(toRemove: Camera): number;
  33867. /**
  33868. * Remove a particle system for the list of scene's particle systems
  33869. * @param toRemove defines the particle system to remove
  33870. * @returns the index where the particle system was in the particle system list
  33871. */
  33872. removeParticleSystem(toRemove: IParticleSystem): number;
  33873. /**
  33874. * Remove a animation for the list of scene's animations
  33875. * @param toRemove defines the animation to remove
  33876. * @returns the index where the animation was in the animation list
  33877. */
  33878. removeAnimation(toRemove: Animation): number;
  33879. /**
  33880. * Removes the given animation group from this scene.
  33881. * @param toRemove The animation group to remove
  33882. * @returns The index of the removed animation group
  33883. */
  33884. removeAnimationGroup(toRemove: AnimationGroup): number;
  33885. /**
  33886. * Removes the given multi-material from this scene.
  33887. * @param toRemove The multi-material to remove
  33888. * @returns The index of the removed multi-material
  33889. */
  33890. removeMultiMaterial(toRemove: MultiMaterial): number;
  33891. /**
  33892. * Removes the given material from this scene.
  33893. * @param toRemove The material to remove
  33894. * @returns The index of the removed material
  33895. */
  33896. removeMaterial(toRemove: Material): number;
  33897. /**
  33898. * Removes the given action manager from this scene.
  33899. * @param toRemove The action manager to remove
  33900. * @returns The index of the removed action manager
  33901. */
  33902. removeActionManager(toRemove: AbstractActionManager): number;
  33903. /**
  33904. * Removes the given texture from this scene.
  33905. * @param toRemove The texture to remove
  33906. * @returns The index of the removed texture
  33907. */
  33908. removeTexture(toRemove: BaseTexture): number;
  33909. /**
  33910. * Adds the given light to this scene
  33911. * @param newLight The light to add
  33912. */
  33913. addLight(newLight: Light): void;
  33914. /**
  33915. * Sorts the list list based on light priorities
  33916. */
  33917. sortLightsByPriority(): void;
  33918. /**
  33919. * Adds the given camera to this scene
  33920. * @param newCamera The camera to add
  33921. */
  33922. addCamera(newCamera: Camera): void;
  33923. /**
  33924. * Adds the given skeleton to this scene
  33925. * @param newSkeleton The skeleton to add
  33926. */
  33927. addSkeleton(newSkeleton: Skeleton): void;
  33928. /**
  33929. * Adds the given particle system to this scene
  33930. * @param newParticleSystem The particle system to add
  33931. */
  33932. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33933. /**
  33934. * Adds the given animation to this scene
  33935. * @param newAnimation The animation to add
  33936. */
  33937. addAnimation(newAnimation: Animation): void;
  33938. /**
  33939. * Adds the given animation group to this scene.
  33940. * @param newAnimationGroup The animation group to add
  33941. */
  33942. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33943. /**
  33944. * Adds the given multi-material to this scene
  33945. * @param newMultiMaterial The multi-material to add
  33946. */
  33947. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33948. /**
  33949. * Adds the given material to this scene
  33950. * @param newMaterial The material to add
  33951. */
  33952. addMaterial(newMaterial: Material): void;
  33953. /**
  33954. * Adds the given morph target to this scene
  33955. * @param newMorphTargetManager The morph target to add
  33956. */
  33957. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33958. /**
  33959. * Adds the given geometry to this scene
  33960. * @param newGeometry The geometry to add
  33961. */
  33962. addGeometry(newGeometry: Geometry): void;
  33963. /**
  33964. * Adds the given action manager to this scene
  33965. * @param newActionManager The action manager to add
  33966. */
  33967. addActionManager(newActionManager: AbstractActionManager): void;
  33968. /**
  33969. * Adds the given texture to this scene.
  33970. * @param newTexture The texture to add
  33971. */
  33972. addTexture(newTexture: BaseTexture): void;
  33973. /**
  33974. * Switch active camera
  33975. * @param newCamera defines the new active camera
  33976. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33977. */
  33978. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33979. /**
  33980. * sets the active camera of the scene using its ID
  33981. * @param id defines the camera's ID
  33982. * @return the new active camera or null if none found.
  33983. */
  33984. setActiveCameraByID(id: string): Nullable<Camera>;
  33985. /**
  33986. * sets the active camera of the scene using its name
  33987. * @param name defines the camera's name
  33988. * @returns the new active camera or null if none found.
  33989. */
  33990. setActiveCameraByName(name: string): Nullable<Camera>;
  33991. /**
  33992. * get an animation group using its name
  33993. * @param name defines the material's name
  33994. * @return the animation group or null if none found.
  33995. */
  33996. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33997. /**
  33998. * Get a material using its unique id
  33999. * @param uniqueId defines the material's unique id
  34000. * @return the material or null if none found.
  34001. */
  34002. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34003. /**
  34004. * get a material using its id
  34005. * @param id defines the material's ID
  34006. * @return the material or null if none found.
  34007. */
  34008. getMaterialByID(id: string): Nullable<Material>;
  34009. /**
  34010. * Gets a material using its name
  34011. * @param name defines the material's name
  34012. * @return the material or null if none found.
  34013. */
  34014. getMaterialByName(name: string): Nullable<Material>;
  34015. /**
  34016. * Gets a camera using its id
  34017. * @param id defines the id to look for
  34018. * @returns the camera or null if not found
  34019. */
  34020. getCameraByID(id: string): Nullable<Camera>;
  34021. /**
  34022. * Gets a camera using its unique id
  34023. * @param uniqueId defines the unique id to look for
  34024. * @returns the camera or null if not found
  34025. */
  34026. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34027. /**
  34028. * Gets a camera using its name
  34029. * @param name defines the camera's name
  34030. * @return the camera or null if none found.
  34031. */
  34032. getCameraByName(name: string): Nullable<Camera>;
  34033. /**
  34034. * Gets a bone using its id
  34035. * @param id defines the bone's id
  34036. * @return the bone or null if not found
  34037. */
  34038. getBoneByID(id: string): Nullable<Bone>;
  34039. /**
  34040. * Gets a bone using its id
  34041. * @param name defines the bone's name
  34042. * @return the bone or null if not found
  34043. */
  34044. getBoneByName(name: string): Nullable<Bone>;
  34045. /**
  34046. * Gets a light node using its name
  34047. * @param name defines the the light's name
  34048. * @return the light or null if none found.
  34049. */
  34050. getLightByName(name: string): Nullable<Light>;
  34051. /**
  34052. * Gets a light node using its id
  34053. * @param id defines the light's id
  34054. * @return the light or null if none found.
  34055. */
  34056. getLightByID(id: string): Nullable<Light>;
  34057. /**
  34058. * Gets a light node using its scene-generated unique ID
  34059. * @param uniqueId defines the light's unique id
  34060. * @return the light or null if none found.
  34061. */
  34062. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34063. /**
  34064. * Gets a particle system by id
  34065. * @param id defines the particle system id
  34066. * @return the corresponding system or null if none found
  34067. */
  34068. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34069. /**
  34070. * Gets a geometry using its ID
  34071. * @param id defines the geometry's id
  34072. * @return the geometry or null if none found.
  34073. */
  34074. getGeometryByID(id: string): Nullable<Geometry>;
  34075. private _getGeometryByUniqueID;
  34076. /**
  34077. * Add a new geometry to this scene
  34078. * @param geometry defines the geometry to be added to the scene.
  34079. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34080. * @return a boolean defining if the geometry was added or not
  34081. */
  34082. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34083. /**
  34084. * Removes an existing geometry
  34085. * @param geometry defines the geometry to be removed from the scene
  34086. * @return a boolean defining if the geometry was removed or not
  34087. */
  34088. removeGeometry(geometry: Geometry): boolean;
  34089. /**
  34090. * Gets the list of geometries attached to the scene
  34091. * @returns an array of Geometry
  34092. */
  34093. getGeometries(): Geometry[];
  34094. /**
  34095. * Gets the first added mesh found of a given ID
  34096. * @param id defines the id to search for
  34097. * @return the mesh found or null if not found at all
  34098. */
  34099. getMeshByID(id: string): Nullable<AbstractMesh>;
  34100. /**
  34101. * Gets a list of meshes using their id
  34102. * @param id defines the id to search for
  34103. * @returns a list of meshes
  34104. */
  34105. getMeshesByID(id: string): Array<AbstractMesh>;
  34106. /**
  34107. * Gets the first added transform node found of a given ID
  34108. * @param id defines the id to search for
  34109. * @return the found transform node or null if not found at all.
  34110. */
  34111. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34112. /**
  34113. * Gets a transform node with its auto-generated unique id
  34114. * @param uniqueId efines the unique id to search for
  34115. * @return the found transform node or null if not found at all.
  34116. */
  34117. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34118. /**
  34119. * Gets a list of transform nodes using their id
  34120. * @param id defines the id to search for
  34121. * @returns a list of transform nodes
  34122. */
  34123. getTransformNodesByID(id: string): Array<TransformNode>;
  34124. /**
  34125. * Gets a mesh with its auto-generated unique id
  34126. * @param uniqueId defines the unique id to search for
  34127. * @return the found mesh or null if not found at all.
  34128. */
  34129. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34130. /**
  34131. * Gets a the last added mesh using a given id
  34132. * @param id defines the id to search for
  34133. * @return the found mesh or null if not found at all.
  34134. */
  34135. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34136. /**
  34137. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34138. * @param id defines the id to search for
  34139. * @return the found node or null if not found at all
  34140. */
  34141. getLastEntryByID(id: string): Nullable<Node>;
  34142. /**
  34143. * Gets a node (Mesh, Camera, Light) using a given id
  34144. * @param id defines the id to search for
  34145. * @return the found node or null if not found at all
  34146. */
  34147. getNodeByID(id: string): Nullable<Node>;
  34148. /**
  34149. * Gets a node (Mesh, Camera, Light) using a given name
  34150. * @param name defines the name to search for
  34151. * @return the found node or null if not found at all.
  34152. */
  34153. getNodeByName(name: string): Nullable<Node>;
  34154. /**
  34155. * Gets a mesh using a given name
  34156. * @param name defines the name to search for
  34157. * @return the found mesh or null if not found at all.
  34158. */
  34159. getMeshByName(name: string): Nullable<AbstractMesh>;
  34160. /**
  34161. * Gets a transform node using a given name
  34162. * @param name defines the name to search for
  34163. * @return the found transform node or null if not found at all.
  34164. */
  34165. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34166. /**
  34167. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34168. * @param id defines the id to search for
  34169. * @return the found skeleton or null if not found at all.
  34170. */
  34171. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34172. /**
  34173. * Gets a skeleton using a given auto generated unique id
  34174. * @param uniqueId defines the unique id to search for
  34175. * @return the found skeleton or null if not found at all.
  34176. */
  34177. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34178. /**
  34179. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34180. * @param id defines the id to search for
  34181. * @return the found skeleton or null if not found at all.
  34182. */
  34183. getSkeletonById(id: string): Nullable<Skeleton>;
  34184. /**
  34185. * Gets a skeleton using a given name
  34186. * @param name defines the name to search for
  34187. * @return the found skeleton or null if not found at all.
  34188. */
  34189. getSkeletonByName(name: string): Nullable<Skeleton>;
  34190. /**
  34191. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34192. * @param id defines the id to search for
  34193. * @return the found morph target manager or null if not found at all.
  34194. */
  34195. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34196. /**
  34197. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34198. * @param id defines the id to search for
  34199. * @return the found morph target or null if not found at all.
  34200. */
  34201. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34202. /**
  34203. * Gets a boolean indicating if the given mesh is active
  34204. * @param mesh defines the mesh to look for
  34205. * @returns true if the mesh is in the active list
  34206. */
  34207. isActiveMesh(mesh: AbstractMesh): boolean;
  34208. /**
  34209. * Return a unique id as a string which can serve as an identifier for the scene
  34210. */
  34211. readonly uid: string;
  34212. /**
  34213. * Add an externaly attached data from its key.
  34214. * This method call will fail and return false, if such key already exists.
  34215. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34216. * @param key the unique key that identifies the data
  34217. * @param data the data object to associate to the key for this Engine instance
  34218. * @return true if no such key were already present and the data was added successfully, false otherwise
  34219. */
  34220. addExternalData<T>(key: string, data: T): boolean;
  34221. /**
  34222. * Get an externaly attached data from its key
  34223. * @param key the unique key that identifies the data
  34224. * @return the associated data, if present (can be null), or undefined if not present
  34225. */
  34226. getExternalData<T>(key: string): Nullable<T>;
  34227. /**
  34228. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34229. * @param key the unique key that identifies the data
  34230. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34231. * @return the associated data, can be null if the factory returned null.
  34232. */
  34233. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34234. /**
  34235. * Remove an externaly attached data from the Engine instance
  34236. * @param key the unique key that identifies the data
  34237. * @return true if the data was successfully removed, false if it doesn't exist
  34238. */
  34239. removeExternalData(key: string): boolean;
  34240. private _evaluateSubMesh;
  34241. /**
  34242. * Clear the processed materials smart array preventing retention point in material dispose.
  34243. */
  34244. freeProcessedMaterials(): void;
  34245. private _preventFreeActiveMeshesAndRenderingGroups;
  34246. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34247. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34248. * when disposing several meshes in a row or a hierarchy of meshes.
  34249. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34250. */
  34251. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34252. /**
  34253. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34254. */
  34255. freeActiveMeshes(): void;
  34256. /**
  34257. * Clear the info related to rendering groups preventing retention points during dispose.
  34258. */
  34259. freeRenderingGroups(): void;
  34260. /** @hidden */
  34261. _isInIntermediateRendering(): boolean;
  34262. /**
  34263. * Lambda returning the list of potentially active meshes.
  34264. */
  34265. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34266. /**
  34267. * Lambda returning the list of potentially active sub meshes.
  34268. */
  34269. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34270. /**
  34271. * Lambda returning the list of potentially intersecting sub meshes.
  34272. */
  34273. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34274. /**
  34275. * Lambda returning the list of potentially colliding sub meshes.
  34276. */
  34277. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34278. private _activeMeshesFrozen;
  34279. /**
  34280. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34281. * @returns the current scene
  34282. */
  34283. freezeActiveMeshes(): Scene;
  34284. /**
  34285. * Use this function to restart evaluating active meshes on every frame
  34286. * @returns the current scene
  34287. */
  34288. unfreezeActiveMeshes(): Scene;
  34289. private _evaluateActiveMeshes;
  34290. private _activeMesh;
  34291. /**
  34292. * Update the transform matrix to update from the current active camera
  34293. * @param force defines a boolean used to force the update even if cache is up to date
  34294. */
  34295. updateTransformMatrix(force?: boolean): void;
  34296. private _bindFrameBuffer;
  34297. /** @hidden */
  34298. _allowPostProcessClearColor: boolean;
  34299. /** @hidden */
  34300. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34301. private _processSubCameras;
  34302. private _checkIntersections;
  34303. /** @hidden */
  34304. _advancePhysicsEngineStep(step: number): void;
  34305. /**
  34306. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34307. */
  34308. getDeterministicFrameTime: () => number;
  34309. /** @hidden */
  34310. _animate(): void;
  34311. /** Execute all animations (for a frame) */
  34312. animate(): void;
  34313. /**
  34314. * Render the scene
  34315. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34316. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34317. */
  34318. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34319. /**
  34320. * Freeze all materials
  34321. * A frozen material will not be updatable but should be faster to render
  34322. */
  34323. freezeMaterials(): void;
  34324. /**
  34325. * Unfreeze all materials
  34326. * A frozen material will not be updatable but should be faster to render
  34327. */
  34328. unfreezeMaterials(): void;
  34329. /**
  34330. * Releases all held ressources
  34331. */
  34332. dispose(): void;
  34333. /**
  34334. * Gets if the scene is already disposed
  34335. */
  34336. readonly isDisposed: boolean;
  34337. /**
  34338. * Call this function to reduce memory footprint of the scene.
  34339. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34340. */
  34341. clearCachedVertexData(): void;
  34342. /**
  34343. * This function will remove the local cached buffer data from texture.
  34344. * It will save memory but will prevent the texture from being rebuilt
  34345. */
  34346. cleanCachedTextureBuffer(): void;
  34347. /**
  34348. * Get the world extend vectors with an optional filter
  34349. *
  34350. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34351. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34352. */
  34353. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34354. min: Vector3;
  34355. max: Vector3;
  34356. };
  34357. /**
  34358. * Creates a ray that can be used to pick in the scene
  34359. * @param x defines the x coordinate of the origin (on-screen)
  34360. * @param y defines the y coordinate of the origin (on-screen)
  34361. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34362. * @param camera defines the camera to use for the picking
  34363. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34364. * @returns a Ray
  34365. */
  34366. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34367. /**
  34368. * Creates a ray that can be used to pick in the scene
  34369. * @param x defines the x coordinate of the origin (on-screen)
  34370. * @param y defines the y coordinate of the origin (on-screen)
  34371. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34372. * @param result defines the ray where to store the picking ray
  34373. * @param camera defines the camera to use for the picking
  34374. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34375. * @returns the current scene
  34376. */
  34377. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34378. /**
  34379. * Creates a ray that can be used to pick in the scene
  34380. * @param x defines the x coordinate of the origin (on-screen)
  34381. * @param y defines the y coordinate of the origin (on-screen)
  34382. * @param camera defines the camera to use for the picking
  34383. * @returns a Ray
  34384. */
  34385. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34386. /**
  34387. * Creates a ray that can be used to pick in the scene
  34388. * @param x defines the x coordinate of the origin (on-screen)
  34389. * @param y defines the y coordinate of the origin (on-screen)
  34390. * @param result defines the ray where to store the picking ray
  34391. * @param camera defines the camera to use for the picking
  34392. * @returns the current scene
  34393. */
  34394. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34395. /** Launch a ray to try to pick a mesh in the scene
  34396. * @param x position on screen
  34397. * @param y position on screen
  34398. * @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
  34399. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34400. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34402. * @returns a PickingInfo
  34403. */
  34404. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34405. /** Use the given ray to pick a mesh in the scene
  34406. * @param ray The ray to use to pick meshes
  34407. * @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
  34408. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34409. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34410. * @returns a PickingInfo
  34411. */
  34412. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34413. /**
  34414. * Launch a ray to try to pick a mesh in the scene
  34415. * @param x X position on screen
  34416. * @param y Y position on screen
  34417. * @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
  34418. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34419. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34420. * @returns an array of PickingInfo
  34421. */
  34422. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34423. /**
  34424. * Launch a ray to try to pick a mesh in the scene
  34425. * @param ray Ray to use
  34426. * @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
  34427. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34428. * @returns an array of PickingInfo
  34429. */
  34430. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34431. /**
  34432. * Force the value of meshUnderPointer
  34433. * @param mesh defines the mesh to use
  34434. */
  34435. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34436. /**
  34437. * Gets the mesh under the pointer
  34438. * @returns a Mesh or null if no mesh is under the pointer
  34439. */
  34440. getPointerOverMesh(): Nullable<AbstractMesh>;
  34441. /** @hidden */
  34442. _rebuildGeometries(): void;
  34443. /** @hidden */
  34444. _rebuildTextures(): void;
  34445. private _getByTags;
  34446. /**
  34447. * Get a list of meshes by tags
  34448. * @param tagsQuery defines the tags query to use
  34449. * @param forEach defines a predicate used to filter results
  34450. * @returns an array of Mesh
  34451. */
  34452. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34453. /**
  34454. * Get a list of cameras by tags
  34455. * @param tagsQuery defines the tags query to use
  34456. * @param forEach defines a predicate used to filter results
  34457. * @returns an array of Camera
  34458. */
  34459. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34460. /**
  34461. * Get a list of lights by tags
  34462. * @param tagsQuery defines the tags query to use
  34463. * @param forEach defines a predicate used to filter results
  34464. * @returns an array of Light
  34465. */
  34466. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34467. /**
  34468. * Get a list of materials by tags
  34469. * @param tagsQuery defines the tags query to use
  34470. * @param forEach defines a predicate used to filter results
  34471. * @returns an array of Material
  34472. */
  34473. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34474. /**
  34475. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34476. * This allowed control for front to back rendering or reversly depending of the special needs.
  34477. *
  34478. * @param renderingGroupId The rendering group id corresponding to its index
  34479. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34480. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34481. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34482. */
  34483. 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;
  34484. /**
  34485. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34486. *
  34487. * @param renderingGroupId The rendering group id corresponding to its index
  34488. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34489. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34490. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34491. */
  34492. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34493. /**
  34494. * Gets the current auto clear configuration for one rendering group of the rendering
  34495. * manager.
  34496. * @param index the rendering group index to get the information for
  34497. * @returns The auto clear setup for the requested rendering group
  34498. */
  34499. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34500. private _blockMaterialDirtyMechanism;
  34501. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34502. blockMaterialDirtyMechanism: boolean;
  34503. /**
  34504. * Will flag all materials as dirty to trigger new shader compilation
  34505. * @param flag defines the flag used to specify which material part must be marked as dirty
  34506. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34507. */
  34508. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34509. /** @hidden */
  34510. _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;
  34511. /** @hidden */
  34512. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34513. }
  34514. }
  34515. declare module "babylonjs/assetContainer" {
  34516. import { AbstractScene } from "babylonjs/abstractScene";
  34517. import { Scene } from "babylonjs/scene";
  34518. import { Mesh } from "babylonjs/Meshes/mesh";
  34519. /**
  34520. * Set of assets to keep when moving a scene into an asset container.
  34521. */
  34522. export class KeepAssets extends AbstractScene {
  34523. }
  34524. /**
  34525. * Container with a set of assets that can be added or removed from a scene.
  34526. */
  34527. export class AssetContainer extends AbstractScene {
  34528. /**
  34529. * The scene the AssetContainer belongs to.
  34530. */
  34531. scene: Scene;
  34532. /**
  34533. * Instantiates an AssetContainer.
  34534. * @param scene The scene the AssetContainer belongs to.
  34535. */
  34536. constructor(scene: Scene);
  34537. /**
  34538. * Adds all the assets from the container to the scene.
  34539. */
  34540. addAllToScene(): void;
  34541. /**
  34542. * Removes all the assets in the container from the scene
  34543. */
  34544. removeAllFromScene(): void;
  34545. /**
  34546. * Disposes all the assets in the container
  34547. */
  34548. dispose(): void;
  34549. private _moveAssets;
  34550. /**
  34551. * Removes all the assets contained in the scene and adds them to the container.
  34552. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34553. */
  34554. moveAllFromScene(keepAssets?: KeepAssets): void;
  34555. /**
  34556. * 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.
  34557. * @returns the root mesh
  34558. */
  34559. createRootMesh(): Mesh;
  34560. }
  34561. }
  34562. declare module "babylonjs/abstractScene" {
  34563. import { Scene } from "babylonjs/scene";
  34564. import { Nullable } from "babylonjs/types";
  34565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34566. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34567. import { Geometry } from "babylonjs/Meshes/geometry";
  34568. import { Skeleton } from "babylonjs/Bones/skeleton";
  34569. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34570. import { AssetContainer } from "babylonjs/assetContainer";
  34571. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34572. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34574. import { Material } from "babylonjs/Materials/material";
  34575. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34576. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34577. import { Camera } from "babylonjs/Cameras/camera";
  34578. import { Light } from "babylonjs/Lights/light";
  34579. import { Node } from "babylonjs/node";
  34580. import { Animation } from "babylonjs/Animations/animation";
  34581. /**
  34582. * Defines how the parser contract is defined.
  34583. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34584. */
  34585. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34586. /**
  34587. * Defines how the individual parser contract is defined.
  34588. * These parser can parse an individual asset
  34589. */
  34590. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34591. /**
  34592. * Base class of the scene acting as a container for the different elements composing a scene.
  34593. * This class is dynamically extended by the different components of the scene increasing
  34594. * flexibility and reducing coupling
  34595. */
  34596. export abstract class AbstractScene {
  34597. /**
  34598. * Stores the list of available parsers in the application.
  34599. */
  34600. private static _BabylonFileParsers;
  34601. /**
  34602. * Stores the list of available individual parsers in the application.
  34603. */
  34604. private static _IndividualBabylonFileParsers;
  34605. /**
  34606. * Adds a parser in the list of available ones
  34607. * @param name Defines the name of the parser
  34608. * @param parser Defines the parser to add
  34609. */
  34610. static AddParser(name: string, parser: BabylonFileParser): void;
  34611. /**
  34612. * Gets a general parser from the list of avaialble ones
  34613. * @param name Defines the name of the parser
  34614. * @returns the requested parser or null
  34615. */
  34616. static GetParser(name: string): Nullable<BabylonFileParser>;
  34617. /**
  34618. * Adds n individual parser in the list of available ones
  34619. * @param name Defines the name of the parser
  34620. * @param parser Defines the parser to add
  34621. */
  34622. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34623. /**
  34624. * Gets an individual parser from the list of avaialble ones
  34625. * @param name Defines the name of the parser
  34626. * @returns the requested parser or null
  34627. */
  34628. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34629. /**
  34630. * Parser json data and populate both a scene and its associated container object
  34631. * @param jsonData Defines the data to parse
  34632. * @param scene Defines the scene to parse the data for
  34633. * @param container Defines the container attached to the parsing sequence
  34634. * @param rootUrl Defines the root url of the data
  34635. */
  34636. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34637. /**
  34638. * Gets the list of root nodes (ie. nodes with no parent)
  34639. */
  34640. rootNodes: Node[];
  34641. /** All of the cameras added to this scene
  34642. * @see http://doc.babylonjs.com/babylon101/cameras
  34643. */
  34644. cameras: Camera[];
  34645. /**
  34646. * All of the lights added to this scene
  34647. * @see http://doc.babylonjs.com/babylon101/lights
  34648. */
  34649. lights: Light[];
  34650. /**
  34651. * All of the (abstract) meshes added to this scene
  34652. */
  34653. meshes: AbstractMesh[];
  34654. /**
  34655. * The list of skeletons added to the scene
  34656. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34657. */
  34658. skeletons: Skeleton[];
  34659. /**
  34660. * All of the particle systems added to this scene
  34661. * @see http://doc.babylonjs.com/babylon101/particles
  34662. */
  34663. particleSystems: IParticleSystem[];
  34664. /**
  34665. * Gets a list of Animations associated with the scene
  34666. */
  34667. animations: Animation[];
  34668. /**
  34669. * All of the animation groups added to this scene
  34670. * @see http://doc.babylonjs.com/how_to/group
  34671. */
  34672. animationGroups: AnimationGroup[];
  34673. /**
  34674. * All of the multi-materials added to this scene
  34675. * @see http://doc.babylonjs.com/how_to/multi_materials
  34676. */
  34677. multiMaterials: MultiMaterial[];
  34678. /**
  34679. * All of the materials added to this scene
  34680. * In the context of a Scene, it is not supposed to be modified manually.
  34681. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34682. * Note also that the order of the Material wihin the array is not significant and might change.
  34683. * @see http://doc.babylonjs.com/babylon101/materials
  34684. */
  34685. materials: Material[];
  34686. /**
  34687. * The list of morph target managers added to the scene
  34688. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34689. */
  34690. morphTargetManagers: MorphTargetManager[];
  34691. /**
  34692. * The list of geometries used in the scene.
  34693. */
  34694. geometries: Geometry[];
  34695. /**
  34696. * All of the tranform nodes added to this scene
  34697. * In the context of a Scene, it is not supposed to be modified manually.
  34698. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34699. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34700. * @see http://doc.babylonjs.com/how_to/transformnode
  34701. */
  34702. transformNodes: TransformNode[];
  34703. /**
  34704. * ActionManagers available on the scene.
  34705. */
  34706. actionManagers: AbstractActionManager[];
  34707. /**
  34708. * Textures to keep.
  34709. */
  34710. textures: BaseTexture[];
  34711. /**
  34712. * Environment texture for the scene
  34713. */
  34714. environmentTexture: Nullable<BaseTexture>;
  34715. }
  34716. }
  34717. declare module "babylonjs/Audio/sound" {
  34718. import { Observable } from "babylonjs/Misc/observable";
  34719. import { Vector3 } from "babylonjs/Maths/math";
  34720. import { Nullable } from "babylonjs/types";
  34721. import { Scene } from "babylonjs/scene";
  34722. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34723. /**
  34724. * Defines a sound that can be played in the application.
  34725. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34727. */
  34728. export class Sound {
  34729. /**
  34730. * The name of the sound in the scene.
  34731. */
  34732. name: string;
  34733. /**
  34734. * Does the sound autoplay once loaded.
  34735. */
  34736. autoplay: boolean;
  34737. /**
  34738. * Does the sound loop after it finishes playing once.
  34739. */
  34740. loop: boolean;
  34741. /**
  34742. * Does the sound use a custom attenuation curve to simulate the falloff
  34743. * happening when the source gets further away from the camera.
  34744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34745. */
  34746. useCustomAttenuation: boolean;
  34747. /**
  34748. * The sound track id this sound belongs to.
  34749. */
  34750. soundTrackId: number;
  34751. /**
  34752. * Is this sound currently played.
  34753. */
  34754. isPlaying: boolean;
  34755. /**
  34756. * Is this sound currently paused.
  34757. */
  34758. isPaused: boolean;
  34759. /**
  34760. * Does this sound enables spatial sound.
  34761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34762. */
  34763. spatialSound: boolean;
  34764. /**
  34765. * Define the reference distance the sound should be heard perfectly.
  34766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34767. */
  34768. refDistance: number;
  34769. /**
  34770. * Define the roll off factor of spatial sounds.
  34771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34772. */
  34773. rolloffFactor: number;
  34774. /**
  34775. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34777. */
  34778. maxDistance: number;
  34779. /**
  34780. * Define the distance attenuation model the sound will follow.
  34781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34782. */
  34783. distanceModel: string;
  34784. /**
  34785. * @hidden
  34786. * Back Compat
  34787. **/
  34788. onended: () => any;
  34789. /**
  34790. * Observable event when the current playing sound finishes.
  34791. */
  34792. onEndedObservable: Observable<Sound>;
  34793. private _panningModel;
  34794. private _playbackRate;
  34795. private _streaming;
  34796. private _startTime;
  34797. private _startOffset;
  34798. private _position;
  34799. /** @hidden */
  34800. _positionInEmitterSpace: boolean;
  34801. private _localDirection;
  34802. private _volume;
  34803. private _isReadyToPlay;
  34804. private _isDirectional;
  34805. private _readyToPlayCallback;
  34806. private _audioBuffer;
  34807. private _soundSource;
  34808. private _streamingSource;
  34809. private _soundPanner;
  34810. private _soundGain;
  34811. private _inputAudioNode;
  34812. private _outputAudioNode;
  34813. private _coneInnerAngle;
  34814. private _coneOuterAngle;
  34815. private _coneOuterGain;
  34816. private _scene;
  34817. private _connectedTransformNode;
  34818. private _customAttenuationFunction;
  34819. private _registerFunc;
  34820. private _isOutputConnected;
  34821. private _htmlAudioElement;
  34822. private _urlType;
  34823. /** @hidden */
  34824. static _SceneComponentInitialization: (scene: Scene) => void;
  34825. /**
  34826. * Create a sound and attach it to a scene
  34827. * @param name Name of your sound
  34828. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34829. * @param scene defines the scene the sound belongs to
  34830. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34831. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34832. */
  34833. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34834. /**
  34835. * Release the sound and its associated resources
  34836. */
  34837. dispose(): void;
  34838. /**
  34839. * Gets if the sounds is ready to be played or not.
  34840. * @returns true if ready, otherwise false
  34841. */
  34842. isReady(): boolean;
  34843. private _soundLoaded;
  34844. /**
  34845. * Sets the data of the sound from an audiobuffer
  34846. * @param audioBuffer The audioBuffer containing the data
  34847. */
  34848. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34849. /**
  34850. * Updates the current sounds options such as maxdistance, loop...
  34851. * @param options A JSON object containing values named as the object properties
  34852. */
  34853. updateOptions(options: any): void;
  34854. private _createSpatialParameters;
  34855. private _updateSpatialParameters;
  34856. /**
  34857. * Switch the panning model to HRTF:
  34858. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34860. */
  34861. switchPanningModelToHRTF(): void;
  34862. /**
  34863. * Switch the panning model to Equal Power:
  34864. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34866. */
  34867. switchPanningModelToEqualPower(): void;
  34868. private _switchPanningModel;
  34869. /**
  34870. * Connect this sound to a sound track audio node like gain...
  34871. * @param soundTrackAudioNode the sound track audio node to connect to
  34872. */
  34873. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34874. /**
  34875. * Transform this sound into a directional source
  34876. * @param coneInnerAngle Size of the inner cone in degree
  34877. * @param coneOuterAngle Size of the outer cone in degree
  34878. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34879. */
  34880. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34881. /**
  34882. * Gets or sets the inner angle for the directional cone.
  34883. */
  34884. /**
  34885. * Gets or sets the inner angle for the directional cone.
  34886. */
  34887. directionalConeInnerAngle: number;
  34888. /**
  34889. * Gets or sets the outer angle for the directional cone.
  34890. */
  34891. /**
  34892. * Gets or sets the outer angle for the directional cone.
  34893. */
  34894. directionalConeOuterAngle: number;
  34895. /**
  34896. * Sets the position of the emitter if spatial sound is enabled
  34897. * @param newPosition Defines the new posisiton
  34898. */
  34899. setPosition(newPosition: Vector3): void;
  34900. /**
  34901. * Sets the local direction of the emitter if spatial sound is enabled
  34902. * @param newLocalDirection Defines the new local direction
  34903. */
  34904. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34905. private _updateDirection;
  34906. /** @hidden */
  34907. updateDistanceFromListener(): void;
  34908. /**
  34909. * Sets a new custom attenuation function for the sound.
  34910. * @param callback Defines the function used for the attenuation
  34911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34912. */
  34913. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34914. /**
  34915. * Play the sound
  34916. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34917. * @param offset (optional) Start the sound setting it at a specific time
  34918. */
  34919. play(time?: number, offset?: number): void;
  34920. private _onended;
  34921. /**
  34922. * Stop the sound
  34923. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34924. */
  34925. stop(time?: number): void;
  34926. /**
  34927. * Put the sound in pause
  34928. */
  34929. pause(): void;
  34930. /**
  34931. * Sets a dedicated volume for this sounds
  34932. * @param newVolume Define the new volume of the sound
  34933. * @param time Define in how long the sound should be at this value
  34934. */
  34935. setVolume(newVolume: number, time?: number): void;
  34936. /**
  34937. * Set the sound play back rate
  34938. * @param newPlaybackRate Define the playback rate the sound should be played at
  34939. */
  34940. setPlaybackRate(newPlaybackRate: number): void;
  34941. /**
  34942. * Gets the volume of the sound.
  34943. * @returns the volume of the sound
  34944. */
  34945. getVolume(): number;
  34946. /**
  34947. * Attach the sound to a dedicated mesh
  34948. * @param transformNode The transform node to connect the sound with
  34949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34950. */
  34951. attachToMesh(transformNode: TransformNode): void;
  34952. /**
  34953. * Detach the sound from the previously attached mesh
  34954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34955. */
  34956. detachFromMesh(): void;
  34957. private _onRegisterAfterWorldMatrixUpdate;
  34958. /**
  34959. * Clone the current sound in the scene.
  34960. * @returns the new sound clone
  34961. */
  34962. clone(): Nullable<Sound>;
  34963. /**
  34964. * Gets the current underlying audio buffer containing the data
  34965. * @returns the audio buffer
  34966. */
  34967. getAudioBuffer(): Nullable<AudioBuffer>;
  34968. /**
  34969. * Serializes the Sound in a JSON representation
  34970. * @returns the JSON representation of the sound
  34971. */
  34972. serialize(): any;
  34973. /**
  34974. * Parse a JSON representation of a sound to innstantiate in a given scene
  34975. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34976. * @param scene Define the scene the new parsed sound should be created in
  34977. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34978. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34979. * @returns the newly parsed sound
  34980. */
  34981. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34982. }
  34983. }
  34984. declare module "babylonjs/Actions/directAudioActions" {
  34985. import { Action } from "babylonjs/Actions/action";
  34986. import { Condition } from "babylonjs/Actions/condition";
  34987. import { Sound } from "babylonjs/Audio/sound";
  34988. /**
  34989. * This defines an action helpful to play a defined sound on a triggered action.
  34990. */
  34991. export class PlaySoundAction extends Action {
  34992. private _sound;
  34993. /**
  34994. * Instantiate the action
  34995. * @param triggerOptions defines the trigger options
  34996. * @param sound defines the sound to play
  34997. * @param condition defines the trigger related conditions
  34998. */
  34999. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35000. /** @hidden */
  35001. _prepare(): void;
  35002. /**
  35003. * Execute the action and play the sound.
  35004. */
  35005. execute(): void;
  35006. /**
  35007. * Serializes the actions and its related information.
  35008. * @param parent defines the object to serialize in
  35009. * @returns the serialized object
  35010. */
  35011. serialize(parent: any): any;
  35012. }
  35013. /**
  35014. * This defines an action helpful to stop a defined sound on a triggered action.
  35015. */
  35016. export class StopSoundAction extends Action {
  35017. private _sound;
  35018. /**
  35019. * Instantiate the action
  35020. * @param triggerOptions defines the trigger options
  35021. * @param sound defines the sound to stop
  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 stop 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. declare module "babylonjs/Actions/interpolateValueAction" {
  35040. import { Action } from "babylonjs/Actions/action";
  35041. import { Condition } from "babylonjs/Actions/condition";
  35042. import { Observable } from "babylonjs/Misc/observable";
  35043. /**
  35044. * This defines an action responsible to change the value of a property
  35045. * by interpolating between its current value and the newly set one once triggered.
  35046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35047. */
  35048. export class InterpolateValueAction extends Action {
  35049. /**
  35050. * Defines the path of the property where the value should be interpolated
  35051. */
  35052. propertyPath: string;
  35053. /**
  35054. * Defines the target value at the end of the interpolation.
  35055. */
  35056. value: any;
  35057. /**
  35058. * Defines the time it will take for the property to interpolate to the value.
  35059. */
  35060. duration: number;
  35061. /**
  35062. * Defines if the other scene animations should be stopped when the action has been triggered
  35063. */
  35064. stopOtherAnimations?: boolean;
  35065. /**
  35066. * Defines a callback raised once the interpolation animation has been done.
  35067. */
  35068. onInterpolationDone?: () => void;
  35069. /**
  35070. * Observable triggered once the interpolation animation has been done.
  35071. */
  35072. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35073. private _target;
  35074. private _effectiveTarget;
  35075. private _property;
  35076. /**
  35077. * Instantiate the action
  35078. * @param triggerOptions defines the trigger options
  35079. * @param target defines the object containing the value to interpolate
  35080. * @param propertyPath defines the path to the property in the target object
  35081. * @param value defines the target value at the end of the interpolation
  35082. * @param duration deines the time it will take for the property to interpolate to the value.
  35083. * @param condition defines the trigger related conditions
  35084. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35085. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35086. */
  35087. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35088. /** @hidden */
  35089. _prepare(): void;
  35090. /**
  35091. * Execute the action starts the value interpolation.
  35092. */
  35093. execute(): void;
  35094. /**
  35095. * Serializes the actions and its related information.
  35096. * @param parent defines the object to serialize in
  35097. * @returns the serialized object
  35098. */
  35099. serialize(parent: any): any;
  35100. }
  35101. }
  35102. declare module "babylonjs/Actions/index" {
  35103. export * from "babylonjs/Actions/action";
  35104. export * from "babylonjs/Actions/actionEvent";
  35105. export * from "babylonjs/Actions/actionManager";
  35106. export * from "babylonjs/Actions/condition";
  35107. export * from "babylonjs/Actions/directActions";
  35108. export * from "babylonjs/Actions/directAudioActions";
  35109. export * from "babylonjs/Actions/interpolateValueAction";
  35110. }
  35111. declare module "babylonjs/Animations/index" {
  35112. export * from "babylonjs/Animations/animatable";
  35113. export * from "babylonjs/Animations/animation";
  35114. export * from "babylonjs/Animations/animationGroup";
  35115. export * from "babylonjs/Animations/animationPropertiesOverride";
  35116. export * from "babylonjs/Animations/easing";
  35117. export * from "babylonjs/Animations/runtimeAnimation";
  35118. export * from "babylonjs/Animations/animationEvent";
  35119. export * from "babylonjs/Animations/animationGroup";
  35120. export * from "babylonjs/Animations/animationKey";
  35121. export * from "babylonjs/Animations/animationRange";
  35122. }
  35123. declare module "babylonjs/Audio/soundTrack" {
  35124. import { Sound } from "babylonjs/Audio/sound";
  35125. import { Analyser } from "babylonjs/Audio/analyser";
  35126. import { Scene } from "babylonjs/scene";
  35127. /**
  35128. * Options allowed during the creation of a sound track.
  35129. */
  35130. export interface ISoundTrackOptions {
  35131. /**
  35132. * The volume the sound track should take during creation
  35133. */
  35134. volume?: number;
  35135. /**
  35136. * Define if the sound track is the main sound track of the scene
  35137. */
  35138. mainTrack?: boolean;
  35139. }
  35140. /**
  35141. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35142. * It will be also used in a future release to apply effects on a specific track.
  35143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35144. */
  35145. export class SoundTrack {
  35146. /**
  35147. * The unique identifier of the sound track in the scene.
  35148. */
  35149. id: number;
  35150. /**
  35151. * The list of sounds included in the sound track.
  35152. */
  35153. soundCollection: Array<Sound>;
  35154. private _outputAudioNode;
  35155. private _scene;
  35156. private _isMainTrack;
  35157. private _connectedAnalyser;
  35158. private _options;
  35159. private _isInitialized;
  35160. /**
  35161. * Creates a new sound track.
  35162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35163. * @param scene Define the scene the sound track belongs to
  35164. * @param options
  35165. */
  35166. constructor(scene: Scene, options?: ISoundTrackOptions);
  35167. private _initializeSoundTrackAudioGraph;
  35168. /**
  35169. * Release the sound track and its associated resources
  35170. */
  35171. dispose(): void;
  35172. /**
  35173. * Adds a sound to this sound track
  35174. * @param sound define the cound to add
  35175. * @ignoreNaming
  35176. */
  35177. AddSound(sound: Sound): void;
  35178. /**
  35179. * Removes a sound to this sound track
  35180. * @param sound define the cound to remove
  35181. * @ignoreNaming
  35182. */
  35183. RemoveSound(sound: Sound): void;
  35184. /**
  35185. * Set a global volume for the full sound track.
  35186. * @param newVolume Define the new volume of the sound track
  35187. */
  35188. setVolume(newVolume: number): void;
  35189. /**
  35190. * Switch the panning model to HRTF:
  35191. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35193. */
  35194. switchPanningModelToHRTF(): void;
  35195. /**
  35196. * Switch the panning model to Equal Power:
  35197. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35199. */
  35200. switchPanningModelToEqualPower(): void;
  35201. /**
  35202. * Connect the sound track to an audio analyser allowing some amazing
  35203. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35205. * @param analyser The analyser to connect to the engine
  35206. */
  35207. connectToAnalyser(analyser: Analyser): void;
  35208. }
  35209. }
  35210. declare module "babylonjs/Audio/audioSceneComponent" {
  35211. import { Sound } from "babylonjs/Audio/sound";
  35212. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35213. import { Nullable } from "babylonjs/types";
  35214. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35215. import { Scene } from "babylonjs/scene";
  35216. import { AbstractScene } from "babylonjs/abstractScene";
  35217. module "babylonjs/abstractScene" {
  35218. interface AbstractScene {
  35219. /**
  35220. * The list of sounds used in the scene.
  35221. */
  35222. sounds: Nullable<Array<Sound>>;
  35223. }
  35224. }
  35225. module "babylonjs/scene" {
  35226. interface Scene {
  35227. /**
  35228. * @hidden
  35229. * Backing field
  35230. */
  35231. _mainSoundTrack: SoundTrack;
  35232. /**
  35233. * The main sound track played by the scene.
  35234. * It cotains your primary collection of sounds.
  35235. */
  35236. mainSoundTrack: SoundTrack;
  35237. /**
  35238. * The list of sound tracks added to the scene
  35239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35240. */
  35241. soundTracks: Nullable<Array<SoundTrack>>;
  35242. /**
  35243. * Gets a sound using a given name
  35244. * @param name defines the name to search for
  35245. * @return the found sound or null if not found at all.
  35246. */
  35247. getSoundByName(name: string): Nullable<Sound>;
  35248. /**
  35249. * Gets or sets if audio support is enabled
  35250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35251. */
  35252. audioEnabled: boolean;
  35253. /**
  35254. * Gets or sets if audio will be output to headphones
  35255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35256. */
  35257. headphone: boolean;
  35258. }
  35259. }
  35260. /**
  35261. * Defines the sound scene component responsible to manage any sounds
  35262. * in a given scene.
  35263. */
  35264. export class AudioSceneComponent implements ISceneSerializableComponent {
  35265. /**
  35266. * The component name helpfull to identify the component in the list of scene components.
  35267. */
  35268. readonly name: string;
  35269. /**
  35270. * The scene the component belongs to.
  35271. */
  35272. scene: Scene;
  35273. private _audioEnabled;
  35274. /**
  35275. * Gets whether audio is enabled or not.
  35276. * Please use related enable/disable method to switch state.
  35277. */
  35278. readonly audioEnabled: boolean;
  35279. private _headphone;
  35280. /**
  35281. * Gets whether audio is outputing to headphone or not.
  35282. * Please use the according Switch methods to change output.
  35283. */
  35284. readonly headphone: boolean;
  35285. /**
  35286. * Creates a new instance of the component for the given scene
  35287. * @param scene Defines the scene to register the component in
  35288. */
  35289. constructor(scene: Scene);
  35290. /**
  35291. * Registers the component in a given scene
  35292. */
  35293. register(): void;
  35294. /**
  35295. * Rebuilds the elements related to this component in case of
  35296. * context lost for instance.
  35297. */
  35298. rebuild(): void;
  35299. /**
  35300. * Serializes the component data to the specified json object
  35301. * @param serializationObject The object to serialize to
  35302. */
  35303. serialize(serializationObject: any): void;
  35304. /**
  35305. * Adds all the element from the container to the scene
  35306. * @param container the container holding the elements
  35307. */
  35308. addFromContainer(container: AbstractScene): void;
  35309. /**
  35310. * Removes all the elements in the container from the scene
  35311. * @param container contains the elements to remove
  35312. * @param dispose if the removed element should be disposed (default: false)
  35313. */
  35314. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35315. /**
  35316. * Disposes the component and the associated ressources.
  35317. */
  35318. dispose(): void;
  35319. /**
  35320. * Disables audio in the associated scene.
  35321. */
  35322. disableAudio(): void;
  35323. /**
  35324. * Enables audio in the associated scene.
  35325. */
  35326. enableAudio(): void;
  35327. /**
  35328. * Switch audio to headphone output.
  35329. */
  35330. switchAudioModeForHeadphones(): void;
  35331. /**
  35332. * Switch audio to normal speakers.
  35333. */
  35334. switchAudioModeForNormalSpeakers(): void;
  35335. private _afterRender;
  35336. }
  35337. }
  35338. declare module "babylonjs/Audio/weightedsound" {
  35339. import { Sound } from "babylonjs/Audio/sound";
  35340. /**
  35341. * Wraps one or more Sound objects and selects one with random weight for playback.
  35342. */
  35343. export class WeightedSound {
  35344. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35345. loop: boolean;
  35346. private _coneInnerAngle;
  35347. private _coneOuterAngle;
  35348. private _volume;
  35349. /** A Sound is currently playing. */
  35350. isPlaying: boolean;
  35351. /** A Sound is currently paused. */
  35352. isPaused: boolean;
  35353. private _sounds;
  35354. private _weights;
  35355. private _currentIndex?;
  35356. /**
  35357. * Creates a new WeightedSound from the list of sounds given.
  35358. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35359. * @param sounds Array of Sounds that will be selected from.
  35360. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35361. */
  35362. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35363. /**
  35364. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35365. */
  35366. /**
  35367. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35368. */
  35369. directionalConeInnerAngle: number;
  35370. /**
  35371. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35372. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35373. */
  35374. /**
  35375. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35376. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35377. */
  35378. directionalConeOuterAngle: number;
  35379. /**
  35380. * Playback volume.
  35381. */
  35382. /**
  35383. * Playback volume.
  35384. */
  35385. volume: number;
  35386. private _onended;
  35387. /**
  35388. * Suspend playback
  35389. */
  35390. pause(): void;
  35391. /**
  35392. * Stop playback
  35393. */
  35394. stop(): void;
  35395. /**
  35396. * Start playback.
  35397. * @param startOffset Position the clip head at a specific time in seconds.
  35398. */
  35399. play(startOffset?: number): void;
  35400. }
  35401. }
  35402. declare module "babylonjs/Audio/index" {
  35403. export * from "babylonjs/Audio/analyser";
  35404. export * from "babylonjs/Audio/audioEngine";
  35405. export * from "babylonjs/Audio/audioSceneComponent";
  35406. export * from "babylonjs/Audio/sound";
  35407. export * from "babylonjs/Audio/soundTrack";
  35408. export * from "babylonjs/Audio/weightedsound";
  35409. }
  35410. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35411. import { Behavior } from "babylonjs/Behaviors/behavior";
  35412. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35413. import { BackEase } from "babylonjs/Animations/easing";
  35414. /**
  35415. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35416. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35417. */
  35418. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35419. /**
  35420. * Gets the name of the behavior.
  35421. */
  35422. readonly name: string;
  35423. /**
  35424. * The easing function used by animations
  35425. */
  35426. static EasingFunction: BackEase;
  35427. /**
  35428. * The easing mode used by animations
  35429. */
  35430. static EasingMode: number;
  35431. /**
  35432. * The duration of the animation, in milliseconds
  35433. */
  35434. transitionDuration: number;
  35435. /**
  35436. * Length of the distance animated by the transition when lower radius is reached
  35437. */
  35438. lowerRadiusTransitionRange: number;
  35439. /**
  35440. * Length of the distance animated by the transition when upper radius is reached
  35441. */
  35442. upperRadiusTransitionRange: number;
  35443. private _autoTransitionRange;
  35444. /**
  35445. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35446. */
  35447. /**
  35448. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35449. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35450. */
  35451. autoTransitionRange: boolean;
  35452. private _attachedCamera;
  35453. private _onAfterCheckInputsObserver;
  35454. private _onMeshTargetChangedObserver;
  35455. /**
  35456. * Initializes the behavior.
  35457. */
  35458. init(): void;
  35459. /**
  35460. * Attaches the behavior to its arc rotate camera.
  35461. * @param camera Defines the camera to attach the behavior to
  35462. */
  35463. attach(camera: ArcRotateCamera): void;
  35464. /**
  35465. * Detaches the behavior from its current arc rotate camera.
  35466. */
  35467. detach(): void;
  35468. private _radiusIsAnimating;
  35469. private _radiusBounceTransition;
  35470. private _animatables;
  35471. private _cachedWheelPrecision;
  35472. /**
  35473. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35474. * @param radiusLimit The limit to check against.
  35475. * @return Bool to indicate if at limit.
  35476. */
  35477. private _isRadiusAtLimit;
  35478. /**
  35479. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35480. * @param radiusDelta The delta by which to animate to. Can be negative.
  35481. */
  35482. private _applyBoundRadiusAnimation;
  35483. /**
  35484. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35485. */
  35486. protected _clearAnimationLocks(): void;
  35487. /**
  35488. * Stops and removes all animations that have been applied to the camera
  35489. */
  35490. stopAllAnimations(): void;
  35491. }
  35492. }
  35493. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35494. import { Behavior } from "babylonjs/Behaviors/behavior";
  35495. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35496. import { ExponentialEase } from "babylonjs/Animations/easing";
  35497. import { Nullable } from "babylonjs/types";
  35498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35499. import { Vector3 } from "babylonjs/Maths/math";
  35500. /**
  35501. * 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.
  35502. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35503. */
  35504. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35505. /**
  35506. * Gets the name of the behavior.
  35507. */
  35508. readonly name: string;
  35509. private _mode;
  35510. private _radiusScale;
  35511. private _positionScale;
  35512. private _defaultElevation;
  35513. private _elevationReturnTime;
  35514. private _elevationReturnWaitTime;
  35515. private _zoomStopsAnimation;
  35516. private _framingTime;
  35517. /**
  35518. * The easing function used by animations
  35519. */
  35520. static EasingFunction: ExponentialEase;
  35521. /**
  35522. * The easing mode used by animations
  35523. */
  35524. static EasingMode: number;
  35525. /**
  35526. * Sets the current mode used by the behavior
  35527. */
  35528. /**
  35529. * Gets current mode used by the behavior.
  35530. */
  35531. mode: number;
  35532. /**
  35533. * Sets the scale applied to the radius (1 by default)
  35534. */
  35535. /**
  35536. * Gets the scale applied to the radius
  35537. */
  35538. radiusScale: number;
  35539. /**
  35540. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35541. */
  35542. /**
  35543. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35544. */
  35545. positionScale: number;
  35546. /**
  35547. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35548. * behaviour is triggered, in radians.
  35549. */
  35550. /**
  35551. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35552. * behaviour is triggered, in radians.
  35553. */
  35554. defaultElevation: number;
  35555. /**
  35556. * Sets the time (in milliseconds) taken to return to the default beta position.
  35557. * Negative value indicates camera should not return to default.
  35558. */
  35559. /**
  35560. * Gets the time (in milliseconds) taken to return to the default beta position.
  35561. * Negative value indicates camera should not return to default.
  35562. */
  35563. elevationReturnTime: number;
  35564. /**
  35565. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35566. */
  35567. /**
  35568. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35569. */
  35570. elevationReturnWaitTime: number;
  35571. /**
  35572. * Sets the flag that indicates if user zooming should stop animation.
  35573. */
  35574. /**
  35575. * Gets the flag that indicates if user zooming should stop animation.
  35576. */
  35577. zoomStopsAnimation: boolean;
  35578. /**
  35579. * Sets the transition time when framing the mesh, in milliseconds
  35580. */
  35581. /**
  35582. * Gets the transition time when framing the mesh, in milliseconds
  35583. */
  35584. framingTime: number;
  35585. /**
  35586. * Define if the behavior should automatically change the configured
  35587. * camera limits and sensibilities.
  35588. */
  35589. autoCorrectCameraLimitsAndSensibility: boolean;
  35590. private _onPrePointerObservableObserver;
  35591. private _onAfterCheckInputsObserver;
  35592. private _onMeshTargetChangedObserver;
  35593. private _attachedCamera;
  35594. private _isPointerDown;
  35595. private _lastInteractionTime;
  35596. /**
  35597. * Initializes the behavior.
  35598. */
  35599. init(): void;
  35600. /**
  35601. * Attaches the behavior to its arc rotate camera.
  35602. * @param camera Defines the camera to attach the behavior to
  35603. */
  35604. attach(camera: ArcRotateCamera): void;
  35605. /**
  35606. * Detaches the behavior from its current arc rotate camera.
  35607. */
  35608. detach(): void;
  35609. private _animatables;
  35610. private _betaIsAnimating;
  35611. private _betaTransition;
  35612. private _radiusTransition;
  35613. private _vectorTransition;
  35614. /**
  35615. * Targets the given mesh and updates zoom level accordingly.
  35616. * @param mesh The mesh to target.
  35617. * @param radius Optional. If a cached radius position already exists, overrides default.
  35618. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35619. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35620. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35621. */
  35622. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35623. /**
  35624. * Targets the given mesh with its children and updates zoom level accordingly.
  35625. * @param mesh The mesh to target.
  35626. * @param radius Optional. If a cached radius position already exists, overrides default.
  35627. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35628. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35629. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35630. */
  35631. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35632. /**
  35633. * Targets the given meshes with their children and updates zoom level accordingly.
  35634. * @param meshes The mesh to target.
  35635. * @param radius Optional. If a cached radius position already exists, overrides default.
  35636. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35637. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35638. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35639. */
  35640. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35641. /**
  35642. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35643. * @param minimumWorld Determines the smaller position of the bounding box extend
  35644. * @param maximumWorld Determines the bigger position of the bounding box extend
  35645. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35646. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35647. */
  35648. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35649. /**
  35650. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35651. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35652. * frustum width.
  35653. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35654. * to fully enclose the mesh in the viewing frustum.
  35655. */
  35656. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35657. /**
  35658. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35659. * is automatically returned to its default position (expected to be above ground plane).
  35660. */
  35661. private _maintainCameraAboveGround;
  35662. /**
  35663. * Returns the frustum slope based on the canvas ratio and camera FOV
  35664. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35665. */
  35666. private _getFrustumSlope;
  35667. /**
  35668. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35669. */
  35670. private _clearAnimationLocks;
  35671. /**
  35672. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35673. */
  35674. private _applyUserInteraction;
  35675. /**
  35676. * Stops and removes all animations that have been applied to the camera
  35677. */
  35678. stopAllAnimations(): void;
  35679. /**
  35680. * Gets a value indicating if the user is moving the camera
  35681. */
  35682. readonly isUserIsMoving: boolean;
  35683. /**
  35684. * The camera can move all the way towards the mesh.
  35685. */
  35686. static IgnoreBoundsSizeMode: number;
  35687. /**
  35688. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35689. */
  35690. static FitFrustumSidesMode: number;
  35691. }
  35692. }
  35693. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35694. import { Nullable } from "babylonjs/types";
  35695. import { Camera } from "babylonjs/Cameras/camera";
  35696. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35697. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35698. /**
  35699. * Base class for Camera Pointer Inputs.
  35700. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35701. * for example usage.
  35702. */
  35703. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35704. /**
  35705. * Defines the camera the input is attached to.
  35706. */
  35707. abstract camera: Camera;
  35708. /**
  35709. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35710. */
  35711. protected _altKey: boolean;
  35712. protected _ctrlKey: boolean;
  35713. protected _metaKey: boolean;
  35714. protected _shiftKey: boolean;
  35715. /**
  35716. * Which mouse buttons were pressed at time of last mouse event.
  35717. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35718. */
  35719. protected _buttonsPressed: number;
  35720. /**
  35721. * Defines the buttons associated with the input to handle camera move.
  35722. */
  35723. buttons: number[];
  35724. /**
  35725. * Attach the input controls to a specific dom element to get the input from.
  35726. * @param element Defines the element the controls should be listened from
  35727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35728. */
  35729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35730. /**
  35731. * Detach the current controls from the specified dom element.
  35732. * @param element Defines the element to stop listening the inputs from
  35733. */
  35734. detachControl(element: Nullable<HTMLElement>): void;
  35735. /**
  35736. * Gets the class name of the current input.
  35737. * @returns the class name
  35738. */
  35739. getClassName(): string;
  35740. /**
  35741. * Get the friendly name associated with the input class.
  35742. * @returns the input friendly name
  35743. */
  35744. getSimpleName(): string;
  35745. /**
  35746. * Called on pointer POINTERDOUBLETAP event.
  35747. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35748. */
  35749. protected onDoubleTap(type: string): void;
  35750. /**
  35751. * Called on pointer POINTERMOVE event if only a single touch is active.
  35752. * Override this method to provide functionality.
  35753. */
  35754. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35755. /**
  35756. * Called on pointer POINTERMOVE event if multiple touches are active.
  35757. * Override this method to provide functionality.
  35758. */
  35759. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35760. /**
  35761. * Called on JS contextmenu event.
  35762. * Override this method to provide functionality.
  35763. */
  35764. protected onContextMenu(evt: PointerEvent): void;
  35765. /**
  35766. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35767. * press.
  35768. * Override this method to provide functionality.
  35769. */
  35770. protected onButtonDown(evt: PointerEvent): void;
  35771. /**
  35772. * Called each time a new POINTERUP event occurs. Ie, for each button
  35773. * release.
  35774. * Override this method to provide functionality.
  35775. */
  35776. protected onButtonUp(evt: PointerEvent): void;
  35777. /**
  35778. * Called when window becomes inactive.
  35779. * Override this method to provide functionality.
  35780. */
  35781. protected onLostFocus(): void;
  35782. private _pointerInput;
  35783. private _observer;
  35784. private _onLostFocus;
  35785. private pointA;
  35786. private pointB;
  35787. }
  35788. }
  35789. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35790. import { Nullable } from "babylonjs/types";
  35791. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35792. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35793. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35794. /**
  35795. * Manage the pointers inputs to control an arc rotate camera.
  35796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35797. */
  35798. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35799. /**
  35800. * Defines the camera the input is attached to.
  35801. */
  35802. camera: ArcRotateCamera;
  35803. /**
  35804. * Gets the class name of the current input.
  35805. * @returns the class name
  35806. */
  35807. getClassName(): string;
  35808. /**
  35809. * Defines the buttons associated with the input to handle camera move.
  35810. */
  35811. buttons: number[];
  35812. /**
  35813. * Defines the pointer angular sensibility along the X axis or how fast is
  35814. * the camera rotating.
  35815. */
  35816. angularSensibilityX: number;
  35817. /**
  35818. * Defines the pointer angular sensibility along the Y axis or how fast is
  35819. * the camera rotating.
  35820. */
  35821. angularSensibilityY: number;
  35822. /**
  35823. * Defines the pointer pinch precision or how fast is the camera zooming.
  35824. */
  35825. pinchPrecision: number;
  35826. /**
  35827. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35828. * from 0.
  35829. * It defines the percentage of current camera.radius to use as delta when
  35830. * pinch zoom is used.
  35831. */
  35832. pinchDeltaPercentage: number;
  35833. /**
  35834. * Defines the pointer panning sensibility or how fast is the camera moving.
  35835. */
  35836. panningSensibility: number;
  35837. /**
  35838. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35839. */
  35840. multiTouchPanning: boolean;
  35841. /**
  35842. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35843. * zoom (pinch) through multitouch.
  35844. */
  35845. multiTouchPanAndZoom: boolean;
  35846. /**
  35847. * Revers pinch action direction.
  35848. */
  35849. pinchInwards: boolean;
  35850. private _isPanClick;
  35851. private _twoFingerActivityCount;
  35852. private _isPinching;
  35853. /**
  35854. * Called on pointer POINTERMOVE event if only a single touch is active.
  35855. */
  35856. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35857. /**
  35858. * Called on pointer POINTERDOUBLETAP event.
  35859. */
  35860. protected onDoubleTap(type: string): void;
  35861. /**
  35862. * Called on pointer POINTERMOVE event if multiple touches are active.
  35863. */
  35864. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35865. /**
  35866. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35867. * press.
  35868. */
  35869. protected onButtonDown(evt: PointerEvent): void;
  35870. /**
  35871. * Called each time a new POINTERUP event occurs. Ie, for each button
  35872. * release.
  35873. */
  35874. protected onButtonUp(evt: PointerEvent): void;
  35875. /**
  35876. * Called when window becomes inactive.
  35877. */
  35878. protected onLostFocus(): void;
  35879. }
  35880. }
  35881. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35882. import { Nullable } from "babylonjs/types";
  35883. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35884. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35885. /**
  35886. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35888. */
  35889. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35890. /**
  35891. * Defines the camera the input is attached to.
  35892. */
  35893. camera: ArcRotateCamera;
  35894. /**
  35895. * Defines the list of key codes associated with the up action (increase alpha)
  35896. */
  35897. keysUp: number[];
  35898. /**
  35899. * Defines the list of key codes associated with the down action (decrease alpha)
  35900. */
  35901. keysDown: number[];
  35902. /**
  35903. * Defines the list of key codes associated with the left action (increase beta)
  35904. */
  35905. keysLeft: number[];
  35906. /**
  35907. * Defines the list of key codes associated with the right action (decrease beta)
  35908. */
  35909. keysRight: number[];
  35910. /**
  35911. * Defines the list of key codes associated with the reset action.
  35912. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35913. */
  35914. keysReset: number[];
  35915. /**
  35916. * Defines the panning sensibility of the inputs.
  35917. * (How fast is the camera paning)
  35918. */
  35919. panningSensibility: number;
  35920. /**
  35921. * Defines the zooming sensibility of the inputs.
  35922. * (How fast is the camera zooming)
  35923. */
  35924. zoomingSensibility: number;
  35925. /**
  35926. * Defines wether maintaining the alt key down switch the movement mode from
  35927. * orientation to zoom.
  35928. */
  35929. useAltToZoom: boolean;
  35930. /**
  35931. * Rotation speed of the camera
  35932. */
  35933. angularSpeed: number;
  35934. private _keys;
  35935. private _ctrlPressed;
  35936. private _altPressed;
  35937. private _onCanvasBlurObserver;
  35938. private _onKeyboardObserver;
  35939. private _engine;
  35940. private _scene;
  35941. /**
  35942. * Attach the input controls to a specific dom element to get the input from.
  35943. * @param element Defines the element the controls should be listened from
  35944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35945. */
  35946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35947. /**
  35948. * Detach the current controls from the specified dom element.
  35949. * @param element Defines the element to stop listening the inputs from
  35950. */
  35951. detachControl(element: Nullable<HTMLElement>): void;
  35952. /**
  35953. * Update the current camera state depending on the inputs that have been used this frame.
  35954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35955. */
  35956. checkInputs(): void;
  35957. /**
  35958. * Gets the class name of the current intput.
  35959. * @returns the class name
  35960. */
  35961. getClassName(): string;
  35962. /**
  35963. * Get the friendly name associated with the input class.
  35964. * @returns the input friendly name
  35965. */
  35966. getSimpleName(): string;
  35967. }
  35968. }
  35969. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35970. import { Nullable } from "babylonjs/types";
  35971. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35973. /**
  35974. * Manage the mouse wheel inputs to control an arc rotate camera.
  35975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35976. */
  35977. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35978. /**
  35979. * Defines the camera the input is attached to.
  35980. */
  35981. camera: ArcRotateCamera;
  35982. /**
  35983. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35984. */
  35985. wheelPrecision: number;
  35986. /**
  35987. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35988. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35989. */
  35990. wheelDeltaPercentage: number;
  35991. private _wheel;
  35992. private _observer;
  35993. /**
  35994. * Attach the input controls to a specific dom element to get the input from.
  35995. * @param element Defines the element the controls should be listened from
  35996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35997. */
  35998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35999. /**
  36000. * Detach the current controls from the specified dom element.
  36001. * @param element Defines the element to stop listening the inputs from
  36002. */
  36003. detachControl(element: Nullable<HTMLElement>): void;
  36004. /**
  36005. * Gets the class name of the current intput.
  36006. * @returns the class name
  36007. */
  36008. getClassName(): string;
  36009. /**
  36010. * Get the friendly name associated with the input class.
  36011. * @returns the input friendly name
  36012. */
  36013. getSimpleName(): string;
  36014. }
  36015. }
  36016. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36017. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36018. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36019. /**
  36020. * Default Inputs manager for the ArcRotateCamera.
  36021. * It groups all the default supported inputs for ease of use.
  36022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36023. */
  36024. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36025. /**
  36026. * Instantiates a new ArcRotateCameraInputsManager.
  36027. * @param camera Defines the camera the inputs belong to
  36028. */
  36029. constructor(camera: ArcRotateCamera);
  36030. /**
  36031. * Add mouse wheel input support to the input manager.
  36032. * @returns the current input manager
  36033. */
  36034. addMouseWheel(): ArcRotateCameraInputsManager;
  36035. /**
  36036. * Add pointers input support to the input manager.
  36037. * @returns the current input manager
  36038. */
  36039. addPointers(): ArcRotateCameraInputsManager;
  36040. /**
  36041. * Add keyboard input support to the input manager.
  36042. * @returns the current input manager
  36043. */
  36044. addKeyboard(): ArcRotateCameraInputsManager;
  36045. }
  36046. }
  36047. declare module "babylonjs/Cameras/arcRotateCamera" {
  36048. import { Observable } from "babylonjs/Misc/observable";
  36049. import { Nullable } from "babylonjs/types";
  36050. import { Scene } from "babylonjs/scene";
  36051. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36053. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36054. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36055. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36056. import { Camera } from "babylonjs/Cameras/camera";
  36057. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36058. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36059. import { Collider } from "babylonjs/Collisions/collider";
  36060. /**
  36061. * This represents an orbital type of camera.
  36062. *
  36063. * 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.
  36064. * 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.
  36065. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36066. */
  36067. export class ArcRotateCamera extends TargetCamera {
  36068. /**
  36069. * Defines the rotation angle of the camera along the longitudinal axis.
  36070. */
  36071. alpha: number;
  36072. /**
  36073. * Defines the rotation angle of the camera along the latitudinal axis.
  36074. */
  36075. beta: number;
  36076. /**
  36077. * Defines the radius of the camera from it s target point.
  36078. */
  36079. radius: number;
  36080. protected _target: Vector3;
  36081. protected _targetHost: Nullable<AbstractMesh>;
  36082. /**
  36083. * Defines the target point of the camera.
  36084. * The camera looks towards it form the radius distance.
  36085. */
  36086. target: Vector3;
  36087. /**
  36088. * Define the current local position of the camera in the scene
  36089. */
  36090. position: Vector3;
  36091. protected _upVector: Vector3;
  36092. protected _upToYMatrix: Matrix;
  36093. protected _YToUpMatrix: Matrix;
  36094. /**
  36095. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36096. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36097. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36098. */
  36099. upVector: Vector3;
  36100. /**
  36101. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36102. */
  36103. setMatUp(): void;
  36104. /**
  36105. * Current inertia value on the longitudinal axis.
  36106. * The bigger this number the longer it will take for the camera to stop.
  36107. */
  36108. inertialAlphaOffset: number;
  36109. /**
  36110. * Current inertia value on the latitudinal axis.
  36111. * The bigger this number the longer it will take for the camera to stop.
  36112. */
  36113. inertialBetaOffset: number;
  36114. /**
  36115. * Current inertia value on the radius axis.
  36116. * The bigger this number the longer it will take for the camera to stop.
  36117. */
  36118. inertialRadiusOffset: number;
  36119. /**
  36120. * Minimum allowed angle on the longitudinal axis.
  36121. * This can help limiting how the Camera is able to move in the scene.
  36122. */
  36123. lowerAlphaLimit: Nullable<number>;
  36124. /**
  36125. * Maximum allowed angle on the longitudinal axis.
  36126. * This can help limiting how the Camera is able to move in the scene.
  36127. */
  36128. upperAlphaLimit: Nullable<number>;
  36129. /**
  36130. * Minimum allowed angle on the latitudinal axis.
  36131. * This can help limiting how the Camera is able to move in the scene.
  36132. */
  36133. lowerBetaLimit: number;
  36134. /**
  36135. * Maximum allowed angle on the latitudinal axis.
  36136. * This can help limiting how the Camera is able to move in the scene.
  36137. */
  36138. upperBetaLimit: number;
  36139. /**
  36140. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36141. * This can help limiting how the Camera is able to move in the scene.
  36142. */
  36143. lowerRadiusLimit: Nullable<number>;
  36144. /**
  36145. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36146. * This can help limiting how the Camera is able to move in the scene.
  36147. */
  36148. upperRadiusLimit: Nullable<number>;
  36149. /**
  36150. * Defines the current inertia value used during panning of the camera along the X axis.
  36151. */
  36152. inertialPanningX: number;
  36153. /**
  36154. * Defines the current inertia value used during panning of the camera along the Y axis.
  36155. */
  36156. inertialPanningY: number;
  36157. /**
  36158. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36159. * Basically if your fingers moves away from more than this distance you will be considered
  36160. * in pinch mode.
  36161. */
  36162. pinchToPanMaxDistance: number;
  36163. /**
  36164. * Defines the maximum distance the camera can pan.
  36165. * This could help keeping the cammera always in your scene.
  36166. */
  36167. panningDistanceLimit: Nullable<number>;
  36168. /**
  36169. * Defines the target of the camera before paning.
  36170. */
  36171. panningOriginTarget: Vector3;
  36172. /**
  36173. * Defines the value of the inertia used during panning.
  36174. * 0 would mean stop inertia and one would mean no decelleration at all.
  36175. */
  36176. panningInertia: number;
  36177. /**
  36178. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36179. */
  36180. angularSensibilityX: number;
  36181. /**
  36182. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36183. */
  36184. angularSensibilityY: number;
  36185. /**
  36186. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36187. */
  36188. pinchPrecision: number;
  36189. /**
  36190. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36191. * It will be used instead of pinchDeltaPrecision if different from 0.
  36192. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36193. */
  36194. pinchDeltaPercentage: number;
  36195. /**
  36196. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36197. */
  36198. panningSensibility: number;
  36199. /**
  36200. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36201. */
  36202. keysUp: number[];
  36203. /**
  36204. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36205. */
  36206. keysDown: number[];
  36207. /**
  36208. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36209. */
  36210. keysLeft: number[];
  36211. /**
  36212. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36213. */
  36214. keysRight: number[];
  36215. /**
  36216. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36217. */
  36218. wheelPrecision: number;
  36219. /**
  36220. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36221. * It will be used instead of pinchDeltaPrecision if different from 0.
  36222. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36223. */
  36224. wheelDeltaPercentage: number;
  36225. /**
  36226. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36227. */
  36228. zoomOnFactor: number;
  36229. /**
  36230. * Defines a screen offset for the camera position.
  36231. */
  36232. targetScreenOffset: Vector2;
  36233. /**
  36234. * Allows the camera to be completely reversed.
  36235. * If false the camera can not arrive upside down.
  36236. */
  36237. allowUpsideDown: boolean;
  36238. /**
  36239. * Define if double tap/click is used to restore the previously saved state of the camera.
  36240. */
  36241. useInputToRestoreState: boolean;
  36242. /** @hidden */
  36243. _viewMatrix: Matrix;
  36244. /** @hidden */
  36245. _useCtrlForPanning: boolean;
  36246. /** @hidden */
  36247. _panningMouseButton: number;
  36248. /**
  36249. * Defines the input associated to the camera.
  36250. */
  36251. inputs: ArcRotateCameraInputsManager;
  36252. /** @hidden */
  36253. _reset: () => void;
  36254. /**
  36255. * Defines the allowed panning axis.
  36256. */
  36257. panningAxis: Vector3;
  36258. protected _localDirection: Vector3;
  36259. protected _transformedDirection: Vector3;
  36260. private _bouncingBehavior;
  36261. /**
  36262. * Gets the bouncing behavior of the camera if it has been enabled.
  36263. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36264. */
  36265. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36266. /**
  36267. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36269. */
  36270. useBouncingBehavior: boolean;
  36271. private _framingBehavior;
  36272. /**
  36273. * Gets the framing behavior of the camera if it has been enabled.
  36274. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36275. */
  36276. readonly framingBehavior: Nullable<FramingBehavior>;
  36277. /**
  36278. * Defines if the framing behavior of the camera is enabled on the camera.
  36279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36280. */
  36281. useFramingBehavior: boolean;
  36282. private _autoRotationBehavior;
  36283. /**
  36284. * Gets the auto rotation behavior of the camera if it has been enabled.
  36285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36286. */
  36287. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36288. /**
  36289. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36291. */
  36292. useAutoRotationBehavior: boolean;
  36293. /**
  36294. * Observable triggered when the mesh target has been changed on the camera.
  36295. */
  36296. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36297. /**
  36298. * Event raised when the camera is colliding with a mesh.
  36299. */
  36300. onCollide: (collidedMesh: AbstractMesh) => void;
  36301. /**
  36302. * Defines whether the camera should check collision with the objects oh the scene.
  36303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36304. */
  36305. checkCollisions: boolean;
  36306. /**
  36307. * Defines the collision radius of the camera.
  36308. * This simulates a sphere around the camera.
  36309. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36310. */
  36311. collisionRadius: Vector3;
  36312. protected _collider: Collider;
  36313. protected _previousPosition: Vector3;
  36314. protected _collisionVelocity: Vector3;
  36315. protected _newPosition: Vector3;
  36316. protected _previousAlpha: number;
  36317. protected _previousBeta: number;
  36318. protected _previousRadius: number;
  36319. protected _collisionTriggered: boolean;
  36320. protected _targetBoundingCenter: Nullable<Vector3>;
  36321. private _computationVector;
  36322. /**
  36323. * Instantiates a new ArcRotateCamera in a given scene
  36324. * @param name Defines the name of the camera
  36325. * @param alpha Defines the camera rotation along the logitudinal axis
  36326. * @param beta Defines the camera rotation along the latitudinal axis
  36327. * @param radius Defines the camera distance from its target
  36328. * @param target Defines the camera target
  36329. * @param scene Defines the scene the camera belongs to
  36330. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36331. */
  36332. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36333. /** @hidden */
  36334. _initCache(): void;
  36335. /** @hidden */
  36336. _updateCache(ignoreParentClass?: boolean): void;
  36337. protected _getTargetPosition(): Vector3;
  36338. private _storedAlpha;
  36339. private _storedBeta;
  36340. private _storedRadius;
  36341. private _storedTarget;
  36342. /**
  36343. * Stores the current state of the camera (alpha, beta, radius and target)
  36344. * @returns the camera itself
  36345. */
  36346. storeState(): Camera;
  36347. /**
  36348. * @hidden
  36349. * Restored camera state. You must call storeState() first
  36350. */
  36351. _restoreStateValues(): boolean;
  36352. /** @hidden */
  36353. _isSynchronizedViewMatrix(): boolean;
  36354. /**
  36355. * Attached controls to the current camera.
  36356. * @param element Defines the element the controls should be listened from
  36357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36358. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36359. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36360. */
  36361. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36362. /**
  36363. * Detach the current controls from the camera.
  36364. * The camera will stop reacting to inputs.
  36365. * @param element Defines the element to stop listening the inputs from
  36366. */
  36367. detachControl(element: HTMLElement): void;
  36368. /** @hidden */
  36369. _checkInputs(): void;
  36370. protected _checkLimits(): void;
  36371. /**
  36372. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36373. */
  36374. rebuildAnglesAndRadius(): void;
  36375. /**
  36376. * Use a position to define the current camera related information like aplha, beta and radius
  36377. * @param position Defines the position to set the camera at
  36378. */
  36379. setPosition(position: Vector3): void;
  36380. /**
  36381. * Defines the target the camera should look at.
  36382. * This will automatically adapt alpha beta and radius to fit within the new target.
  36383. * @param target Defines the new target as a Vector or a mesh
  36384. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36385. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36386. */
  36387. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36388. /** @hidden */
  36389. _getViewMatrix(): Matrix;
  36390. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36391. /**
  36392. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36393. * @param meshes Defines the mesh to zoom on
  36394. * @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)
  36395. */
  36396. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36397. /**
  36398. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36399. * The target will be changed but the radius
  36400. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36401. * @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)
  36402. */
  36403. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36404. min: Vector3;
  36405. max: Vector3;
  36406. distance: number;
  36407. }, doNotUpdateMaxZ?: boolean): void;
  36408. /**
  36409. * @override
  36410. * Override Camera.createRigCamera
  36411. */
  36412. createRigCamera(name: string, cameraIndex: number): Camera;
  36413. /**
  36414. * @hidden
  36415. * @override
  36416. * Override Camera._updateRigCameras
  36417. */
  36418. _updateRigCameras(): void;
  36419. /**
  36420. * Destroy the camera and release the current resources hold by it.
  36421. */
  36422. dispose(): void;
  36423. /**
  36424. * Gets the current object class name.
  36425. * @return the class name
  36426. */
  36427. getClassName(): string;
  36428. }
  36429. }
  36430. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36431. import { Behavior } from "babylonjs/Behaviors/behavior";
  36432. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36433. /**
  36434. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36435. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36436. */
  36437. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36438. /**
  36439. * Gets the name of the behavior.
  36440. */
  36441. readonly name: string;
  36442. private _zoomStopsAnimation;
  36443. private _idleRotationSpeed;
  36444. private _idleRotationWaitTime;
  36445. private _idleRotationSpinupTime;
  36446. /**
  36447. * Sets the flag that indicates if user zooming should stop animation.
  36448. */
  36449. /**
  36450. * Gets the flag that indicates if user zooming should stop animation.
  36451. */
  36452. zoomStopsAnimation: boolean;
  36453. /**
  36454. * Sets the default speed at which the camera rotates around the model.
  36455. */
  36456. /**
  36457. * Gets the default speed at which the camera rotates around the model.
  36458. */
  36459. idleRotationSpeed: number;
  36460. /**
  36461. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36462. */
  36463. /**
  36464. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36465. */
  36466. idleRotationWaitTime: number;
  36467. /**
  36468. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36469. */
  36470. /**
  36471. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36472. */
  36473. idleRotationSpinupTime: number;
  36474. /**
  36475. * Gets a value indicating if the camera is currently rotating because of this behavior
  36476. */
  36477. readonly rotationInProgress: boolean;
  36478. private _onPrePointerObservableObserver;
  36479. private _onAfterCheckInputsObserver;
  36480. private _attachedCamera;
  36481. private _isPointerDown;
  36482. private _lastFrameTime;
  36483. private _lastInteractionTime;
  36484. private _cameraRotationSpeed;
  36485. /**
  36486. * Initializes the behavior.
  36487. */
  36488. init(): void;
  36489. /**
  36490. * Attaches the behavior to its arc rotate camera.
  36491. * @param camera Defines the camera to attach the behavior to
  36492. */
  36493. attach(camera: ArcRotateCamera): void;
  36494. /**
  36495. * Detaches the behavior from its current arc rotate camera.
  36496. */
  36497. detach(): void;
  36498. /**
  36499. * Returns true if user is scrolling.
  36500. * @return true if user is scrolling.
  36501. */
  36502. private _userIsZooming;
  36503. private _lastFrameRadius;
  36504. private _shouldAnimationStopForInteraction;
  36505. /**
  36506. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36507. */
  36508. private _applyUserInteraction;
  36509. private _userIsMoving;
  36510. }
  36511. }
  36512. declare module "babylonjs/Behaviors/Cameras/index" {
  36513. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36514. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36515. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36516. }
  36517. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36518. import { Mesh } from "babylonjs/Meshes/mesh";
  36519. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36520. import { Behavior } from "babylonjs/Behaviors/behavior";
  36521. /**
  36522. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36523. */
  36524. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36525. private ui;
  36526. /**
  36527. * The name of the behavior
  36528. */
  36529. name: string;
  36530. /**
  36531. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36532. */
  36533. distanceAwayFromFace: number;
  36534. /**
  36535. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36536. */
  36537. distanceAwayFromBottomOfFace: number;
  36538. private _faceVectors;
  36539. private _target;
  36540. private _scene;
  36541. private _onRenderObserver;
  36542. private _tmpMatrix;
  36543. private _tmpVector;
  36544. /**
  36545. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36546. * @param ui The transform node that should be attched to the mesh
  36547. */
  36548. constructor(ui: TransformNode);
  36549. /**
  36550. * Initializes the behavior
  36551. */
  36552. init(): void;
  36553. private _closestFace;
  36554. private _zeroVector;
  36555. private _lookAtTmpMatrix;
  36556. private _lookAtToRef;
  36557. /**
  36558. * Attaches the AttachToBoxBehavior to the passed in mesh
  36559. * @param target The mesh that the specified node will be attached to
  36560. */
  36561. attach(target: Mesh): void;
  36562. /**
  36563. * Detaches the behavior from the mesh
  36564. */
  36565. detach(): void;
  36566. }
  36567. }
  36568. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36569. import { Behavior } from "babylonjs/Behaviors/behavior";
  36570. import { Mesh } from "babylonjs/Meshes/mesh";
  36571. /**
  36572. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36573. */
  36574. export class FadeInOutBehavior implements Behavior<Mesh> {
  36575. /**
  36576. * Time in milliseconds to delay before fading in (Default: 0)
  36577. */
  36578. delay: number;
  36579. /**
  36580. * Time in milliseconds for the mesh to fade in (Default: 300)
  36581. */
  36582. fadeInTime: number;
  36583. private _millisecondsPerFrame;
  36584. private _hovered;
  36585. private _hoverValue;
  36586. private _ownerNode;
  36587. /**
  36588. * Instatiates the FadeInOutBehavior
  36589. */
  36590. constructor();
  36591. /**
  36592. * The name of the behavior
  36593. */
  36594. readonly name: string;
  36595. /**
  36596. * Initializes the behavior
  36597. */
  36598. init(): void;
  36599. /**
  36600. * Attaches the fade behavior on the passed in mesh
  36601. * @param ownerNode The mesh that will be faded in/out once attached
  36602. */
  36603. attach(ownerNode: Mesh): void;
  36604. /**
  36605. * Detaches the behavior from the mesh
  36606. */
  36607. detach(): void;
  36608. /**
  36609. * Triggers the mesh to begin fading in or out
  36610. * @param value if the object should fade in or out (true to fade in)
  36611. */
  36612. fadeIn(value: boolean): void;
  36613. private _update;
  36614. private _setAllVisibility;
  36615. }
  36616. }
  36617. declare module "babylonjs/Misc/pivotTools" {
  36618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36619. /**
  36620. * Class containing a set of static utilities functions for managing Pivots
  36621. * @hidden
  36622. */
  36623. export class PivotTools {
  36624. private static _PivotCached;
  36625. private static _OldPivotPoint;
  36626. private static _PivotTranslation;
  36627. private static _PivotTmpVector;
  36628. /** @hidden */
  36629. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36630. /** @hidden */
  36631. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36632. }
  36633. }
  36634. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36635. import { Scene } from "babylonjs/scene";
  36636. import { Vector4, Plane } from "babylonjs/Maths/math";
  36637. import { Mesh } from "babylonjs/Meshes/mesh";
  36638. import { Nullable } from "babylonjs/types";
  36639. /**
  36640. * Class containing static functions to help procedurally build meshes
  36641. */
  36642. export class PlaneBuilder {
  36643. /**
  36644. * Creates a plane mesh
  36645. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36646. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36647. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36651. * @param name defines the name of the mesh
  36652. * @param options defines the options used to create the mesh
  36653. * @param scene defines the hosting scene
  36654. * @returns the plane mesh
  36655. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36656. */
  36657. static CreatePlane(name: string, options: {
  36658. size?: number;
  36659. width?: number;
  36660. height?: number;
  36661. sideOrientation?: number;
  36662. frontUVs?: Vector4;
  36663. backUVs?: Vector4;
  36664. updatable?: boolean;
  36665. sourcePlane?: Plane;
  36666. }, scene?: Nullable<Scene>): Mesh;
  36667. }
  36668. }
  36669. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36670. import { Behavior } from "babylonjs/Behaviors/behavior";
  36671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36672. import { Observable } from "babylonjs/Misc/observable";
  36673. import { Vector3 } from "babylonjs/Maths/math";
  36674. import { Ray } from "babylonjs/Culling/ray";
  36675. import "babylonjs/Meshes/Builders/planeBuilder";
  36676. /**
  36677. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36678. */
  36679. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36680. private static _AnyMouseID;
  36681. private _attachedNode;
  36682. private _dragPlane;
  36683. private _scene;
  36684. private _pointerObserver;
  36685. private _beforeRenderObserver;
  36686. private static _planeScene;
  36687. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36688. /**
  36689. * 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)
  36690. */
  36691. maxDragAngle: number;
  36692. /**
  36693. * @hidden
  36694. */
  36695. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36696. /**
  36697. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36698. */
  36699. currentDraggingPointerID: number;
  36700. /**
  36701. * The last position where the pointer hit the drag plane in world space
  36702. */
  36703. lastDragPosition: Vector3;
  36704. /**
  36705. * If the behavior is currently in a dragging state
  36706. */
  36707. dragging: boolean;
  36708. /**
  36709. * 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)
  36710. */
  36711. dragDeltaRatio: number;
  36712. /**
  36713. * If the drag plane orientation should be updated during the dragging (Default: true)
  36714. */
  36715. updateDragPlane: boolean;
  36716. private _debugMode;
  36717. private _moving;
  36718. /**
  36719. * Fires each time the attached mesh is dragged with the pointer
  36720. * * delta between last drag position and current drag position in world space
  36721. * * dragDistance along the drag axis
  36722. * * dragPlaneNormal normal of the current drag plane used during the drag
  36723. * * dragPlanePoint in world space where the drag intersects the drag plane
  36724. */
  36725. onDragObservable: Observable<{
  36726. delta: Vector3;
  36727. dragPlanePoint: Vector3;
  36728. dragPlaneNormal: Vector3;
  36729. dragDistance: number;
  36730. pointerId: number;
  36731. }>;
  36732. /**
  36733. * Fires each time a drag begins (eg. mouse down on mesh)
  36734. */
  36735. onDragStartObservable: Observable<{
  36736. dragPlanePoint: Vector3;
  36737. pointerId: number;
  36738. }>;
  36739. /**
  36740. * Fires each time a drag ends (eg. mouse release after drag)
  36741. */
  36742. onDragEndObservable: Observable<{
  36743. dragPlanePoint: Vector3;
  36744. pointerId: number;
  36745. }>;
  36746. /**
  36747. * If the attached mesh should be moved when dragged
  36748. */
  36749. moveAttached: boolean;
  36750. /**
  36751. * If the drag behavior will react to drag events (Default: true)
  36752. */
  36753. enabled: boolean;
  36754. /**
  36755. * If camera controls should be detached during the drag
  36756. */
  36757. detachCameraControls: boolean;
  36758. /**
  36759. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36760. */
  36761. useObjectOrienationForDragging: boolean;
  36762. private _options;
  36763. /**
  36764. * Creates a pointer drag behavior that can be attached to a mesh
  36765. * @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)
  36766. */
  36767. constructor(options?: {
  36768. dragAxis?: Vector3;
  36769. dragPlaneNormal?: Vector3;
  36770. });
  36771. /**
  36772. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36773. */
  36774. validateDrag: (targetPosition: Vector3) => boolean;
  36775. /**
  36776. * The name of the behavior
  36777. */
  36778. readonly name: string;
  36779. /**
  36780. * Initializes the behavior
  36781. */
  36782. init(): void;
  36783. private _tmpVector;
  36784. private _alternatePickedPoint;
  36785. private _worldDragAxis;
  36786. private _targetPosition;
  36787. private _attachedElement;
  36788. /**
  36789. * Attaches the drag behavior the passed in mesh
  36790. * @param ownerNode The mesh that will be dragged around once attached
  36791. */
  36792. attach(ownerNode: AbstractMesh): void;
  36793. /**
  36794. * Force relase the drag action by code.
  36795. */
  36796. releaseDrag(): void;
  36797. private _startDragRay;
  36798. private _lastPointerRay;
  36799. /**
  36800. * Simulates the start of a pointer drag event on the behavior
  36801. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36802. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36803. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36804. */
  36805. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36806. private _startDrag;
  36807. private _dragDelta;
  36808. private _moveDrag;
  36809. private _pickWithRayOnDragPlane;
  36810. private _pointA;
  36811. private _pointB;
  36812. private _pointC;
  36813. private _lineA;
  36814. private _lineB;
  36815. private _localAxis;
  36816. private _lookAt;
  36817. private _updateDragPlanePosition;
  36818. /**
  36819. * Detaches the behavior from the mesh
  36820. */
  36821. detach(): void;
  36822. }
  36823. }
  36824. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36825. import { Mesh } from "babylonjs/Meshes/mesh";
  36826. import { Behavior } from "babylonjs/Behaviors/behavior";
  36827. /**
  36828. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36829. */
  36830. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36831. private _dragBehaviorA;
  36832. private _dragBehaviorB;
  36833. private _startDistance;
  36834. private _initialScale;
  36835. private _targetScale;
  36836. private _ownerNode;
  36837. private _sceneRenderObserver;
  36838. /**
  36839. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36840. */
  36841. constructor();
  36842. /**
  36843. * The name of the behavior
  36844. */
  36845. readonly name: string;
  36846. /**
  36847. * Initializes the behavior
  36848. */
  36849. init(): void;
  36850. private _getCurrentDistance;
  36851. /**
  36852. * Attaches the scale behavior the passed in mesh
  36853. * @param ownerNode The mesh that will be scaled around once attached
  36854. */
  36855. attach(ownerNode: Mesh): void;
  36856. /**
  36857. * Detaches the behavior from the mesh
  36858. */
  36859. detach(): void;
  36860. }
  36861. }
  36862. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36863. import { Behavior } from "babylonjs/Behaviors/behavior";
  36864. import { Mesh } from "babylonjs/Meshes/mesh";
  36865. import { Observable } from "babylonjs/Misc/observable";
  36866. /**
  36867. * 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
  36868. */
  36869. export class SixDofDragBehavior implements Behavior<Mesh> {
  36870. private static _virtualScene;
  36871. private _ownerNode;
  36872. private _sceneRenderObserver;
  36873. private _scene;
  36874. private _targetPosition;
  36875. private _virtualOriginMesh;
  36876. private _virtualDragMesh;
  36877. private _pointerObserver;
  36878. private _moving;
  36879. private _startingOrientation;
  36880. /**
  36881. * 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)
  36882. */
  36883. private zDragFactor;
  36884. /**
  36885. * If the object should rotate to face the drag origin
  36886. */
  36887. rotateDraggedObject: boolean;
  36888. /**
  36889. * If the behavior is currently in a dragging state
  36890. */
  36891. dragging: boolean;
  36892. /**
  36893. * 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)
  36894. */
  36895. dragDeltaRatio: number;
  36896. /**
  36897. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36898. */
  36899. currentDraggingPointerID: number;
  36900. /**
  36901. * If camera controls should be detached during the drag
  36902. */
  36903. detachCameraControls: boolean;
  36904. /**
  36905. * Fires each time a drag starts
  36906. */
  36907. onDragStartObservable: Observable<{}>;
  36908. /**
  36909. * Fires each time a drag ends (eg. mouse release after drag)
  36910. */
  36911. onDragEndObservable: Observable<{}>;
  36912. /**
  36913. * 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
  36914. */
  36915. constructor();
  36916. /**
  36917. * The name of the behavior
  36918. */
  36919. readonly name: string;
  36920. /**
  36921. * Initializes the behavior
  36922. */
  36923. init(): void;
  36924. /**
  36925. * Attaches the scale behavior the passed in mesh
  36926. * @param ownerNode The mesh that will be scaled around once attached
  36927. */
  36928. attach(ownerNode: Mesh): void;
  36929. /**
  36930. * Detaches the behavior from the mesh
  36931. */
  36932. detach(): void;
  36933. }
  36934. }
  36935. declare module "babylonjs/Behaviors/Meshes/index" {
  36936. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36937. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36938. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36939. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36940. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36941. }
  36942. declare module "babylonjs/Behaviors/index" {
  36943. export * from "babylonjs/Behaviors/behavior";
  36944. export * from "babylonjs/Behaviors/Cameras/index";
  36945. export * from "babylonjs/Behaviors/Meshes/index";
  36946. }
  36947. declare module "babylonjs/Bones/boneIKController" {
  36948. import { Bone } from "babylonjs/Bones/bone";
  36949. import { Vector3 } from "babylonjs/Maths/math";
  36950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36951. import { Nullable } from "babylonjs/types";
  36952. /**
  36953. * Class used to apply inverse kinematics to bones
  36954. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36955. */
  36956. export class BoneIKController {
  36957. private static _tmpVecs;
  36958. private static _tmpQuat;
  36959. private static _tmpMats;
  36960. /**
  36961. * Gets or sets the target mesh
  36962. */
  36963. targetMesh: AbstractMesh;
  36964. /** Gets or sets the mesh used as pole */
  36965. poleTargetMesh: AbstractMesh;
  36966. /**
  36967. * Gets or sets the bone used as pole
  36968. */
  36969. poleTargetBone: Nullable<Bone>;
  36970. /**
  36971. * Gets or sets the target position
  36972. */
  36973. targetPosition: Vector3;
  36974. /**
  36975. * Gets or sets the pole target position
  36976. */
  36977. poleTargetPosition: Vector3;
  36978. /**
  36979. * Gets or sets the pole target local offset
  36980. */
  36981. poleTargetLocalOffset: Vector3;
  36982. /**
  36983. * Gets or sets the pole angle
  36984. */
  36985. poleAngle: number;
  36986. /**
  36987. * Gets or sets the mesh associated with the controller
  36988. */
  36989. mesh: AbstractMesh;
  36990. /**
  36991. * 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)
  36992. */
  36993. slerpAmount: number;
  36994. private _bone1Quat;
  36995. private _bone1Mat;
  36996. private _bone2Ang;
  36997. private _bone1;
  36998. private _bone2;
  36999. private _bone1Length;
  37000. private _bone2Length;
  37001. private _maxAngle;
  37002. private _maxReach;
  37003. private _rightHandedSystem;
  37004. private _bendAxis;
  37005. private _slerping;
  37006. private _adjustRoll;
  37007. /**
  37008. * Gets or sets maximum allowed angle
  37009. */
  37010. maxAngle: number;
  37011. /**
  37012. * Creates a new BoneIKController
  37013. * @param mesh defines the mesh to control
  37014. * @param bone defines the bone to control
  37015. * @param options defines options to set up the controller
  37016. */
  37017. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37018. targetMesh?: AbstractMesh;
  37019. poleTargetMesh?: AbstractMesh;
  37020. poleTargetBone?: Bone;
  37021. poleTargetLocalOffset?: Vector3;
  37022. poleAngle?: number;
  37023. bendAxis?: Vector3;
  37024. maxAngle?: number;
  37025. slerpAmount?: number;
  37026. });
  37027. private _setMaxAngle;
  37028. /**
  37029. * Force the controller to update the bones
  37030. */
  37031. update(): void;
  37032. }
  37033. }
  37034. declare module "babylonjs/Bones/boneLookController" {
  37035. import { Vector3, Space } from "babylonjs/Maths/math";
  37036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37037. import { Bone } from "babylonjs/Bones/bone";
  37038. /**
  37039. * Class used to make a bone look toward a point in space
  37040. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37041. */
  37042. export class BoneLookController {
  37043. private static _tmpVecs;
  37044. private static _tmpQuat;
  37045. private static _tmpMats;
  37046. /**
  37047. * The target Vector3 that the bone will look at
  37048. */
  37049. target: Vector3;
  37050. /**
  37051. * The mesh that the bone is attached to
  37052. */
  37053. mesh: AbstractMesh;
  37054. /**
  37055. * The bone that will be looking to the target
  37056. */
  37057. bone: Bone;
  37058. /**
  37059. * The up axis of the coordinate system that is used when the bone is rotated
  37060. */
  37061. upAxis: Vector3;
  37062. /**
  37063. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37064. */
  37065. upAxisSpace: Space;
  37066. /**
  37067. * Used to make an adjustment to the yaw of the bone
  37068. */
  37069. adjustYaw: number;
  37070. /**
  37071. * Used to make an adjustment to the pitch of the bone
  37072. */
  37073. adjustPitch: number;
  37074. /**
  37075. * Used to make an adjustment to the roll of the bone
  37076. */
  37077. adjustRoll: number;
  37078. /**
  37079. * 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)
  37080. */
  37081. slerpAmount: number;
  37082. private _minYaw;
  37083. private _maxYaw;
  37084. private _minPitch;
  37085. private _maxPitch;
  37086. private _minYawSin;
  37087. private _minYawCos;
  37088. private _maxYawSin;
  37089. private _maxYawCos;
  37090. private _midYawConstraint;
  37091. private _minPitchTan;
  37092. private _maxPitchTan;
  37093. private _boneQuat;
  37094. private _slerping;
  37095. private _transformYawPitch;
  37096. private _transformYawPitchInv;
  37097. private _firstFrameSkipped;
  37098. private _yawRange;
  37099. private _fowardAxis;
  37100. /**
  37101. * Gets or sets the minimum yaw angle that the bone can look to
  37102. */
  37103. minYaw: number;
  37104. /**
  37105. * Gets or sets the maximum yaw angle that the bone can look to
  37106. */
  37107. maxYaw: number;
  37108. /**
  37109. * Gets or sets the minimum pitch angle that the bone can look to
  37110. */
  37111. minPitch: number;
  37112. /**
  37113. * Gets or sets the maximum pitch angle that the bone can look to
  37114. */
  37115. maxPitch: number;
  37116. /**
  37117. * Create a BoneLookController
  37118. * @param mesh the mesh that the bone belongs to
  37119. * @param bone the bone that will be looking to the target
  37120. * @param target the target Vector3 to look at
  37121. * @param options optional settings:
  37122. * * maxYaw: the maximum angle the bone will yaw to
  37123. * * minYaw: the minimum angle the bone will yaw to
  37124. * * maxPitch: the maximum angle the bone will pitch to
  37125. * * minPitch: the minimum angle the bone will yaw to
  37126. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37127. * * upAxis: the up axis of the coordinate system
  37128. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37129. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37130. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37131. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37132. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37133. * * adjustRoll: used to make an adjustment to the roll of the bone
  37134. **/
  37135. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37136. maxYaw?: number;
  37137. minYaw?: number;
  37138. maxPitch?: number;
  37139. minPitch?: number;
  37140. slerpAmount?: number;
  37141. upAxis?: Vector3;
  37142. upAxisSpace?: Space;
  37143. yawAxis?: Vector3;
  37144. pitchAxis?: Vector3;
  37145. adjustYaw?: number;
  37146. adjustPitch?: number;
  37147. adjustRoll?: number;
  37148. });
  37149. /**
  37150. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37151. */
  37152. update(): void;
  37153. private _getAngleDiff;
  37154. private _getAngleBetween;
  37155. private _isAngleBetween;
  37156. }
  37157. }
  37158. declare module "babylonjs/Bones/index" {
  37159. export * from "babylonjs/Bones/bone";
  37160. export * from "babylonjs/Bones/boneIKController";
  37161. export * from "babylonjs/Bones/boneLookController";
  37162. export * from "babylonjs/Bones/skeleton";
  37163. }
  37164. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37165. import { Nullable } from "babylonjs/types";
  37166. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37167. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37168. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37169. /**
  37170. * Manage the gamepad inputs to control an arc rotate camera.
  37171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37172. */
  37173. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37174. /**
  37175. * Defines the camera the input is attached to.
  37176. */
  37177. camera: ArcRotateCamera;
  37178. /**
  37179. * Defines the gamepad the input is gathering event from.
  37180. */
  37181. gamepad: Nullable<Gamepad>;
  37182. /**
  37183. * Defines the gamepad rotation sensiblity.
  37184. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37185. */
  37186. gamepadRotationSensibility: number;
  37187. /**
  37188. * Defines the gamepad move sensiblity.
  37189. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37190. */
  37191. gamepadMoveSensibility: number;
  37192. private _onGamepadConnectedObserver;
  37193. private _onGamepadDisconnectedObserver;
  37194. /**
  37195. * Attach the input controls to a specific dom element to get the input from.
  37196. * @param element Defines the element the controls should be listened from
  37197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37198. */
  37199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37200. /**
  37201. * Detach the current controls from the specified dom element.
  37202. * @param element Defines the element to stop listening the inputs from
  37203. */
  37204. detachControl(element: Nullable<HTMLElement>): void;
  37205. /**
  37206. * Update the current camera state depending on the inputs that have been used this frame.
  37207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37208. */
  37209. checkInputs(): void;
  37210. /**
  37211. * Gets the class name of the current intput.
  37212. * @returns the class name
  37213. */
  37214. getClassName(): string;
  37215. /**
  37216. * Get the friendly name associated with the input class.
  37217. * @returns the input friendly name
  37218. */
  37219. getSimpleName(): string;
  37220. }
  37221. }
  37222. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37223. import { Nullable } from "babylonjs/types";
  37224. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37225. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37226. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37227. interface ArcRotateCameraInputsManager {
  37228. /**
  37229. * Add orientation input support to the input manager.
  37230. * @returns the current input manager
  37231. */
  37232. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37233. }
  37234. }
  37235. /**
  37236. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37238. */
  37239. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37240. /**
  37241. * Defines the camera the input is attached to.
  37242. */
  37243. camera: ArcRotateCamera;
  37244. /**
  37245. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37246. */
  37247. alphaCorrection: number;
  37248. /**
  37249. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37250. */
  37251. gammaCorrection: number;
  37252. private _alpha;
  37253. private _gamma;
  37254. private _dirty;
  37255. private _deviceOrientationHandler;
  37256. /**
  37257. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37258. */
  37259. constructor();
  37260. /**
  37261. * Attach the input controls to a specific dom element to get the input from.
  37262. * @param element Defines the element the controls should be listened from
  37263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37264. */
  37265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37266. /** @hidden */
  37267. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37268. /**
  37269. * Update the current camera state depending on the inputs that have been used this frame.
  37270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37271. */
  37272. checkInputs(): void;
  37273. /**
  37274. * Detach the current controls from the specified dom element.
  37275. * @param element Defines the element to stop listening the inputs from
  37276. */
  37277. detachControl(element: Nullable<HTMLElement>): void;
  37278. /**
  37279. * Gets the class name of the current intput.
  37280. * @returns the class name
  37281. */
  37282. getClassName(): string;
  37283. /**
  37284. * Get the friendly name associated with the input class.
  37285. * @returns the input friendly name
  37286. */
  37287. getSimpleName(): string;
  37288. }
  37289. }
  37290. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37291. import { Nullable } from "babylonjs/types";
  37292. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37293. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37294. /**
  37295. * Listen to mouse events to control the camera.
  37296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37297. */
  37298. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37299. /**
  37300. * Defines the camera the input is attached to.
  37301. */
  37302. camera: FlyCamera;
  37303. /**
  37304. * Defines if touch is enabled. (Default is true.)
  37305. */
  37306. touchEnabled: boolean;
  37307. /**
  37308. * Defines the buttons associated with the input to handle camera rotation.
  37309. */
  37310. buttons: number[];
  37311. /**
  37312. * Assign buttons for Yaw control.
  37313. */
  37314. buttonsYaw: number[];
  37315. /**
  37316. * Assign buttons for Pitch control.
  37317. */
  37318. buttonsPitch: number[];
  37319. /**
  37320. * Assign buttons for Roll control.
  37321. */
  37322. buttonsRoll: number[];
  37323. /**
  37324. * Detect if any button is being pressed while mouse is moved.
  37325. * -1 = Mouse locked.
  37326. * 0 = Left button.
  37327. * 1 = Middle Button.
  37328. * 2 = Right Button.
  37329. */
  37330. activeButton: number;
  37331. /**
  37332. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37333. * Higher values reduce its sensitivity.
  37334. */
  37335. angularSensibility: number;
  37336. private _mousemoveCallback;
  37337. private _observer;
  37338. private _rollObserver;
  37339. private previousPosition;
  37340. private noPreventDefault;
  37341. private element;
  37342. /**
  37343. * Listen to mouse events to control the camera.
  37344. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37346. */
  37347. constructor(touchEnabled?: boolean);
  37348. /**
  37349. * Attach the mouse control to the HTML DOM element.
  37350. * @param element Defines the element that listens to the input events.
  37351. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37352. */
  37353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37354. /**
  37355. * Detach the current controls from the specified dom element.
  37356. * @param element Defines the element to stop listening the inputs from
  37357. */
  37358. detachControl(element: Nullable<HTMLElement>): void;
  37359. /**
  37360. * Gets the class name of the current input.
  37361. * @returns the class name.
  37362. */
  37363. getClassName(): string;
  37364. /**
  37365. * Get the friendly name associated with the input class.
  37366. * @returns the input's friendly name.
  37367. */
  37368. getSimpleName(): string;
  37369. private _pointerInput;
  37370. private _onMouseMove;
  37371. /**
  37372. * Rotate camera by mouse offset.
  37373. */
  37374. private rotateCamera;
  37375. }
  37376. }
  37377. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37378. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37379. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37380. /**
  37381. * Default Inputs manager for the FlyCamera.
  37382. * It groups all the default supported inputs for ease of use.
  37383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37384. */
  37385. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37386. /**
  37387. * Instantiates a new FlyCameraInputsManager.
  37388. * @param camera Defines the camera the inputs belong to.
  37389. */
  37390. constructor(camera: FlyCamera);
  37391. /**
  37392. * Add keyboard input support to the input manager.
  37393. * @returns the new FlyCameraKeyboardMoveInput().
  37394. */
  37395. addKeyboard(): FlyCameraInputsManager;
  37396. /**
  37397. * Add mouse input support to the input manager.
  37398. * @param touchEnabled Enable touch screen support.
  37399. * @returns the new FlyCameraMouseInput().
  37400. */
  37401. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37402. }
  37403. }
  37404. declare module "babylonjs/Cameras/flyCamera" {
  37405. import { Scene } from "babylonjs/scene";
  37406. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37408. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37409. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37410. /**
  37411. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37412. * such as in a 3D Space Shooter or a Flight Simulator.
  37413. */
  37414. export class FlyCamera extends TargetCamera {
  37415. /**
  37416. * Define the collision ellipsoid of the camera.
  37417. * This is helpful for simulating a camera body, like a player's body.
  37418. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37419. */
  37420. ellipsoid: Vector3;
  37421. /**
  37422. * Define an offset for the position of the ellipsoid around the camera.
  37423. * This can be helpful if the camera is attached away from the player's body center,
  37424. * such as at its head.
  37425. */
  37426. ellipsoidOffset: Vector3;
  37427. /**
  37428. * Enable or disable collisions of the camera with the rest of the scene objects.
  37429. */
  37430. checkCollisions: boolean;
  37431. /**
  37432. * Enable or disable gravity on the camera.
  37433. */
  37434. applyGravity: boolean;
  37435. /**
  37436. * Define the current direction the camera is moving to.
  37437. */
  37438. cameraDirection: Vector3;
  37439. /**
  37440. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37441. * This overrides and empties cameraRotation.
  37442. */
  37443. rotationQuaternion: Quaternion;
  37444. /**
  37445. * Track Roll to maintain the wanted Rolling when looking around.
  37446. */
  37447. _trackRoll: number;
  37448. /**
  37449. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37450. */
  37451. rollCorrect: number;
  37452. /**
  37453. * Mimic a banked turn, Rolling the camera when Yawing.
  37454. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37455. */
  37456. bankedTurn: boolean;
  37457. /**
  37458. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37459. */
  37460. bankedTurnLimit: number;
  37461. /**
  37462. * Value of 0 disables the banked Roll.
  37463. * Value of 1 is equal to the Yaw angle in radians.
  37464. */
  37465. bankedTurnMultiplier: number;
  37466. /**
  37467. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37468. */
  37469. inputs: FlyCameraInputsManager;
  37470. /**
  37471. * Gets the input sensibility for mouse input.
  37472. * Higher values reduce sensitivity.
  37473. */
  37474. /**
  37475. * Sets the input sensibility for a mouse input.
  37476. * Higher values reduce sensitivity.
  37477. */
  37478. angularSensibility: number;
  37479. /**
  37480. * Get the keys for camera movement forward.
  37481. */
  37482. /**
  37483. * Set the keys for camera movement forward.
  37484. */
  37485. keysForward: number[];
  37486. /**
  37487. * Get the keys for camera movement backward.
  37488. */
  37489. keysBackward: number[];
  37490. /**
  37491. * Get the keys for camera movement up.
  37492. */
  37493. /**
  37494. * Set the keys for camera movement up.
  37495. */
  37496. keysUp: number[];
  37497. /**
  37498. * Get the keys for camera movement down.
  37499. */
  37500. /**
  37501. * Set the keys for camera movement down.
  37502. */
  37503. keysDown: number[];
  37504. /**
  37505. * Get the keys for camera movement left.
  37506. */
  37507. /**
  37508. * Set the keys for camera movement left.
  37509. */
  37510. keysLeft: number[];
  37511. /**
  37512. * Set the keys for camera movement right.
  37513. */
  37514. /**
  37515. * Set the keys for camera movement right.
  37516. */
  37517. keysRight: number[];
  37518. /**
  37519. * Event raised when the camera collides with a mesh in the scene.
  37520. */
  37521. onCollide: (collidedMesh: AbstractMesh) => void;
  37522. private _collider;
  37523. private _needMoveForGravity;
  37524. private _oldPosition;
  37525. private _diffPosition;
  37526. private _newPosition;
  37527. /** @hidden */
  37528. _localDirection: Vector3;
  37529. /** @hidden */
  37530. _transformedDirection: Vector3;
  37531. /**
  37532. * Instantiates a FlyCamera.
  37533. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37534. * such as in a 3D Space Shooter or a Flight Simulator.
  37535. * @param name Define the name of the camera in the scene.
  37536. * @param position Define the starting position of the camera in the scene.
  37537. * @param scene Define the scene the camera belongs to.
  37538. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37539. */
  37540. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37541. /**
  37542. * Attach a control to the HTML DOM element.
  37543. * @param element Defines the element that listens to the input events.
  37544. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37545. */
  37546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37547. /**
  37548. * Detach a control from the HTML DOM element.
  37549. * The camera will stop reacting to that input.
  37550. * @param element Defines the element that listens to the input events.
  37551. */
  37552. detachControl(element: HTMLElement): void;
  37553. private _collisionMask;
  37554. /**
  37555. * Get the mask that the camera ignores in collision events.
  37556. */
  37557. /**
  37558. * Set the mask that the camera ignores in collision events.
  37559. */
  37560. collisionMask: number;
  37561. /** @hidden */
  37562. _collideWithWorld(displacement: Vector3): void;
  37563. /** @hidden */
  37564. private _onCollisionPositionChange;
  37565. /** @hidden */
  37566. _checkInputs(): void;
  37567. /** @hidden */
  37568. _decideIfNeedsToMove(): boolean;
  37569. /** @hidden */
  37570. _updatePosition(): void;
  37571. /**
  37572. * Restore the Roll to its target value at the rate specified.
  37573. * @param rate - Higher means slower restoring.
  37574. * @hidden
  37575. */
  37576. restoreRoll(rate: number): void;
  37577. /**
  37578. * Destroy the camera and release the current resources held by it.
  37579. */
  37580. dispose(): void;
  37581. /**
  37582. * Get the current object class name.
  37583. * @returns the class name.
  37584. */
  37585. getClassName(): string;
  37586. }
  37587. }
  37588. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37589. import { Nullable } from "babylonjs/types";
  37590. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37591. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37592. /**
  37593. * Listen to keyboard events to control the camera.
  37594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37595. */
  37596. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37597. /**
  37598. * Defines the camera the input is attached to.
  37599. */
  37600. camera: FlyCamera;
  37601. /**
  37602. * The list of keyboard keys used to control the forward move of the camera.
  37603. */
  37604. keysForward: number[];
  37605. /**
  37606. * The list of keyboard keys used to control the backward move of the camera.
  37607. */
  37608. keysBackward: number[];
  37609. /**
  37610. * The list of keyboard keys used to control the forward move of the camera.
  37611. */
  37612. keysUp: number[];
  37613. /**
  37614. * The list of keyboard keys used to control the backward move of the camera.
  37615. */
  37616. keysDown: number[];
  37617. /**
  37618. * The list of keyboard keys used to control the right strafe move of the camera.
  37619. */
  37620. keysRight: number[];
  37621. /**
  37622. * The list of keyboard keys used to control the left strafe move of the camera.
  37623. */
  37624. keysLeft: number[];
  37625. private _keys;
  37626. private _onCanvasBlurObserver;
  37627. private _onKeyboardObserver;
  37628. private _engine;
  37629. private _scene;
  37630. /**
  37631. * Attach the input controls to a specific dom element to get the input from.
  37632. * @param element Defines the element the controls should be listened from
  37633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37634. */
  37635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37636. /**
  37637. * Detach the current controls from the specified dom element.
  37638. * @param element Defines the element to stop listening the inputs from
  37639. */
  37640. detachControl(element: Nullable<HTMLElement>): void;
  37641. /**
  37642. * Gets the class name of the current intput.
  37643. * @returns the class name
  37644. */
  37645. getClassName(): string;
  37646. /** @hidden */
  37647. _onLostFocus(e: FocusEvent): void;
  37648. /**
  37649. * Get the friendly name associated with the input class.
  37650. * @returns the input friendly name
  37651. */
  37652. getSimpleName(): string;
  37653. /**
  37654. * Update the current camera state depending on the inputs that have been used this frame.
  37655. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37656. */
  37657. checkInputs(): void;
  37658. }
  37659. }
  37660. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37661. import { Nullable } from "babylonjs/types";
  37662. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37663. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37664. /**
  37665. * Manage the mouse wheel inputs to control a follow camera.
  37666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37667. */
  37668. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37669. /**
  37670. * Defines the camera the input is attached to.
  37671. */
  37672. camera: FollowCamera;
  37673. /**
  37674. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37675. */
  37676. axisControlRadius: boolean;
  37677. /**
  37678. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37679. */
  37680. axisControlHeight: boolean;
  37681. /**
  37682. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37683. */
  37684. axisControlRotation: boolean;
  37685. /**
  37686. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37687. * relation to mouseWheel events.
  37688. */
  37689. wheelPrecision: number;
  37690. /**
  37691. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37692. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37693. */
  37694. wheelDeltaPercentage: number;
  37695. private _wheel;
  37696. private _observer;
  37697. /**
  37698. * Attach the input controls to a specific dom element to get the input from.
  37699. * @param element Defines the element the controls should be listened from
  37700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37701. */
  37702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37703. /**
  37704. * Detach the current controls from the specified dom element.
  37705. * @param element Defines the element to stop listening the inputs from
  37706. */
  37707. detachControl(element: Nullable<HTMLElement>): void;
  37708. /**
  37709. * Gets the class name of the current intput.
  37710. * @returns the class name
  37711. */
  37712. getClassName(): string;
  37713. /**
  37714. * Get the friendly name associated with the input class.
  37715. * @returns the input friendly name
  37716. */
  37717. getSimpleName(): string;
  37718. }
  37719. }
  37720. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37721. import { Nullable } from "babylonjs/types";
  37722. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37723. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37724. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37725. /**
  37726. * Manage the pointers inputs to control an follow camera.
  37727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37728. */
  37729. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37730. /**
  37731. * Defines the camera the input is attached to.
  37732. */
  37733. camera: FollowCamera;
  37734. /**
  37735. * Gets the class name of the current input.
  37736. * @returns the class name
  37737. */
  37738. getClassName(): string;
  37739. /**
  37740. * Defines the pointer angular sensibility along the X axis or how fast is
  37741. * the camera rotating.
  37742. * A negative number will reverse the axis direction.
  37743. */
  37744. angularSensibilityX: number;
  37745. /**
  37746. * Defines the pointer angular sensibility along the Y axis or how fast is
  37747. * the camera rotating.
  37748. * A negative number will reverse the axis direction.
  37749. */
  37750. angularSensibilityY: number;
  37751. /**
  37752. * Defines the pointer pinch precision or how fast is the camera zooming.
  37753. * A negative number will reverse the axis direction.
  37754. */
  37755. pinchPrecision: number;
  37756. /**
  37757. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37758. * from 0.
  37759. * It defines the percentage of current camera.radius to use as delta when
  37760. * pinch zoom is used.
  37761. */
  37762. pinchDeltaPercentage: number;
  37763. /**
  37764. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37765. */
  37766. axisXControlRadius: boolean;
  37767. /**
  37768. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37769. */
  37770. axisXControlHeight: boolean;
  37771. /**
  37772. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37773. */
  37774. axisXControlRotation: boolean;
  37775. /**
  37776. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37777. */
  37778. axisYControlRadius: boolean;
  37779. /**
  37780. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37781. */
  37782. axisYControlHeight: boolean;
  37783. /**
  37784. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37785. */
  37786. axisYControlRotation: boolean;
  37787. /**
  37788. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37789. */
  37790. axisPinchControlRadius: boolean;
  37791. /**
  37792. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37793. */
  37794. axisPinchControlHeight: boolean;
  37795. /**
  37796. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37797. */
  37798. axisPinchControlRotation: boolean;
  37799. /**
  37800. * Log error messages if basic misconfiguration has occurred.
  37801. */
  37802. warningEnable: boolean;
  37803. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37804. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37805. private _warningCounter;
  37806. private _warning;
  37807. }
  37808. }
  37809. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37810. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37811. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37812. /**
  37813. * Default Inputs manager for the FollowCamera.
  37814. * It groups all the default supported inputs for ease of use.
  37815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37816. */
  37817. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37818. /**
  37819. * Instantiates a new FollowCameraInputsManager.
  37820. * @param camera Defines the camera the inputs belong to
  37821. */
  37822. constructor(camera: FollowCamera);
  37823. /**
  37824. * Add keyboard input support to the input manager.
  37825. * @returns the current input manager
  37826. */
  37827. addKeyboard(): FollowCameraInputsManager;
  37828. /**
  37829. * Add mouse wheel input support to the input manager.
  37830. * @returns the current input manager
  37831. */
  37832. addMouseWheel(): FollowCameraInputsManager;
  37833. /**
  37834. * Add pointers input support to the input manager.
  37835. * @returns the current input manager
  37836. */
  37837. addPointers(): FollowCameraInputsManager;
  37838. /**
  37839. * Add orientation input support to the input manager.
  37840. * @returns the current input manager
  37841. */
  37842. addVRDeviceOrientation(): FollowCameraInputsManager;
  37843. }
  37844. }
  37845. declare module "babylonjs/Cameras/followCamera" {
  37846. import { Nullable } from "babylonjs/types";
  37847. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37848. import { Scene } from "babylonjs/scene";
  37849. import { Vector3 } from "babylonjs/Maths/math";
  37850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37851. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37852. /**
  37853. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37854. * an arc rotate version arcFollowCamera are available.
  37855. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37856. */
  37857. export class FollowCamera extends TargetCamera {
  37858. /**
  37859. * Distance the follow camera should follow an object at
  37860. */
  37861. radius: number;
  37862. /**
  37863. * Minimum allowed distance of the camera to the axis of rotation
  37864. * (The camera can not get closer).
  37865. * This can help limiting how the Camera is able to move in the scene.
  37866. */
  37867. lowerRadiusLimit: Nullable<number>;
  37868. /**
  37869. * Maximum allowed distance of the camera to the axis of rotation
  37870. * (The camera can not get further).
  37871. * This can help limiting how the Camera is able to move in the scene.
  37872. */
  37873. upperRadiusLimit: Nullable<number>;
  37874. /**
  37875. * Define a rotation offset between the camera and the object it follows
  37876. */
  37877. rotationOffset: number;
  37878. /**
  37879. * Minimum allowed angle to camera position relative to target object.
  37880. * This can help limiting how the Camera is able to move in the scene.
  37881. */
  37882. lowerRotationOffsetLimit: Nullable<number>;
  37883. /**
  37884. * Maximum allowed angle to camera position relative to target object.
  37885. * This can help limiting how the Camera is able to move in the scene.
  37886. */
  37887. upperRotationOffsetLimit: Nullable<number>;
  37888. /**
  37889. * Define a height offset between the camera and the object it follows.
  37890. * It can help following an object from the top (like a car chaing a plane)
  37891. */
  37892. heightOffset: number;
  37893. /**
  37894. * Minimum allowed height of camera position relative to target object.
  37895. * This can help limiting how the Camera is able to move in the scene.
  37896. */
  37897. lowerHeightOffsetLimit: Nullable<number>;
  37898. /**
  37899. * Maximum allowed height of camera position relative to target object.
  37900. * This can help limiting how the Camera is able to move in the scene.
  37901. */
  37902. upperHeightOffsetLimit: Nullable<number>;
  37903. /**
  37904. * Define how fast the camera can accelerate to follow it s target.
  37905. */
  37906. cameraAcceleration: number;
  37907. /**
  37908. * Define the speed limit of the camera following an object.
  37909. */
  37910. maxCameraSpeed: number;
  37911. /**
  37912. * Define the target of the camera.
  37913. */
  37914. lockedTarget: Nullable<AbstractMesh>;
  37915. /**
  37916. * Defines the input associated with the camera.
  37917. */
  37918. inputs: FollowCameraInputsManager;
  37919. /**
  37920. * Instantiates the follow camera.
  37921. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37922. * @param name Define the name of the camera in the scene
  37923. * @param position Define the position of the camera
  37924. * @param scene Define the scene the camera belong to
  37925. * @param lockedTarget Define the target of the camera
  37926. */
  37927. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37928. private _follow;
  37929. /**
  37930. * Attached controls to the current camera.
  37931. * @param element Defines the element the controls should be listened from
  37932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37933. */
  37934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37935. /**
  37936. * Detach the current controls from the camera.
  37937. * The camera will stop reacting to inputs.
  37938. * @param element Defines the element to stop listening the inputs from
  37939. */
  37940. detachControl(element: HTMLElement): void;
  37941. /** @hidden */
  37942. _checkInputs(): void;
  37943. private _checkLimits;
  37944. /**
  37945. * Gets the camera class name.
  37946. * @returns the class name
  37947. */
  37948. getClassName(): string;
  37949. }
  37950. /**
  37951. * Arc Rotate version of the follow camera.
  37952. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37953. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37954. */
  37955. export class ArcFollowCamera extends TargetCamera {
  37956. /** The longitudinal angle of the camera */
  37957. alpha: number;
  37958. /** The latitudinal angle of the camera */
  37959. beta: number;
  37960. /** The radius of the camera from its target */
  37961. radius: number;
  37962. /** Define the camera target (the messh it should follow) */
  37963. target: Nullable<AbstractMesh>;
  37964. private _cartesianCoordinates;
  37965. /**
  37966. * Instantiates a new ArcFollowCamera
  37967. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37968. * @param name Define the name of the camera
  37969. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37970. * @param beta Define the rotation angle of the camera around the elevation axis
  37971. * @param radius Define the radius of the camera from its target point
  37972. * @param target Define the target of the camera
  37973. * @param scene Define the scene the camera belongs to
  37974. */
  37975. constructor(name: string,
  37976. /** The longitudinal angle of the camera */
  37977. alpha: number,
  37978. /** The latitudinal angle of the camera */
  37979. beta: number,
  37980. /** The radius of the camera from its target */
  37981. radius: number,
  37982. /** Define the camera target (the messh it should follow) */
  37983. target: Nullable<AbstractMesh>, scene: Scene);
  37984. private _follow;
  37985. /** @hidden */
  37986. _checkInputs(): void;
  37987. /**
  37988. * Returns the class name of the object.
  37989. * It is mostly used internally for serialization purposes.
  37990. */
  37991. getClassName(): string;
  37992. }
  37993. }
  37994. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37995. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37996. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37997. import { Nullable } from "babylonjs/types";
  37998. /**
  37999. * Manage the keyboard inputs to control the movement of a follow camera.
  38000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38001. */
  38002. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38003. /**
  38004. * Defines the camera the input is attached to.
  38005. */
  38006. camera: FollowCamera;
  38007. /**
  38008. * Defines the list of key codes associated with the up action (increase heightOffset)
  38009. */
  38010. keysHeightOffsetIncr: number[];
  38011. /**
  38012. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38013. */
  38014. keysHeightOffsetDecr: number[];
  38015. /**
  38016. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38017. */
  38018. keysHeightOffsetModifierAlt: boolean;
  38019. /**
  38020. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38021. */
  38022. keysHeightOffsetModifierCtrl: boolean;
  38023. /**
  38024. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38025. */
  38026. keysHeightOffsetModifierShift: boolean;
  38027. /**
  38028. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38029. */
  38030. keysRotationOffsetIncr: number[];
  38031. /**
  38032. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38033. */
  38034. keysRotationOffsetDecr: number[];
  38035. /**
  38036. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38037. */
  38038. keysRotationOffsetModifierAlt: boolean;
  38039. /**
  38040. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38041. */
  38042. keysRotationOffsetModifierCtrl: boolean;
  38043. /**
  38044. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38045. */
  38046. keysRotationOffsetModifierShift: boolean;
  38047. /**
  38048. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38049. */
  38050. keysRadiusIncr: number[];
  38051. /**
  38052. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38053. */
  38054. keysRadiusDecr: number[];
  38055. /**
  38056. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38057. */
  38058. keysRadiusModifierAlt: boolean;
  38059. /**
  38060. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38061. */
  38062. keysRadiusModifierCtrl: boolean;
  38063. /**
  38064. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38065. */
  38066. keysRadiusModifierShift: boolean;
  38067. /**
  38068. * Defines the rate of change of heightOffset.
  38069. */
  38070. heightSensibility: number;
  38071. /**
  38072. * Defines the rate of change of rotationOffset.
  38073. */
  38074. rotationSensibility: number;
  38075. /**
  38076. * Defines the rate of change of radius.
  38077. */
  38078. radiusSensibility: number;
  38079. private _keys;
  38080. private _ctrlPressed;
  38081. private _altPressed;
  38082. private _shiftPressed;
  38083. private _onCanvasBlurObserver;
  38084. private _onKeyboardObserver;
  38085. private _engine;
  38086. private _scene;
  38087. /**
  38088. * Attach the input controls to a specific dom element to get the input from.
  38089. * @param element Defines the element the controls should be listened from
  38090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38091. */
  38092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38093. /**
  38094. * Detach the current controls from the specified dom element.
  38095. * @param element Defines the element to stop listening the inputs from
  38096. */
  38097. detachControl(element: Nullable<HTMLElement>): void;
  38098. /**
  38099. * Update the current camera state depending on the inputs that have been used this frame.
  38100. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38101. */
  38102. checkInputs(): void;
  38103. /**
  38104. * Gets the class name of the current input.
  38105. * @returns the class name
  38106. */
  38107. getClassName(): string;
  38108. /**
  38109. * Get the friendly name associated with the input class.
  38110. * @returns the input friendly name
  38111. */
  38112. getSimpleName(): string;
  38113. /**
  38114. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38115. * allow modification of the heightOffset value.
  38116. */
  38117. private _modifierHeightOffset;
  38118. /**
  38119. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38120. * allow modification of the rotationOffset value.
  38121. */
  38122. private _modifierRotationOffset;
  38123. /**
  38124. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38125. * allow modification of the radius value.
  38126. */
  38127. private _modifierRadius;
  38128. }
  38129. }
  38130. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38131. import { Nullable } from "babylonjs/types";
  38132. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38133. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38134. import { Observable } from "babylonjs/Misc/observable";
  38135. module "babylonjs/Cameras/freeCameraInputsManager" {
  38136. interface FreeCameraInputsManager {
  38137. /**
  38138. * @hidden
  38139. */
  38140. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38141. /**
  38142. * Add orientation input support to the input manager.
  38143. * @returns the current input manager
  38144. */
  38145. addDeviceOrientation(): FreeCameraInputsManager;
  38146. }
  38147. }
  38148. /**
  38149. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38150. * Screen rotation is taken into account.
  38151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38152. */
  38153. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38154. private _camera;
  38155. private _screenOrientationAngle;
  38156. private _constantTranform;
  38157. private _screenQuaternion;
  38158. private _alpha;
  38159. private _beta;
  38160. private _gamma;
  38161. /**
  38162. * @hidden
  38163. */
  38164. _onDeviceOrientationChangedObservable: Observable<void>;
  38165. /**
  38166. * Instantiates a new input
  38167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38168. */
  38169. constructor();
  38170. /**
  38171. * Define the camera controlled by the input.
  38172. */
  38173. camera: FreeCamera;
  38174. /**
  38175. * Attach the input controls to a specific dom element to get the input from.
  38176. * @param element Defines the element the controls should be listened from
  38177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38178. */
  38179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38180. private _orientationChanged;
  38181. private _deviceOrientation;
  38182. /**
  38183. * Detach the current controls from the specified dom element.
  38184. * @param element Defines the element to stop listening the inputs from
  38185. */
  38186. detachControl(element: Nullable<HTMLElement>): void;
  38187. /**
  38188. * Update the current camera state depending on the inputs that have been used this frame.
  38189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38190. */
  38191. checkInputs(): void;
  38192. /**
  38193. * Gets the class name of the current intput.
  38194. * @returns the class name
  38195. */
  38196. getClassName(): string;
  38197. /**
  38198. * Get the friendly name associated with the input class.
  38199. * @returns the input friendly name
  38200. */
  38201. getSimpleName(): string;
  38202. }
  38203. }
  38204. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38205. import { Nullable } from "babylonjs/types";
  38206. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38207. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38208. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38209. /**
  38210. * Manage the gamepad inputs to control a free camera.
  38211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38212. */
  38213. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38214. /**
  38215. * Define the camera the input is attached to.
  38216. */
  38217. camera: FreeCamera;
  38218. /**
  38219. * Define the Gamepad controlling the input
  38220. */
  38221. gamepad: Nullable<Gamepad>;
  38222. /**
  38223. * Defines the gamepad rotation sensiblity.
  38224. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38225. */
  38226. gamepadAngularSensibility: number;
  38227. /**
  38228. * Defines the gamepad move sensiblity.
  38229. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38230. */
  38231. gamepadMoveSensibility: number;
  38232. private _onGamepadConnectedObserver;
  38233. private _onGamepadDisconnectedObserver;
  38234. private _cameraTransform;
  38235. private _deltaTransform;
  38236. private _vector3;
  38237. private _vector2;
  38238. /**
  38239. * Attach the input controls to a specific dom element to get the input from.
  38240. * @param element Defines the element the controls should be listened from
  38241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38242. */
  38243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38244. /**
  38245. * Detach the current controls from the specified dom element.
  38246. * @param element Defines the element to stop listening the inputs from
  38247. */
  38248. detachControl(element: Nullable<HTMLElement>): void;
  38249. /**
  38250. * Update the current camera state depending on the inputs that have been used this frame.
  38251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38252. */
  38253. checkInputs(): void;
  38254. /**
  38255. * Gets the class name of the current intput.
  38256. * @returns the class name
  38257. */
  38258. getClassName(): string;
  38259. /**
  38260. * Get the friendly name associated with the input class.
  38261. * @returns the input friendly name
  38262. */
  38263. getSimpleName(): string;
  38264. }
  38265. }
  38266. declare module "babylonjs/Misc/virtualJoystick" {
  38267. import { Nullable } from "babylonjs/types";
  38268. import { Vector3 } from "babylonjs/Maths/math";
  38269. /**
  38270. * Defines the potential axis of a Joystick
  38271. */
  38272. export enum JoystickAxis {
  38273. /** X axis */
  38274. X = 0,
  38275. /** Y axis */
  38276. Y = 1,
  38277. /** Z axis */
  38278. Z = 2
  38279. }
  38280. /**
  38281. * Class used to define virtual joystick (used in touch mode)
  38282. */
  38283. export class VirtualJoystick {
  38284. /**
  38285. * Gets or sets a boolean indicating that left and right values must be inverted
  38286. */
  38287. reverseLeftRight: boolean;
  38288. /**
  38289. * Gets or sets a boolean indicating that up and down values must be inverted
  38290. */
  38291. reverseUpDown: boolean;
  38292. /**
  38293. * Gets the offset value for the position (ie. the change of the position value)
  38294. */
  38295. deltaPosition: Vector3;
  38296. /**
  38297. * Gets a boolean indicating if the virtual joystick was pressed
  38298. */
  38299. pressed: boolean;
  38300. /**
  38301. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38302. */
  38303. static Canvas: Nullable<HTMLCanvasElement>;
  38304. private static _globalJoystickIndex;
  38305. private static vjCanvasContext;
  38306. private static vjCanvasWidth;
  38307. private static vjCanvasHeight;
  38308. private static halfWidth;
  38309. private _action;
  38310. private _axisTargetedByLeftAndRight;
  38311. private _axisTargetedByUpAndDown;
  38312. private _joystickSensibility;
  38313. private _inversedSensibility;
  38314. private _joystickPointerID;
  38315. private _joystickColor;
  38316. private _joystickPointerPos;
  38317. private _joystickPreviousPointerPos;
  38318. private _joystickPointerStartPos;
  38319. private _deltaJoystickVector;
  38320. private _leftJoystick;
  38321. private _touches;
  38322. private _onPointerDownHandlerRef;
  38323. private _onPointerMoveHandlerRef;
  38324. private _onPointerUpHandlerRef;
  38325. private _onResize;
  38326. /**
  38327. * Creates a new virtual joystick
  38328. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38329. */
  38330. constructor(leftJoystick?: boolean);
  38331. /**
  38332. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38333. * @param newJoystickSensibility defines the new sensibility
  38334. */
  38335. setJoystickSensibility(newJoystickSensibility: number): void;
  38336. private _onPointerDown;
  38337. private _onPointerMove;
  38338. private _onPointerUp;
  38339. /**
  38340. * Change the color of the virtual joystick
  38341. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38342. */
  38343. setJoystickColor(newColor: string): void;
  38344. /**
  38345. * Defines a callback to call when the joystick is touched
  38346. * @param action defines the callback
  38347. */
  38348. setActionOnTouch(action: () => any): void;
  38349. /**
  38350. * Defines which axis you'd like to control for left & right
  38351. * @param axis defines the axis to use
  38352. */
  38353. setAxisForLeftRight(axis: JoystickAxis): void;
  38354. /**
  38355. * Defines which axis you'd like to control for up & down
  38356. * @param axis defines the axis to use
  38357. */
  38358. setAxisForUpDown(axis: JoystickAxis): void;
  38359. private _drawVirtualJoystick;
  38360. /**
  38361. * Release internal HTML canvas
  38362. */
  38363. releaseCanvas(): void;
  38364. }
  38365. }
  38366. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38367. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38368. import { Nullable } from "babylonjs/types";
  38369. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38370. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38371. module "babylonjs/Cameras/freeCameraInputsManager" {
  38372. interface FreeCameraInputsManager {
  38373. /**
  38374. * Add virtual joystick input support to the input manager.
  38375. * @returns the current input manager
  38376. */
  38377. addVirtualJoystick(): FreeCameraInputsManager;
  38378. }
  38379. }
  38380. /**
  38381. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38383. */
  38384. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38385. /**
  38386. * Defines the camera the input is attached to.
  38387. */
  38388. camera: FreeCamera;
  38389. private _leftjoystick;
  38390. private _rightjoystick;
  38391. /**
  38392. * Gets the left stick of the virtual joystick.
  38393. * @returns The virtual Joystick
  38394. */
  38395. getLeftJoystick(): VirtualJoystick;
  38396. /**
  38397. * Gets the right stick of the virtual joystick.
  38398. * @returns The virtual Joystick
  38399. */
  38400. getRightJoystick(): VirtualJoystick;
  38401. /**
  38402. * Update the current camera state depending on the inputs that have been used this frame.
  38403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38404. */
  38405. checkInputs(): void;
  38406. /**
  38407. * Attach the input controls to a specific dom element to get the input from.
  38408. * @param element Defines the element the controls should be listened from
  38409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38410. */
  38411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38412. /**
  38413. * Detach the current controls from the specified dom element.
  38414. * @param element Defines the element to stop listening the inputs from
  38415. */
  38416. detachControl(element: Nullable<HTMLElement>): void;
  38417. /**
  38418. * Gets the class name of the current intput.
  38419. * @returns the class name
  38420. */
  38421. getClassName(): string;
  38422. /**
  38423. * Get the friendly name associated with the input class.
  38424. * @returns the input friendly name
  38425. */
  38426. getSimpleName(): string;
  38427. }
  38428. }
  38429. declare module "babylonjs/Cameras/Inputs/index" {
  38430. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38431. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38432. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38433. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38434. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38435. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38436. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38437. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38438. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38439. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38440. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38441. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38442. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38443. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38444. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38445. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38446. }
  38447. declare module "babylonjs/Cameras/touchCamera" {
  38448. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38449. import { Scene } from "babylonjs/scene";
  38450. import { Vector3 } from "babylonjs/Maths/math";
  38451. /**
  38452. * This represents a FPS type of camera controlled by touch.
  38453. * This is like a universal camera minus the Gamepad controls.
  38454. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38455. */
  38456. export class TouchCamera extends FreeCamera {
  38457. /**
  38458. * Defines the touch sensibility for rotation.
  38459. * The higher the faster.
  38460. */
  38461. touchAngularSensibility: number;
  38462. /**
  38463. * Defines the touch sensibility for move.
  38464. * The higher the faster.
  38465. */
  38466. touchMoveSensibility: number;
  38467. /**
  38468. * Instantiates a new touch camera.
  38469. * This represents a FPS type of camera controlled by touch.
  38470. * This is like a universal camera minus the Gamepad controls.
  38471. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38472. * @param name Define the name of the camera in the scene
  38473. * @param position Define the start position of the camera in the scene
  38474. * @param scene Define the scene the camera belongs to
  38475. */
  38476. constructor(name: string, position: Vector3, scene: Scene);
  38477. /**
  38478. * Gets the current object class name.
  38479. * @return the class name
  38480. */
  38481. getClassName(): string;
  38482. /** @hidden */
  38483. _setupInputs(): void;
  38484. }
  38485. }
  38486. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38487. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38488. import { Scene } from "babylonjs/scene";
  38489. import { Vector3, Axis } from "babylonjs/Maths/math";
  38490. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38491. /**
  38492. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38493. * being tilted forward or back and left or right.
  38494. */
  38495. export class DeviceOrientationCamera extends FreeCamera {
  38496. private _initialQuaternion;
  38497. private _quaternionCache;
  38498. private _tmpDragQuaternion;
  38499. /**
  38500. * Creates a new device orientation camera
  38501. * @param name The name of the camera
  38502. * @param position The start position camera
  38503. * @param scene The scene the camera belongs to
  38504. */
  38505. constructor(name: string, position: Vector3, scene: Scene);
  38506. /**
  38507. * @hidden
  38508. * Disabled pointer input on first orientation sensor update (Default: true)
  38509. */
  38510. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38511. private _dragFactor;
  38512. /**
  38513. * Enabled turning on the y axis when the orientation sensor is active
  38514. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38515. */
  38516. enableHorizontalDragging(dragFactor?: number): void;
  38517. /**
  38518. * Gets the current instance class name ("DeviceOrientationCamera").
  38519. * This helps avoiding instanceof at run time.
  38520. * @returns the class name
  38521. */
  38522. getClassName(): string;
  38523. /**
  38524. * @hidden
  38525. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38526. */
  38527. _checkInputs(): void;
  38528. /**
  38529. * Reset the camera to its default orientation on the specified axis only.
  38530. * @param axis The axis to reset
  38531. */
  38532. resetToCurrentRotation(axis?: Axis): void;
  38533. }
  38534. }
  38535. declare module "babylonjs/Cameras/universalCamera" {
  38536. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38537. import { Scene } from "babylonjs/scene";
  38538. import { Vector3 } from "babylonjs/Maths/math";
  38539. /**
  38540. * 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,
  38541. * which still works and will still be found in many Playgrounds.
  38542. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38543. */
  38544. export class UniversalCamera extends TouchCamera {
  38545. /**
  38546. * Defines the gamepad rotation sensiblity.
  38547. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38548. */
  38549. gamepadAngularSensibility: number;
  38550. /**
  38551. * Defines the gamepad move sensiblity.
  38552. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38553. */
  38554. gamepadMoveSensibility: number;
  38555. /**
  38556. * 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,
  38557. * which still works and will still be found in many Playgrounds.
  38558. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38559. * @param name Define the name of the camera in the scene
  38560. * @param position Define the start position of the camera in the scene
  38561. * @param scene Define the scene the camera belongs to
  38562. */
  38563. constructor(name: string, position: Vector3, scene: Scene);
  38564. /**
  38565. * Gets the current object class name.
  38566. * @return the class name
  38567. */
  38568. getClassName(): string;
  38569. }
  38570. }
  38571. declare module "babylonjs/Cameras/gamepadCamera" {
  38572. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38573. import { Scene } from "babylonjs/scene";
  38574. import { Vector3 } from "babylonjs/Maths/math";
  38575. /**
  38576. * This represents a FPS type of camera. This is only here for back compat purpose.
  38577. * Please use the UniversalCamera instead as both are identical.
  38578. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38579. */
  38580. export class GamepadCamera extends UniversalCamera {
  38581. /**
  38582. * Instantiates a new Gamepad Camera
  38583. * This represents a FPS type of camera. This is only here for back compat purpose.
  38584. * Please use the UniversalCamera instead as both are identical.
  38585. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38586. * @param name Define the name of the camera in the scene
  38587. * @param position Define the start position of the camera in the scene
  38588. * @param scene Define the scene the camera belongs to
  38589. */
  38590. constructor(name: string, position: Vector3, scene: Scene);
  38591. /**
  38592. * Gets the current object class name.
  38593. * @return the class name
  38594. */
  38595. getClassName(): string;
  38596. }
  38597. }
  38598. declare module "babylonjs/Shaders/pass.fragment" {
  38599. /** @hidden */
  38600. export var passPixelShader: {
  38601. name: string;
  38602. shader: string;
  38603. };
  38604. }
  38605. declare module "babylonjs/Shaders/passCube.fragment" {
  38606. /** @hidden */
  38607. export var passCubePixelShader: {
  38608. name: string;
  38609. shader: string;
  38610. };
  38611. }
  38612. declare module "babylonjs/PostProcesses/passPostProcess" {
  38613. import { Nullable } from "babylonjs/types";
  38614. import { Camera } from "babylonjs/Cameras/camera";
  38615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38616. import { Engine } from "babylonjs/Engines/engine";
  38617. import "babylonjs/Shaders/pass.fragment";
  38618. import "babylonjs/Shaders/passCube.fragment";
  38619. /**
  38620. * PassPostProcess which produces an output the same as it's input
  38621. */
  38622. export class PassPostProcess extends PostProcess {
  38623. /**
  38624. * Creates the PassPostProcess
  38625. * @param name The name of the effect.
  38626. * @param options The required width/height ratio to downsize to before computing the render pass.
  38627. * @param camera The camera to apply the render pass to.
  38628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38629. * @param engine The engine which the post process will be applied. (default: current engine)
  38630. * @param reusable If the post process can be reused on the same frame. (default: false)
  38631. * @param textureType The type of texture to be used when performing the post processing.
  38632. * @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)
  38633. */
  38634. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38635. }
  38636. /**
  38637. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38638. */
  38639. export class PassCubePostProcess extends PostProcess {
  38640. private _face;
  38641. /**
  38642. * Gets or sets the cube face to display.
  38643. * * 0 is +X
  38644. * * 1 is -X
  38645. * * 2 is +Y
  38646. * * 3 is -Y
  38647. * * 4 is +Z
  38648. * * 5 is -Z
  38649. */
  38650. face: number;
  38651. /**
  38652. * Creates the PassCubePostProcess
  38653. * @param name The name of the effect.
  38654. * @param options The required width/height ratio to downsize to before computing the render pass.
  38655. * @param camera The camera to apply the render pass to.
  38656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38657. * @param engine The engine which the post process will be applied. (default: current engine)
  38658. * @param reusable If the post process can be reused on the same frame. (default: false)
  38659. * @param textureType The type of texture to be used when performing the post processing.
  38660. * @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)
  38661. */
  38662. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38663. }
  38664. }
  38665. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38666. /** @hidden */
  38667. export var anaglyphPixelShader: {
  38668. name: string;
  38669. shader: string;
  38670. };
  38671. }
  38672. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38673. import { Engine } from "babylonjs/Engines/engine";
  38674. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38675. import { Camera } from "babylonjs/Cameras/camera";
  38676. import "babylonjs/Shaders/anaglyph.fragment";
  38677. /**
  38678. * Postprocess used to generate anaglyphic rendering
  38679. */
  38680. export class AnaglyphPostProcess extends PostProcess {
  38681. private _passedProcess;
  38682. /**
  38683. * Creates a new AnaglyphPostProcess
  38684. * @param name defines postprocess name
  38685. * @param options defines creation options or target ratio scale
  38686. * @param rigCameras defines cameras using this postprocess
  38687. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38688. * @param engine defines hosting engine
  38689. * @param reusable defines if the postprocess will be reused multiple times per frame
  38690. */
  38691. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38692. }
  38693. }
  38694. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38695. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38696. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38697. import { Scene } from "babylonjs/scene";
  38698. import { Vector3 } from "babylonjs/Maths/math";
  38699. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38700. /**
  38701. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38702. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38703. */
  38704. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38705. /**
  38706. * Creates a new AnaglyphArcRotateCamera
  38707. * @param name defines camera name
  38708. * @param alpha defines alpha angle (in radians)
  38709. * @param beta defines beta angle (in radians)
  38710. * @param radius defines radius
  38711. * @param target defines camera target
  38712. * @param interaxialDistance defines distance between each color axis
  38713. * @param scene defines the hosting scene
  38714. */
  38715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38716. /**
  38717. * Gets camera class name
  38718. * @returns AnaglyphArcRotateCamera
  38719. */
  38720. getClassName(): string;
  38721. }
  38722. }
  38723. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38724. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38725. import { Scene } from "babylonjs/scene";
  38726. import { Vector3 } from "babylonjs/Maths/math";
  38727. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38728. /**
  38729. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38730. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38731. */
  38732. export class AnaglyphFreeCamera extends FreeCamera {
  38733. /**
  38734. * Creates a new AnaglyphFreeCamera
  38735. * @param name defines camera name
  38736. * @param position defines initial position
  38737. * @param interaxialDistance defines distance between each color axis
  38738. * @param scene defines the hosting scene
  38739. */
  38740. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38741. /**
  38742. * Gets camera class name
  38743. * @returns AnaglyphFreeCamera
  38744. */
  38745. getClassName(): string;
  38746. }
  38747. }
  38748. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38749. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  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 GamepadCamera)
  38755. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38756. */
  38757. export class AnaglyphGamepadCamera extends GamepadCamera {
  38758. /**
  38759. * Creates a new AnaglyphGamepadCamera
  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 AnaglyphGamepadCamera
  38769. */
  38770. getClassName(): string;
  38771. }
  38772. }
  38773. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38774. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  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 UniversalCamera)
  38780. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38781. */
  38782. export class AnaglyphUniversalCamera extends UniversalCamera {
  38783. /**
  38784. * Creates a new AnaglyphUniversalCamera
  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 AnaglyphUniversalCamera
  38794. */
  38795. getClassName(): string;
  38796. }
  38797. }
  38798. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38799. /** @hidden */
  38800. export var stereoscopicInterlacePixelShader: {
  38801. name: string;
  38802. shader: string;
  38803. };
  38804. }
  38805. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38806. import { Camera } from "babylonjs/Cameras/camera";
  38807. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38808. import { Engine } from "babylonjs/Engines/engine";
  38809. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38810. /**
  38811. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38812. */
  38813. export class StereoscopicInterlacePostProcess extends PostProcess {
  38814. private _stepSize;
  38815. private _passedProcess;
  38816. /**
  38817. * Initializes a StereoscopicInterlacePostProcess
  38818. * @param name The name of the effect.
  38819. * @param rigCameras The rig cameras to be appled to the post process
  38820. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38822. * @param engine The engine which the post process will be applied. (default: current engine)
  38823. * @param reusable If the post process can be reused on the same frame. (default: false)
  38824. */
  38825. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38826. }
  38827. }
  38828. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38829. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38830. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38831. import { Scene } from "babylonjs/scene";
  38832. import { Vector3 } from "babylonjs/Maths/math";
  38833. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38834. /**
  38835. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38836. * @see http://doc.babylonjs.com/features/cameras
  38837. */
  38838. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38839. /**
  38840. * Creates a new StereoscopicArcRotateCamera
  38841. * @param name defines camera name
  38842. * @param alpha defines alpha angle (in radians)
  38843. * @param beta defines beta angle (in radians)
  38844. * @param radius defines radius
  38845. * @param target defines camera target
  38846. * @param interaxialDistance defines distance between each color axis
  38847. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38848. * @param scene defines the hosting scene
  38849. */
  38850. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38851. /**
  38852. * Gets camera class name
  38853. * @returns StereoscopicArcRotateCamera
  38854. */
  38855. getClassName(): string;
  38856. }
  38857. }
  38858. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38859. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38860. import { Scene } from "babylonjs/scene";
  38861. import { Vector3 } from "babylonjs/Maths/math";
  38862. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38863. /**
  38864. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38865. * @see http://doc.babylonjs.com/features/cameras
  38866. */
  38867. export class StereoscopicFreeCamera extends FreeCamera {
  38868. /**
  38869. * Creates a new StereoscopicFreeCamera
  38870. * @param name defines camera name
  38871. * @param position defines initial position
  38872. * @param interaxialDistance defines distance between each color axis
  38873. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38874. * @param scene defines the hosting scene
  38875. */
  38876. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38877. /**
  38878. * Gets camera class name
  38879. * @returns StereoscopicFreeCamera
  38880. */
  38881. getClassName(): string;
  38882. }
  38883. }
  38884. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38885. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38886. import { Scene } from "babylonjs/scene";
  38887. import { Vector3 } from "babylonjs/Maths/math";
  38888. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38889. /**
  38890. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38891. * @see http://doc.babylonjs.com/features/cameras
  38892. */
  38893. export class StereoscopicGamepadCamera extends GamepadCamera {
  38894. /**
  38895. * Creates a new StereoscopicGamepadCamera
  38896. * @param name defines camera name
  38897. * @param position defines initial position
  38898. * @param interaxialDistance defines distance between each color axis
  38899. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38900. * @param scene defines the hosting scene
  38901. */
  38902. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38903. /**
  38904. * Gets camera class name
  38905. * @returns StereoscopicGamepadCamera
  38906. */
  38907. getClassName(): string;
  38908. }
  38909. }
  38910. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38911. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38912. import { Scene } from "babylonjs/scene";
  38913. import { Vector3 } from "babylonjs/Maths/math";
  38914. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38915. /**
  38916. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38917. * @see http://doc.babylonjs.com/features/cameras
  38918. */
  38919. export class StereoscopicUniversalCamera extends UniversalCamera {
  38920. /**
  38921. * Creates a new StereoscopicUniversalCamera
  38922. * @param name defines camera name
  38923. * @param position defines initial position
  38924. * @param interaxialDistance defines distance between each color axis
  38925. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38926. * @param scene defines the hosting scene
  38927. */
  38928. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38929. /**
  38930. * Gets camera class name
  38931. * @returns StereoscopicUniversalCamera
  38932. */
  38933. getClassName(): string;
  38934. }
  38935. }
  38936. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38937. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38938. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38939. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38940. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38941. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38942. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38943. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38944. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38945. }
  38946. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38947. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38948. import { Scene } from "babylonjs/scene";
  38949. import { Vector3 } from "babylonjs/Maths/math";
  38950. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38951. /**
  38952. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38953. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38954. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38955. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38956. */
  38957. export class VirtualJoysticksCamera extends FreeCamera {
  38958. /**
  38959. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38960. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38961. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38962. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38963. * @param name Define the name of the camera in the scene
  38964. * @param position Define the start position of the camera in the scene
  38965. * @param scene Define the scene the camera belongs to
  38966. */
  38967. constructor(name: string, position: Vector3, scene: Scene);
  38968. /**
  38969. * Gets the current object class name.
  38970. * @return the class name
  38971. */
  38972. getClassName(): string;
  38973. }
  38974. }
  38975. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38976. import { Matrix } from "babylonjs/Maths/math";
  38977. /**
  38978. * This represents all the required metrics to create a VR camera.
  38979. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38980. */
  38981. export class VRCameraMetrics {
  38982. /**
  38983. * Define the horizontal resolution off the screen.
  38984. */
  38985. hResolution: number;
  38986. /**
  38987. * Define the vertical resolution off the screen.
  38988. */
  38989. vResolution: number;
  38990. /**
  38991. * Define the horizontal screen size.
  38992. */
  38993. hScreenSize: number;
  38994. /**
  38995. * Define the vertical screen size.
  38996. */
  38997. vScreenSize: number;
  38998. /**
  38999. * Define the vertical screen center position.
  39000. */
  39001. vScreenCenter: number;
  39002. /**
  39003. * Define the distance of the eyes to the screen.
  39004. */
  39005. eyeToScreenDistance: number;
  39006. /**
  39007. * Define the distance between both lenses
  39008. */
  39009. lensSeparationDistance: number;
  39010. /**
  39011. * Define the distance between both viewer's eyes.
  39012. */
  39013. interpupillaryDistance: number;
  39014. /**
  39015. * Define the distortion factor of the VR postprocess.
  39016. * Please, touch with care.
  39017. */
  39018. distortionK: number[];
  39019. /**
  39020. * Define the chromatic aberration correction factors for the VR post process.
  39021. */
  39022. chromaAbCorrection: number[];
  39023. /**
  39024. * Define the scale factor of the post process.
  39025. * The smaller the better but the slower.
  39026. */
  39027. postProcessScaleFactor: number;
  39028. /**
  39029. * Define an offset for the lens center.
  39030. */
  39031. lensCenterOffset: number;
  39032. /**
  39033. * Define if the current vr camera should compensate the distortion of the lense or not.
  39034. */
  39035. compensateDistortion: boolean;
  39036. /**
  39037. * Defines if multiview should be enabled when rendering (Default: false)
  39038. */
  39039. multiviewEnabled: boolean;
  39040. /**
  39041. * Gets the rendering aspect ratio based on the provided resolutions.
  39042. */
  39043. readonly aspectRatio: number;
  39044. /**
  39045. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39046. */
  39047. readonly aspectRatioFov: number;
  39048. /**
  39049. * @hidden
  39050. */
  39051. readonly leftHMatrix: Matrix;
  39052. /**
  39053. * @hidden
  39054. */
  39055. readonly rightHMatrix: Matrix;
  39056. /**
  39057. * @hidden
  39058. */
  39059. readonly leftPreViewMatrix: Matrix;
  39060. /**
  39061. * @hidden
  39062. */
  39063. readonly rightPreViewMatrix: Matrix;
  39064. /**
  39065. * Get the default VRMetrics based on the most generic setup.
  39066. * @returns the default vr metrics
  39067. */
  39068. static GetDefault(): VRCameraMetrics;
  39069. }
  39070. }
  39071. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39072. /** @hidden */
  39073. export var vrDistortionCorrectionPixelShader: {
  39074. name: string;
  39075. shader: string;
  39076. };
  39077. }
  39078. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39079. import { Camera } from "babylonjs/Cameras/camera";
  39080. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39081. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39082. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39083. /**
  39084. * VRDistortionCorrectionPostProcess used for mobile VR
  39085. */
  39086. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39087. private _isRightEye;
  39088. private _distortionFactors;
  39089. private _postProcessScaleFactor;
  39090. private _lensCenterOffset;
  39091. private _scaleIn;
  39092. private _scaleFactor;
  39093. private _lensCenter;
  39094. /**
  39095. * Initializes the VRDistortionCorrectionPostProcess
  39096. * @param name The name of the effect.
  39097. * @param camera The camera to apply the render pass to.
  39098. * @param isRightEye If this is for the right eye distortion
  39099. * @param vrMetrics All the required metrics for the VR camera
  39100. */
  39101. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39102. }
  39103. }
  39104. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39105. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39106. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39107. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39108. import { Scene } from "babylonjs/scene";
  39109. import { Vector3 } from "babylonjs/Maths/math";
  39110. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39111. import "babylonjs/Cameras/RigModes/vrRigMode";
  39112. /**
  39113. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39114. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39115. */
  39116. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39117. /**
  39118. * Creates a new VRDeviceOrientationArcRotateCamera
  39119. * @param name defines camera name
  39120. * @param alpha defines the camera rotation along the logitudinal axis
  39121. * @param beta defines the camera rotation along the latitudinal axis
  39122. * @param radius defines the camera distance from its target
  39123. * @param target defines the camera target
  39124. * @param scene defines the scene the camera belongs to
  39125. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39126. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39127. */
  39128. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39129. /**
  39130. * Gets camera class name
  39131. * @returns VRDeviceOrientationArcRotateCamera
  39132. */
  39133. getClassName(): string;
  39134. }
  39135. }
  39136. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39137. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39138. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39139. import { Scene } from "babylonjs/scene";
  39140. import { Vector3 } from "babylonjs/Maths/math";
  39141. import "babylonjs/Cameras/RigModes/vrRigMode";
  39142. /**
  39143. * Camera used to simulate VR rendering (based on FreeCamera)
  39144. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39145. */
  39146. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39147. /**
  39148. * Creates a new VRDeviceOrientationFreeCamera
  39149. * @param name defines camera name
  39150. * @param position defines the start position of the camera
  39151. * @param scene defines the scene the camera belongs to
  39152. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39153. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39154. */
  39155. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39156. /**
  39157. * Gets camera class name
  39158. * @returns VRDeviceOrientationFreeCamera
  39159. */
  39160. getClassName(): string;
  39161. }
  39162. }
  39163. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39164. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39165. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39166. import { Scene } from "babylonjs/scene";
  39167. import { Vector3 } from "babylonjs/Maths/math";
  39168. /**
  39169. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39170. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39171. */
  39172. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39173. /**
  39174. * Creates a new VRDeviceOrientationGamepadCamera
  39175. * @param name defines camera name
  39176. * @param position defines the start position of the camera
  39177. * @param scene defines the scene the camera belongs to
  39178. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39179. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39180. */
  39181. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39182. /**
  39183. * Gets camera class name
  39184. * @returns VRDeviceOrientationGamepadCamera
  39185. */
  39186. getClassName(): string;
  39187. }
  39188. }
  39189. declare module "babylonjs/Gamepads/xboxGamepad" {
  39190. import { Observable } from "babylonjs/Misc/observable";
  39191. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39192. /**
  39193. * Defines supported buttons for XBox360 compatible gamepads
  39194. */
  39195. export enum Xbox360Button {
  39196. /** A */
  39197. A = 0,
  39198. /** B */
  39199. B = 1,
  39200. /** X */
  39201. X = 2,
  39202. /** Y */
  39203. Y = 3,
  39204. /** Start */
  39205. Start = 4,
  39206. /** Back */
  39207. Back = 5,
  39208. /** Left button */
  39209. LB = 6,
  39210. /** Right button */
  39211. RB = 7,
  39212. /** Left stick */
  39213. LeftStick = 8,
  39214. /** Right stick */
  39215. RightStick = 9
  39216. }
  39217. /** Defines values for XBox360 DPad */
  39218. export enum Xbox360Dpad {
  39219. /** Up */
  39220. Up = 0,
  39221. /** Down */
  39222. Down = 1,
  39223. /** Left */
  39224. Left = 2,
  39225. /** Right */
  39226. Right = 3
  39227. }
  39228. /**
  39229. * Defines a XBox360 gamepad
  39230. */
  39231. export class Xbox360Pad extends Gamepad {
  39232. private _leftTrigger;
  39233. private _rightTrigger;
  39234. private _onlefttriggerchanged;
  39235. private _onrighttriggerchanged;
  39236. private _onbuttondown;
  39237. private _onbuttonup;
  39238. private _ondpaddown;
  39239. private _ondpadup;
  39240. /** Observable raised when a button is pressed */
  39241. onButtonDownObservable: Observable<Xbox360Button>;
  39242. /** Observable raised when a button is released */
  39243. onButtonUpObservable: Observable<Xbox360Button>;
  39244. /** Observable raised when a pad is pressed */
  39245. onPadDownObservable: Observable<Xbox360Dpad>;
  39246. /** Observable raised when a pad is released */
  39247. onPadUpObservable: Observable<Xbox360Dpad>;
  39248. private _buttonA;
  39249. private _buttonB;
  39250. private _buttonX;
  39251. private _buttonY;
  39252. private _buttonBack;
  39253. private _buttonStart;
  39254. private _buttonLB;
  39255. private _buttonRB;
  39256. private _buttonLeftStick;
  39257. private _buttonRightStick;
  39258. private _dPadUp;
  39259. private _dPadDown;
  39260. private _dPadLeft;
  39261. private _dPadRight;
  39262. private _isXboxOnePad;
  39263. /**
  39264. * Creates a new XBox360 gamepad object
  39265. * @param id defines the id of this gamepad
  39266. * @param index defines its index
  39267. * @param gamepad defines the internal HTML gamepad object
  39268. * @param xboxOne defines if it is a XBox One gamepad
  39269. */
  39270. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39271. /**
  39272. * Defines the callback to call when left trigger is pressed
  39273. * @param callback defines the callback to use
  39274. */
  39275. onlefttriggerchanged(callback: (value: number) => void): void;
  39276. /**
  39277. * Defines the callback to call when right trigger is pressed
  39278. * @param callback defines the callback to use
  39279. */
  39280. onrighttriggerchanged(callback: (value: number) => void): void;
  39281. /**
  39282. * Gets the left trigger value
  39283. */
  39284. /**
  39285. * Sets the left trigger value
  39286. */
  39287. leftTrigger: number;
  39288. /**
  39289. * Gets the right trigger value
  39290. */
  39291. /**
  39292. * Sets the right trigger value
  39293. */
  39294. rightTrigger: number;
  39295. /**
  39296. * Defines the callback to call when a button is pressed
  39297. * @param callback defines the callback to use
  39298. */
  39299. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39300. /**
  39301. * Defines the callback to call when a button is released
  39302. * @param callback defines the callback to use
  39303. */
  39304. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39305. /**
  39306. * Defines the callback to call when a pad is pressed
  39307. * @param callback defines the callback to use
  39308. */
  39309. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39310. /**
  39311. * Defines the callback to call when a pad is released
  39312. * @param callback defines the callback to use
  39313. */
  39314. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39315. private _setButtonValue;
  39316. private _setDPadValue;
  39317. /**
  39318. * Gets the value of the `A` button
  39319. */
  39320. /**
  39321. * Sets the value of the `A` button
  39322. */
  39323. buttonA: number;
  39324. /**
  39325. * Gets the value of the `B` button
  39326. */
  39327. /**
  39328. * Sets the value of the `B` button
  39329. */
  39330. buttonB: number;
  39331. /**
  39332. * Gets the value of the `X` button
  39333. */
  39334. /**
  39335. * Sets the value of the `X` button
  39336. */
  39337. buttonX: number;
  39338. /**
  39339. * Gets the value of the `Y` button
  39340. */
  39341. /**
  39342. * Sets the value of the `Y` button
  39343. */
  39344. buttonY: number;
  39345. /**
  39346. * Gets the value of the `Start` button
  39347. */
  39348. /**
  39349. * Sets the value of the `Start` button
  39350. */
  39351. buttonStart: number;
  39352. /**
  39353. * Gets the value of the `Back` button
  39354. */
  39355. /**
  39356. * Sets the value of the `Back` button
  39357. */
  39358. buttonBack: number;
  39359. /**
  39360. * Gets the value of the `Left` button
  39361. */
  39362. /**
  39363. * Sets the value of the `Left` button
  39364. */
  39365. buttonLB: number;
  39366. /**
  39367. * Gets the value of the `Right` button
  39368. */
  39369. /**
  39370. * Sets the value of the `Right` button
  39371. */
  39372. buttonRB: number;
  39373. /**
  39374. * Gets the value of the Left joystick
  39375. */
  39376. /**
  39377. * Sets the value of the Left joystick
  39378. */
  39379. buttonLeftStick: number;
  39380. /**
  39381. * Gets the value of the Right joystick
  39382. */
  39383. /**
  39384. * Sets the value of the Right joystick
  39385. */
  39386. buttonRightStick: number;
  39387. /**
  39388. * Gets the value of D-pad up
  39389. */
  39390. /**
  39391. * Sets the value of D-pad up
  39392. */
  39393. dPadUp: number;
  39394. /**
  39395. * Gets the value of D-pad down
  39396. */
  39397. /**
  39398. * Sets the value of D-pad down
  39399. */
  39400. dPadDown: number;
  39401. /**
  39402. * Gets the value of D-pad left
  39403. */
  39404. /**
  39405. * Sets the value of D-pad left
  39406. */
  39407. dPadLeft: number;
  39408. /**
  39409. * Gets the value of D-pad right
  39410. */
  39411. /**
  39412. * Sets the value of D-pad right
  39413. */
  39414. dPadRight: number;
  39415. /**
  39416. * Force the gamepad to synchronize with device values
  39417. */
  39418. update(): void;
  39419. /**
  39420. * Disposes the gamepad
  39421. */
  39422. dispose(): void;
  39423. }
  39424. }
  39425. declare module "babylonjs/Materials/pushMaterial" {
  39426. import { Nullable } from "babylonjs/types";
  39427. import { Scene } from "babylonjs/scene";
  39428. import { Matrix } from "babylonjs/Maths/math";
  39429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39430. import { Mesh } from "babylonjs/Meshes/mesh";
  39431. import { Material } from "babylonjs/Materials/material";
  39432. import { Effect } from "babylonjs/Materials/effect";
  39433. /**
  39434. * Base class of materials working in push mode in babylon JS
  39435. * @hidden
  39436. */
  39437. export class PushMaterial extends Material {
  39438. protected _activeEffect: Effect;
  39439. protected _normalMatrix: Matrix;
  39440. /**
  39441. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39442. * This means that the material can keep using a previous shader while a new one is being compiled.
  39443. * This is mostly used when shader parallel compilation is supported (true by default)
  39444. */
  39445. allowShaderHotSwapping: boolean;
  39446. constructor(name: string, scene: Scene);
  39447. getEffect(): Effect;
  39448. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39449. /**
  39450. * Binds the given world matrix to the active effect
  39451. *
  39452. * @param world the matrix to bind
  39453. */
  39454. bindOnlyWorldMatrix(world: Matrix): void;
  39455. /**
  39456. * Binds the given normal matrix to the active effect
  39457. *
  39458. * @param normalMatrix the matrix to bind
  39459. */
  39460. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39461. bind(world: Matrix, mesh?: Mesh): void;
  39462. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39463. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39464. }
  39465. }
  39466. declare module "babylonjs/Materials/materialFlags" {
  39467. /**
  39468. * This groups all the flags used to control the materials channel.
  39469. */
  39470. export class MaterialFlags {
  39471. private static _DiffuseTextureEnabled;
  39472. /**
  39473. * Are diffuse textures enabled in the application.
  39474. */
  39475. static DiffuseTextureEnabled: boolean;
  39476. private static _AmbientTextureEnabled;
  39477. /**
  39478. * Are ambient textures enabled in the application.
  39479. */
  39480. static AmbientTextureEnabled: boolean;
  39481. private static _OpacityTextureEnabled;
  39482. /**
  39483. * Are opacity textures enabled in the application.
  39484. */
  39485. static OpacityTextureEnabled: boolean;
  39486. private static _ReflectionTextureEnabled;
  39487. /**
  39488. * Are reflection textures enabled in the application.
  39489. */
  39490. static ReflectionTextureEnabled: boolean;
  39491. private static _EmissiveTextureEnabled;
  39492. /**
  39493. * Are emissive textures enabled in the application.
  39494. */
  39495. static EmissiveTextureEnabled: boolean;
  39496. private static _SpecularTextureEnabled;
  39497. /**
  39498. * Are specular textures enabled in the application.
  39499. */
  39500. static SpecularTextureEnabled: boolean;
  39501. private static _BumpTextureEnabled;
  39502. /**
  39503. * Are bump textures enabled in the application.
  39504. */
  39505. static BumpTextureEnabled: boolean;
  39506. private static _LightmapTextureEnabled;
  39507. /**
  39508. * Are lightmap textures enabled in the application.
  39509. */
  39510. static LightmapTextureEnabled: boolean;
  39511. private static _RefractionTextureEnabled;
  39512. /**
  39513. * Are refraction textures enabled in the application.
  39514. */
  39515. static RefractionTextureEnabled: boolean;
  39516. private static _ColorGradingTextureEnabled;
  39517. /**
  39518. * Are color grading textures enabled in the application.
  39519. */
  39520. static ColorGradingTextureEnabled: boolean;
  39521. private static _FresnelEnabled;
  39522. /**
  39523. * Are fresnels enabled in the application.
  39524. */
  39525. static FresnelEnabled: boolean;
  39526. private static _ClearCoatTextureEnabled;
  39527. /**
  39528. * Are clear coat textures enabled in the application.
  39529. */
  39530. static ClearCoatTextureEnabled: boolean;
  39531. private static _ClearCoatBumpTextureEnabled;
  39532. /**
  39533. * Are clear coat bump textures enabled in the application.
  39534. */
  39535. static ClearCoatBumpTextureEnabled: boolean;
  39536. private static _ClearCoatTintTextureEnabled;
  39537. /**
  39538. * Are clear coat tint textures enabled in the application.
  39539. */
  39540. static ClearCoatTintTextureEnabled: boolean;
  39541. private static _SheenTextureEnabled;
  39542. /**
  39543. * Are sheen textures enabled in the application.
  39544. */
  39545. static SheenTextureEnabled: boolean;
  39546. private static _AnisotropicTextureEnabled;
  39547. /**
  39548. * Are anisotropic textures enabled in the application.
  39549. */
  39550. static AnisotropicTextureEnabled: boolean;
  39551. private static _ThicknessTextureEnabled;
  39552. /**
  39553. * Are thickness textures enabled in the application.
  39554. */
  39555. static ThicknessTextureEnabled: boolean;
  39556. }
  39557. }
  39558. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39559. /** @hidden */
  39560. export var defaultFragmentDeclaration: {
  39561. name: string;
  39562. shader: string;
  39563. };
  39564. }
  39565. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39566. /** @hidden */
  39567. export var defaultUboDeclaration: {
  39568. name: string;
  39569. shader: string;
  39570. };
  39571. }
  39572. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39573. /** @hidden */
  39574. export var lightFragmentDeclaration: {
  39575. name: string;
  39576. shader: string;
  39577. };
  39578. }
  39579. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39580. /** @hidden */
  39581. export var lightUboDeclaration: {
  39582. name: string;
  39583. shader: string;
  39584. };
  39585. }
  39586. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39587. /** @hidden */
  39588. export var lightsFragmentFunctions: {
  39589. name: string;
  39590. shader: string;
  39591. };
  39592. }
  39593. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39594. /** @hidden */
  39595. export var shadowsFragmentFunctions: {
  39596. name: string;
  39597. shader: string;
  39598. };
  39599. }
  39600. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39601. /** @hidden */
  39602. export var fresnelFunction: {
  39603. name: string;
  39604. shader: string;
  39605. };
  39606. }
  39607. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39608. /** @hidden */
  39609. export var reflectionFunction: {
  39610. name: string;
  39611. shader: string;
  39612. };
  39613. }
  39614. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39615. /** @hidden */
  39616. export var bumpFragmentFunctions: {
  39617. name: string;
  39618. shader: string;
  39619. };
  39620. }
  39621. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39622. /** @hidden */
  39623. export var logDepthDeclaration: {
  39624. name: string;
  39625. shader: string;
  39626. };
  39627. }
  39628. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39629. /** @hidden */
  39630. export var bumpFragment: {
  39631. name: string;
  39632. shader: string;
  39633. };
  39634. }
  39635. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39636. /** @hidden */
  39637. export var depthPrePass: {
  39638. name: string;
  39639. shader: string;
  39640. };
  39641. }
  39642. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39643. /** @hidden */
  39644. export var lightFragment: {
  39645. name: string;
  39646. shader: string;
  39647. };
  39648. }
  39649. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39650. /** @hidden */
  39651. export var logDepthFragment: {
  39652. name: string;
  39653. shader: string;
  39654. };
  39655. }
  39656. declare module "babylonjs/Shaders/default.fragment" {
  39657. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39658. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39659. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39660. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39661. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39662. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39663. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39664. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39665. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39666. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39667. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39668. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39669. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39670. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39671. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39672. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39673. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39674. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39675. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39676. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39677. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39678. /** @hidden */
  39679. export var defaultPixelShader: {
  39680. name: string;
  39681. shader: string;
  39682. };
  39683. }
  39684. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39685. /** @hidden */
  39686. export var defaultVertexDeclaration: {
  39687. name: string;
  39688. shader: string;
  39689. };
  39690. }
  39691. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39692. /** @hidden */
  39693. export var bumpVertexDeclaration: {
  39694. name: string;
  39695. shader: string;
  39696. };
  39697. }
  39698. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39699. /** @hidden */
  39700. export var bumpVertex: {
  39701. name: string;
  39702. shader: string;
  39703. };
  39704. }
  39705. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39706. /** @hidden */
  39707. export var fogVertex: {
  39708. name: string;
  39709. shader: string;
  39710. };
  39711. }
  39712. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39713. /** @hidden */
  39714. export var shadowsVertex: {
  39715. name: string;
  39716. shader: string;
  39717. };
  39718. }
  39719. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39720. /** @hidden */
  39721. export var pointCloudVertex: {
  39722. name: string;
  39723. shader: string;
  39724. };
  39725. }
  39726. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39727. /** @hidden */
  39728. export var logDepthVertex: {
  39729. name: string;
  39730. shader: string;
  39731. };
  39732. }
  39733. declare module "babylonjs/Shaders/default.vertex" {
  39734. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39735. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39737. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39738. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39739. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39741. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39742. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39743. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39744. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39745. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39746. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39747. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39748. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39749. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39750. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39751. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39752. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39753. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39754. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39755. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39756. /** @hidden */
  39757. export var defaultVertexShader: {
  39758. name: string;
  39759. shader: string;
  39760. };
  39761. }
  39762. declare module "babylonjs/Materials/standardMaterial" {
  39763. import { SmartArray } from "babylonjs/Misc/smartArray";
  39764. import { IAnimatable } from "babylonjs/Misc/tools";
  39765. import { Nullable } from "babylonjs/types";
  39766. import { Scene } from "babylonjs/scene";
  39767. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39770. import { Mesh } from "babylonjs/Meshes/mesh";
  39771. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39772. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39773. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39774. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39775. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39778. import "babylonjs/Shaders/default.fragment";
  39779. import "babylonjs/Shaders/default.vertex";
  39780. /** @hidden */
  39781. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39782. MAINUV1: boolean;
  39783. MAINUV2: boolean;
  39784. DIFFUSE: boolean;
  39785. DIFFUSEDIRECTUV: number;
  39786. AMBIENT: boolean;
  39787. AMBIENTDIRECTUV: number;
  39788. OPACITY: boolean;
  39789. OPACITYDIRECTUV: number;
  39790. OPACITYRGB: boolean;
  39791. REFLECTION: boolean;
  39792. EMISSIVE: boolean;
  39793. EMISSIVEDIRECTUV: number;
  39794. SPECULAR: boolean;
  39795. SPECULARDIRECTUV: number;
  39796. BUMP: boolean;
  39797. BUMPDIRECTUV: number;
  39798. PARALLAX: boolean;
  39799. PARALLAXOCCLUSION: boolean;
  39800. SPECULAROVERALPHA: boolean;
  39801. CLIPPLANE: boolean;
  39802. CLIPPLANE2: boolean;
  39803. CLIPPLANE3: boolean;
  39804. CLIPPLANE4: boolean;
  39805. ALPHATEST: boolean;
  39806. DEPTHPREPASS: boolean;
  39807. ALPHAFROMDIFFUSE: boolean;
  39808. POINTSIZE: boolean;
  39809. FOG: boolean;
  39810. SPECULARTERM: boolean;
  39811. DIFFUSEFRESNEL: boolean;
  39812. OPACITYFRESNEL: boolean;
  39813. REFLECTIONFRESNEL: boolean;
  39814. REFRACTIONFRESNEL: boolean;
  39815. EMISSIVEFRESNEL: boolean;
  39816. FRESNEL: boolean;
  39817. NORMAL: boolean;
  39818. UV1: boolean;
  39819. UV2: boolean;
  39820. VERTEXCOLOR: boolean;
  39821. VERTEXALPHA: boolean;
  39822. NUM_BONE_INFLUENCERS: number;
  39823. BonesPerMesh: number;
  39824. BONETEXTURE: boolean;
  39825. INSTANCES: boolean;
  39826. GLOSSINESS: boolean;
  39827. ROUGHNESS: boolean;
  39828. EMISSIVEASILLUMINATION: boolean;
  39829. LINKEMISSIVEWITHDIFFUSE: boolean;
  39830. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39831. LIGHTMAP: boolean;
  39832. LIGHTMAPDIRECTUV: number;
  39833. OBJECTSPACE_NORMALMAP: boolean;
  39834. USELIGHTMAPASSHADOWMAP: boolean;
  39835. REFLECTIONMAP_3D: boolean;
  39836. REFLECTIONMAP_SPHERICAL: boolean;
  39837. REFLECTIONMAP_PLANAR: boolean;
  39838. REFLECTIONMAP_CUBIC: boolean;
  39839. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39840. REFLECTIONMAP_PROJECTION: boolean;
  39841. REFLECTIONMAP_SKYBOX: boolean;
  39842. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39843. REFLECTIONMAP_EXPLICIT: boolean;
  39844. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39845. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39846. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39847. INVERTCUBICMAP: boolean;
  39848. LOGARITHMICDEPTH: boolean;
  39849. REFRACTION: boolean;
  39850. REFRACTIONMAP_3D: boolean;
  39851. REFLECTIONOVERALPHA: boolean;
  39852. TWOSIDEDLIGHTING: boolean;
  39853. SHADOWFLOAT: boolean;
  39854. MORPHTARGETS: boolean;
  39855. MORPHTARGETS_NORMAL: boolean;
  39856. MORPHTARGETS_TANGENT: boolean;
  39857. NUM_MORPH_INFLUENCERS: number;
  39858. NONUNIFORMSCALING: boolean;
  39859. PREMULTIPLYALPHA: boolean;
  39860. IMAGEPROCESSING: boolean;
  39861. VIGNETTE: boolean;
  39862. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39863. VIGNETTEBLENDMODEOPAQUE: boolean;
  39864. TONEMAPPING: boolean;
  39865. TONEMAPPING_ACES: boolean;
  39866. CONTRAST: boolean;
  39867. COLORCURVES: boolean;
  39868. COLORGRADING: boolean;
  39869. COLORGRADING3D: boolean;
  39870. SAMPLER3DGREENDEPTH: boolean;
  39871. SAMPLER3DBGRMAP: boolean;
  39872. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39873. MULTIVIEW: boolean;
  39874. /**
  39875. * If the reflection texture on this material is in linear color space
  39876. * @hidden
  39877. */
  39878. IS_REFLECTION_LINEAR: boolean;
  39879. /**
  39880. * If the refraction texture on this material is in linear color space
  39881. * @hidden
  39882. */
  39883. IS_REFRACTION_LINEAR: boolean;
  39884. EXPOSURE: boolean;
  39885. constructor();
  39886. setReflectionMode(modeToEnable: string): void;
  39887. }
  39888. /**
  39889. * This is the default material used in Babylon. It is the best trade off between quality
  39890. * and performances.
  39891. * @see http://doc.babylonjs.com/babylon101/materials
  39892. */
  39893. export class StandardMaterial extends PushMaterial {
  39894. private _diffuseTexture;
  39895. /**
  39896. * The basic texture of the material as viewed under a light.
  39897. */
  39898. diffuseTexture: Nullable<BaseTexture>;
  39899. private _ambientTexture;
  39900. /**
  39901. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39902. */
  39903. ambientTexture: Nullable<BaseTexture>;
  39904. private _opacityTexture;
  39905. /**
  39906. * Define the transparency of the material from a texture.
  39907. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39908. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39909. */
  39910. opacityTexture: Nullable<BaseTexture>;
  39911. private _reflectionTexture;
  39912. /**
  39913. * Define the texture used to display the reflection.
  39914. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39915. */
  39916. reflectionTexture: Nullable<BaseTexture>;
  39917. private _emissiveTexture;
  39918. /**
  39919. * Define texture of the material as if self lit.
  39920. * This will be mixed in the final result even in the absence of light.
  39921. */
  39922. emissiveTexture: Nullable<BaseTexture>;
  39923. private _specularTexture;
  39924. /**
  39925. * Define how the color and intensity of the highlight given by the light in the material.
  39926. */
  39927. specularTexture: Nullable<BaseTexture>;
  39928. private _bumpTexture;
  39929. /**
  39930. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39931. * 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.
  39932. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39933. */
  39934. bumpTexture: Nullable<BaseTexture>;
  39935. private _lightmapTexture;
  39936. /**
  39937. * Complex lighting can be computationally expensive to compute at runtime.
  39938. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39939. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39940. */
  39941. lightmapTexture: Nullable<BaseTexture>;
  39942. private _refractionTexture;
  39943. /**
  39944. * Define the texture used to display the refraction.
  39945. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39946. */
  39947. refractionTexture: Nullable<BaseTexture>;
  39948. /**
  39949. * The color of the material lit by the environmental background lighting.
  39950. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39951. */
  39952. ambientColor: Color3;
  39953. /**
  39954. * The basic color of the material as viewed under a light.
  39955. */
  39956. diffuseColor: Color3;
  39957. /**
  39958. * Define how the color and intensity of the highlight given by the light in the material.
  39959. */
  39960. specularColor: Color3;
  39961. /**
  39962. * Define the color of the material as if self lit.
  39963. * This will be mixed in the final result even in the absence of light.
  39964. */
  39965. emissiveColor: Color3;
  39966. /**
  39967. * Defines how sharp are the highlights in the material.
  39968. * The bigger the value the sharper giving a more glossy feeling to the result.
  39969. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39970. */
  39971. specularPower: number;
  39972. private _useAlphaFromDiffuseTexture;
  39973. /**
  39974. * Does the transparency come from the diffuse texture alpha channel.
  39975. */
  39976. useAlphaFromDiffuseTexture: boolean;
  39977. private _useEmissiveAsIllumination;
  39978. /**
  39979. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39980. */
  39981. useEmissiveAsIllumination: boolean;
  39982. private _linkEmissiveWithDiffuse;
  39983. /**
  39984. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39985. * the emissive level when the final color is close to one.
  39986. */
  39987. linkEmissiveWithDiffuse: boolean;
  39988. private _useSpecularOverAlpha;
  39989. /**
  39990. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39991. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39992. */
  39993. useSpecularOverAlpha: boolean;
  39994. private _useReflectionOverAlpha;
  39995. /**
  39996. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39997. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39998. */
  39999. useReflectionOverAlpha: boolean;
  40000. private _disableLighting;
  40001. /**
  40002. * Does lights from the scene impacts this material.
  40003. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40004. */
  40005. disableLighting: boolean;
  40006. private _useObjectSpaceNormalMap;
  40007. /**
  40008. * Allows using an object space normal map (instead of tangent space).
  40009. */
  40010. useObjectSpaceNormalMap: boolean;
  40011. private _useParallax;
  40012. /**
  40013. * Is parallax enabled or not.
  40014. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40015. */
  40016. useParallax: boolean;
  40017. private _useParallaxOcclusion;
  40018. /**
  40019. * Is parallax occlusion enabled or not.
  40020. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40021. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40022. */
  40023. useParallaxOcclusion: boolean;
  40024. /**
  40025. * 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.
  40026. */
  40027. parallaxScaleBias: number;
  40028. private _roughness;
  40029. /**
  40030. * Helps to define how blurry the reflections should appears in the material.
  40031. */
  40032. roughness: number;
  40033. /**
  40034. * In case of refraction, define the value of the indice of refraction.
  40035. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40036. */
  40037. indexOfRefraction: number;
  40038. /**
  40039. * Invert the refraction texture alongside the y axis.
  40040. * It can be useful with procedural textures or probe for instance.
  40041. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40042. */
  40043. invertRefractionY: boolean;
  40044. /**
  40045. * Defines the alpha limits in alpha test mode.
  40046. */
  40047. alphaCutOff: number;
  40048. private _useLightmapAsShadowmap;
  40049. /**
  40050. * In case of light mapping, define whether the map contains light or shadow informations.
  40051. */
  40052. useLightmapAsShadowmap: boolean;
  40053. private _diffuseFresnelParameters;
  40054. /**
  40055. * Define the diffuse fresnel parameters of the material.
  40056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40057. */
  40058. diffuseFresnelParameters: FresnelParameters;
  40059. private _opacityFresnelParameters;
  40060. /**
  40061. * Define the opacity fresnel parameters of the material.
  40062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40063. */
  40064. opacityFresnelParameters: FresnelParameters;
  40065. private _reflectionFresnelParameters;
  40066. /**
  40067. * Define the reflection fresnel parameters of the material.
  40068. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40069. */
  40070. reflectionFresnelParameters: FresnelParameters;
  40071. private _refractionFresnelParameters;
  40072. /**
  40073. * Define the refraction fresnel parameters of the material.
  40074. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40075. */
  40076. refractionFresnelParameters: FresnelParameters;
  40077. private _emissiveFresnelParameters;
  40078. /**
  40079. * Define the emissive fresnel parameters of the material.
  40080. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40081. */
  40082. emissiveFresnelParameters: FresnelParameters;
  40083. private _useReflectionFresnelFromSpecular;
  40084. /**
  40085. * If true automatically deducts the fresnels values from the material specularity.
  40086. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40087. */
  40088. useReflectionFresnelFromSpecular: boolean;
  40089. private _useGlossinessFromSpecularMapAlpha;
  40090. /**
  40091. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40092. */
  40093. useGlossinessFromSpecularMapAlpha: boolean;
  40094. private _maxSimultaneousLights;
  40095. /**
  40096. * Defines the maximum number of lights that can be used in the material
  40097. */
  40098. maxSimultaneousLights: number;
  40099. private _invertNormalMapX;
  40100. /**
  40101. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40102. */
  40103. invertNormalMapX: boolean;
  40104. private _invertNormalMapY;
  40105. /**
  40106. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40107. */
  40108. invertNormalMapY: boolean;
  40109. private _twoSidedLighting;
  40110. /**
  40111. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40112. */
  40113. twoSidedLighting: boolean;
  40114. /**
  40115. * Default configuration related to image processing available in the standard Material.
  40116. */
  40117. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40118. /**
  40119. * Gets the image processing configuration used either in this material.
  40120. */
  40121. /**
  40122. * Sets the Default image processing configuration used either in the this material.
  40123. *
  40124. * If sets to null, the scene one is in use.
  40125. */
  40126. imageProcessingConfiguration: ImageProcessingConfiguration;
  40127. /**
  40128. * Keep track of the image processing observer to allow dispose and replace.
  40129. */
  40130. private _imageProcessingObserver;
  40131. /**
  40132. * Attaches a new image processing configuration to the Standard Material.
  40133. * @param configuration
  40134. */
  40135. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40136. /**
  40137. * Gets wether the color curves effect is enabled.
  40138. */
  40139. /**
  40140. * Sets wether the color curves effect is enabled.
  40141. */
  40142. cameraColorCurvesEnabled: boolean;
  40143. /**
  40144. * Gets wether the color grading effect is enabled.
  40145. */
  40146. /**
  40147. * Gets wether the color grading effect is enabled.
  40148. */
  40149. cameraColorGradingEnabled: boolean;
  40150. /**
  40151. * Gets wether tonemapping is enabled or not.
  40152. */
  40153. /**
  40154. * Sets wether tonemapping is enabled or not
  40155. */
  40156. cameraToneMappingEnabled: boolean;
  40157. /**
  40158. * The camera exposure used on this material.
  40159. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40160. * This corresponds to a photographic exposure.
  40161. */
  40162. /**
  40163. * The camera exposure used on this material.
  40164. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40165. * This corresponds to a photographic exposure.
  40166. */
  40167. cameraExposure: number;
  40168. /**
  40169. * Gets The camera contrast used on this material.
  40170. */
  40171. /**
  40172. * Sets The camera contrast used on this material.
  40173. */
  40174. cameraContrast: number;
  40175. /**
  40176. * Gets the Color Grading 2D Lookup Texture.
  40177. */
  40178. /**
  40179. * Sets the Color Grading 2D Lookup Texture.
  40180. */
  40181. cameraColorGradingTexture: Nullable<BaseTexture>;
  40182. /**
  40183. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40184. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40185. * 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;
  40186. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40187. */
  40188. /**
  40189. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40190. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40191. * 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;
  40192. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40193. */
  40194. cameraColorCurves: Nullable<ColorCurves>;
  40195. /**
  40196. * Custom callback helping to override the default shader used in the material.
  40197. */
  40198. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40199. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40200. protected _worldViewProjectionMatrix: Matrix;
  40201. protected _globalAmbientColor: Color3;
  40202. protected _useLogarithmicDepth: boolean;
  40203. /**
  40204. * Instantiates a new standard material.
  40205. * This is the default material used in Babylon. It is the best trade off between quality
  40206. * and performances.
  40207. * @see http://doc.babylonjs.com/babylon101/materials
  40208. * @param name Define the name of the material in the scene
  40209. * @param scene Define the scene the material belong to
  40210. */
  40211. constructor(name: string, scene: Scene);
  40212. /**
  40213. * Gets a boolean indicating that current material needs to register RTT
  40214. */
  40215. readonly hasRenderTargetTextures: boolean;
  40216. /**
  40217. * Gets the current class name of the material e.g. "StandardMaterial"
  40218. * Mainly use in serialization.
  40219. * @returns the class name
  40220. */
  40221. getClassName(): string;
  40222. /**
  40223. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40224. * You can try switching to logarithmic depth.
  40225. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40226. */
  40227. useLogarithmicDepth: boolean;
  40228. /**
  40229. * Specifies if the material will require alpha blending
  40230. * @returns a boolean specifying if alpha blending is needed
  40231. */
  40232. needAlphaBlending(): boolean;
  40233. /**
  40234. * Specifies if this material should be rendered in alpha test mode
  40235. * @returns a boolean specifying if an alpha test is needed.
  40236. */
  40237. needAlphaTesting(): boolean;
  40238. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40239. /**
  40240. * Get the texture used for alpha test purpose.
  40241. * @returns the diffuse texture in case of the standard material.
  40242. */
  40243. getAlphaTestTexture(): Nullable<BaseTexture>;
  40244. /**
  40245. * Get if the submesh is ready to be used and all its information available.
  40246. * Child classes can use it to update shaders
  40247. * @param mesh defines the mesh to check
  40248. * @param subMesh defines which submesh to check
  40249. * @param useInstances specifies that instances should be used
  40250. * @returns a boolean indicating that the submesh is ready or not
  40251. */
  40252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40253. /**
  40254. * Builds the material UBO layouts.
  40255. * Used internally during the effect preparation.
  40256. */
  40257. buildUniformLayout(): void;
  40258. /**
  40259. * Unbinds the material from the mesh
  40260. */
  40261. unbind(): void;
  40262. /**
  40263. * Binds the submesh to this material by preparing the effect and shader to draw
  40264. * @param world defines the world transformation matrix
  40265. * @param mesh defines the mesh containing the submesh
  40266. * @param subMesh defines the submesh to bind the material to
  40267. */
  40268. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40269. /**
  40270. * Get the list of animatables in the material.
  40271. * @returns the list of animatables object used in the material
  40272. */
  40273. getAnimatables(): IAnimatable[];
  40274. /**
  40275. * Gets the active textures from the material
  40276. * @returns an array of textures
  40277. */
  40278. getActiveTextures(): BaseTexture[];
  40279. /**
  40280. * Specifies if the material uses a texture
  40281. * @param texture defines the texture to check against the material
  40282. * @returns a boolean specifying if the material uses the texture
  40283. */
  40284. hasTexture(texture: BaseTexture): boolean;
  40285. /**
  40286. * Disposes the material
  40287. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40288. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40289. */
  40290. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40291. /**
  40292. * Makes a duplicate of the material, and gives it a new name
  40293. * @param name defines the new name for the duplicated material
  40294. * @returns the cloned material
  40295. */
  40296. clone(name: string): StandardMaterial;
  40297. /**
  40298. * Serializes this material in a JSON representation
  40299. * @returns the serialized material object
  40300. */
  40301. serialize(): any;
  40302. /**
  40303. * Creates a standard material from parsed material data
  40304. * @param source defines the JSON representation of the material
  40305. * @param scene defines the hosting scene
  40306. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40307. * @returns a new standard material
  40308. */
  40309. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40310. /**
  40311. * Are diffuse textures enabled in the application.
  40312. */
  40313. static DiffuseTextureEnabled: boolean;
  40314. /**
  40315. * Are ambient textures enabled in the application.
  40316. */
  40317. static AmbientTextureEnabled: boolean;
  40318. /**
  40319. * Are opacity textures enabled in the application.
  40320. */
  40321. static OpacityTextureEnabled: boolean;
  40322. /**
  40323. * Are reflection textures enabled in the application.
  40324. */
  40325. static ReflectionTextureEnabled: boolean;
  40326. /**
  40327. * Are emissive textures enabled in the application.
  40328. */
  40329. static EmissiveTextureEnabled: boolean;
  40330. /**
  40331. * Are specular textures enabled in the application.
  40332. */
  40333. static SpecularTextureEnabled: boolean;
  40334. /**
  40335. * Are bump textures enabled in the application.
  40336. */
  40337. static BumpTextureEnabled: boolean;
  40338. /**
  40339. * Are lightmap textures enabled in the application.
  40340. */
  40341. static LightmapTextureEnabled: boolean;
  40342. /**
  40343. * Are refraction textures enabled in the application.
  40344. */
  40345. static RefractionTextureEnabled: boolean;
  40346. /**
  40347. * Are color grading textures enabled in the application.
  40348. */
  40349. static ColorGradingTextureEnabled: boolean;
  40350. /**
  40351. * Are fresnels enabled in the application.
  40352. */
  40353. static FresnelEnabled: boolean;
  40354. }
  40355. }
  40356. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40357. import { Scene } from "babylonjs/scene";
  40358. import { Texture } from "babylonjs/Materials/Textures/texture";
  40359. /**
  40360. * A class extending Texture allowing drawing on a texture
  40361. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40362. */
  40363. export class DynamicTexture extends Texture {
  40364. private _generateMipMaps;
  40365. private _canvas;
  40366. private _context;
  40367. private _engine;
  40368. /**
  40369. * Creates a DynamicTexture
  40370. * @param name defines the name of the texture
  40371. * @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
  40372. * @param scene defines the scene where you want the texture
  40373. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40374. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40375. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40376. */
  40377. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40378. /**
  40379. * Get the current class name of the texture useful for serialization or dynamic coding.
  40380. * @returns "DynamicTexture"
  40381. */
  40382. getClassName(): string;
  40383. /**
  40384. * Gets the current state of canRescale
  40385. */
  40386. readonly canRescale: boolean;
  40387. private _recreate;
  40388. /**
  40389. * Scales the texture
  40390. * @param ratio the scale factor to apply to both width and height
  40391. */
  40392. scale(ratio: number): void;
  40393. /**
  40394. * Resizes the texture
  40395. * @param width the new width
  40396. * @param height the new height
  40397. */
  40398. scaleTo(width: number, height: number): void;
  40399. /**
  40400. * Gets the context of the canvas used by the texture
  40401. * @returns the canvas context of the dynamic texture
  40402. */
  40403. getContext(): CanvasRenderingContext2D;
  40404. /**
  40405. * Clears the texture
  40406. */
  40407. clear(): void;
  40408. /**
  40409. * Updates the texture
  40410. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40411. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40412. */
  40413. update(invertY?: boolean, premulAlpha?: boolean): void;
  40414. /**
  40415. * Draws text onto the texture
  40416. * @param text defines the text to be drawn
  40417. * @param x defines the placement of the text from the left
  40418. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40419. * @param font defines the font to be used with font-style, font-size, font-name
  40420. * @param color defines the color used for the text
  40421. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40422. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40423. * @param update defines whether texture is immediately update (default is true)
  40424. */
  40425. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40426. /**
  40427. * Clones the texture
  40428. * @returns the clone of the texture.
  40429. */
  40430. clone(): DynamicTexture;
  40431. /**
  40432. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40433. * @returns a serialized dynamic texture object
  40434. */
  40435. serialize(): any;
  40436. /** @hidden */
  40437. _rebuild(): void;
  40438. }
  40439. }
  40440. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40441. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40443. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40444. /** @hidden */
  40445. export var imageProcessingPixelShader: {
  40446. name: string;
  40447. shader: string;
  40448. };
  40449. }
  40450. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40451. import { Nullable } from "babylonjs/types";
  40452. import { Color4 } from "babylonjs/Maths/math";
  40453. import { Camera } from "babylonjs/Cameras/camera";
  40454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40455. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40456. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40457. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40458. import { Engine } from "babylonjs/Engines/engine";
  40459. import "babylonjs/Shaders/imageProcessing.fragment";
  40460. import "babylonjs/Shaders/postprocess.vertex";
  40461. /**
  40462. * ImageProcessingPostProcess
  40463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40464. */
  40465. export class ImageProcessingPostProcess extends PostProcess {
  40466. /**
  40467. * Default configuration related to image processing available in the PBR Material.
  40468. */
  40469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40470. /**
  40471. * Gets the image processing configuration used either in this material.
  40472. */
  40473. /**
  40474. * Sets the Default image processing configuration used either in the this material.
  40475. *
  40476. * If sets to null, the scene one is in use.
  40477. */
  40478. imageProcessingConfiguration: ImageProcessingConfiguration;
  40479. /**
  40480. * Keep track of the image processing observer to allow dispose and replace.
  40481. */
  40482. private _imageProcessingObserver;
  40483. /**
  40484. * Attaches a new image processing configuration to the PBR Material.
  40485. * @param configuration
  40486. */
  40487. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40488. /**
  40489. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40490. */
  40491. /**
  40492. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40493. */
  40494. colorCurves: Nullable<ColorCurves>;
  40495. /**
  40496. * Gets wether the color curves effect is enabled.
  40497. */
  40498. /**
  40499. * Sets wether the color curves effect is enabled.
  40500. */
  40501. colorCurvesEnabled: boolean;
  40502. /**
  40503. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40504. */
  40505. /**
  40506. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40507. */
  40508. colorGradingTexture: Nullable<BaseTexture>;
  40509. /**
  40510. * Gets wether the color grading effect is enabled.
  40511. */
  40512. /**
  40513. * Gets wether the color grading effect is enabled.
  40514. */
  40515. colorGradingEnabled: boolean;
  40516. /**
  40517. * Gets exposure used in the effect.
  40518. */
  40519. /**
  40520. * Sets exposure used in the effect.
  40521. */
  40522. exposure: number;
  40523. /**
  40524. * Gets wether tonemapping is enabled or not.
  40525. */
  40526. /**
  40527. * Sets wether tonemapping is enabled or not
  40528. */
  40529. toneMappingEnabled: boolean;
  40530. /**
  40531. * Gets the type of tone mapping effect.
  40532. */
  40533. /**
  40534. * Sets the type of tone mapping effect.
  40535. */
  40536. toneMappingType: number;
  40537. /**
  40538. * Gets contrast used in the effect.
  40539. */
  40540. /**
  40541. * Sets contrast used in the effect.
  40542. */
  40543. contrast: number;
  40544. /**
  40545. * Gets Vignette stretch size.
  40546. */
  40547. /**
  40548. * Sets Vignette stretch size.
  40549. */
  40550. vignetteStretch: number;
  40551. /**
  40552. * Gets Vignette centre X Offset.
  40553. */
  40554. /**
  40555. * Sets Vignette centre X Offset.
  40556. */
  40557. vignetteCentreX: number;
  40558. /**
  40559. * Gets Vignette centre Y Offset.
  40560. */
  40561. /**
  40562. * Sets Vignette centre Y Offset.
  40563. */
  40564. vignetteCentreY: number;
  40565. /**
  40566. * Gets Vignette weight or intensity of the vignette effect.
  40567. */
  40568. /**
  40569. * Sets Vignette weight or intensity of the vignette effect.
  40570. */
  40571. vignetteWeight: number;
  40572. /**
  40573. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40574. * if vignetteEnabled is set to true.
  40575. */
  40576. /**
  40577. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40578. * if vignetteEnabled is set to true.
  40579. */
  40580. vignetteColor: Color4;
  40581. /**
  40582. * Gets Camera field of view used by the Vignette effect.
  40583. */
  40584. /**
  40585. * Sets Camera field of view used by the Vignette effect.
  40586. */
  40587. vignetteCameraFov: number;
  40588. /**
  40589. * Gets the vignette blend mode allowing different kind of effect.
  40590. */
  40591. /**
  40592. * Sets the vignette blend mode allowing different kind of effect.
  40593. */
  40594. vignetteBlendMode: number;
  40595. /**
  40596. * Gets wether the vignette effect is enabled.
  40597. */
  40598. /**
  40599. * Sets wether the vignette effect is enabled.
  40600. */
  40601. vignetteEnabled: boolean;
  40602. private _fromLinearSpace;
  40603. /**
  40604. * Gets wether the input of the processing is in Gamma or Linear Space.
  40605. */
  40606. /**
  40607. * Sets wether the input of the processing is in Gamma or Linear Space.
  40608. */
  40609. fromLinearSpace: boolean;
  40610. /**
  40611. * Defines cache preventing GC.
  40612. */
  40613. private _defines;
  40614. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40615. /**
  40616. * "ImageProcessingPostProcess"
  40617. * @returns "ImageProcessingPostProcess"
  40618. */
  40619. getClassName(): string;
  40620. protected _updateParameters(): void;
  40621. dispose(camera?: Camera): void;
  40622. }
  40623. }
  40624. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40625. import { Scene } from "babylonjs/scene";
  40626. import { Color3 } from "babylonjs/Maths/math";
  40627. import { Mesh } from "babylonjs/Meshes/mesh";
  40628. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40629. import { Nullable } from "babylonjs/types";
  40630. /**
  40631. * Class containing static functions to help procedurally build meshes
  40632. */
  40633. export class GroundBuilder {
  40634. /**
  40635. * Creates a ground mesh
  40636. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40637. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40639. * @param name defines the name of the mesh
  40640. * @param options defines the options used to create the mesh
  40641. * @param scene defines the hosting scene
  40642. * @returns the ground mesh
  40643. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40644. */
  40645. static CreateGround(name: string, options: {
  40646. width?: number;
  40647. height?: number;
  40648. subdivisions?: number;
  40649. subdivisionsX?: number;
  40650. subdivisionsY?: number;
  40651. updatable?: boolean;
  40652. }, scene: any): Mesh;
  40653. /**
  40654. * Creates a tiled ground mesh
  40655. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40656. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40657. * * 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
  40658. * * 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
  40659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40660. * @param name defines the name of the mesh
  40661. * @param options defines the options used to create the mesh
  40662. * @param scene defines the hosting scene
  40663. * @returns the tiled ground mesh
  40664. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40665. */
  40666. static CreateTiledGround(name: string, options: {
  40667. xmin: number;
  40668. zmin: number;
  40669. xmax: number;
  40670. zmax: number;
  40671. subdivisions?: {
  40672. w: number;
  40673. h: number;
  40674. };
  40675. precision?: {
  40676. w: number;
  40677. h: number;
  40678. };
  40679. updatable?: boolean;
  40680. }, scene?: Nullable<Scene>): Mesh;
  40681. /**
  40682. * Creates a ground mesh from a height map
  40683. * * The parameter `url` sets the URL of the height map image resource.
  40684. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40685. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40686. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40687. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40688. * * 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.
  40689. * * 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).
  40690. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40692. * @param name defines the name of the mesh
  40693. * @param url defines the url to the height map
  40694. * @param options defines the options used to create the mesh
  40695. * @param scene defines the hosting scene
  40696. * @returns the ground mesh
  40697. * @see https://doc.babylonjs.com/babylon101/height_map
  40698. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40699. */
  40700. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40701. width?: number;
  40702. height?: number;
  40703. subdivisions?: number;
  40704. minHeight?: number;
  40705. maxHeight?: number;
  40706. colorFilter?: Color3;
  40707. alphaFilter?: number;
  40708. updatable?: boolean;
  40709. onReady?: (mesh: GroundMesh) => void;
  40710. }, scene?: Nullable<Scene>): GroundMesh;
  40711. }
  40712. }
  40713. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40714. import { Vector4 } from "babylonjs/Maths/math";
  40715. import { Mesh } from "babylonjs/Meshes/mesh";
  40716. /**
  40717. * Class containing static functions to help procedurally build meshes
  40718. */
  40719. export class TorusBuilder {
  40720. /**
  40721. * Creates a torus mesh
  40722. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40723. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40724. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40728. * @param name defines the name of the mesh
  40729. * @param options defines the options used to create the mesh
  40730. * @param scene defines the hosting scene
  40731. * @returns the torus mesh
  40732. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40733. */
  40734. static CreateTorus(name: string, options: {
  40735. diameter?: number;
  40736. thickness?: number;
  40737. tessellation?: number;
  40738. updatable?: boolean;
  40739. sideOrientation?: number;
  40740. frontUVs?: Vector4;
  40741. backUVs?: Vector4;
  40742. }, scene: any): Mesh;
  40743. }
  40744. }
  40745. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40746. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40747. import { Mesh } from "babylonjs/Meshes/mesh";
  40748. /**
  40749. * Class containing static functions to help procedurally build meshes
  40750. */
  40751. export class CylinderBuilder {
  40752. /**
  40753. * Creates a cylinder or a cone mesh
  40754. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40755. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40756. * * 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.
  40757. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40758. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40759. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40760. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40761. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40762. * * 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).
  40763. * * 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
  40764. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40765. * * 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
  40766. * * 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.
  40767. * * If `enclose` is false, a ring surface is one element.
  40768. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40769. * * 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
  40770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40773. * @param name defines the name of the mesh
  40774. * @param options defines the options used to create the mesh
  40775. * @param scene defines the hosting scene
  40776. * @returns the cylinder mesh
  40777. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40778. */
  40779. static CreateCylinder(name: string, options: {
  40780. height?: number;
  40781. diameterTop?: number;
  40782. diameterBottom?: number;
  40783. diameter?: number;
  40784. tessellation?: number;
  40785. subdivisions?: number;
  40786. arc?: number;
  40787. faceColors?: Color4[];
  40788. faceUV?: Vector4[];
  40789. updatable?: boolean;
  40790. hasRings?: boolean;
  40791. enclose?: boolean;
  40792. sideOrientation?: number;
  40793. frontUVs?: Vector4;
  40794. backUVs?: Vector4;
  40795. }, scene: any): Mesh;
  40796. }
  40797. }
  40798. declare module "babylonjs/Gamepads/gamepadManager" {
  40799. import { Observable } from "babylonjs/Misc/observable";
  40800. import { Nullable } from "babylonjs/types";
  40801. import { Scene } from "babylonjs/scene";
  40802. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40803. /**
  40804. * Manager for handling gamepads
  40805. */
  40806. export class GamepadManager {
  40807. private _scene?;
  40808. private _babylonGamepads;
  40809. private _oneGamepadConnected;
  40810. /** @hidden */
  40811. _isMonitoring: boolean;
  40812. private _gamepadEventSupported;
  40813. private _gamepadSupport;
  40814. /**
  40815. * observable to be triggered when the gamepad controller has been connected
  40816. */
  40817. onGamepadConnectedObservable: Observable<Gamepad>;
  40818. /**
  40819. * observable to be triggered when the gamepad controller has been disconnected
  40820. */
  40821. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40822. private _onGamepadConnectedEvent;
  40823. private _onGamepadDisconnectedEvent;
  40824. /**
  40825. * Initializes the gamepad manager
  40826. * @param _scene BabylonJS scene
  40827. */
  40828. constructor(_scene?: Scene | undefined);
  40829. /**
  40830. * The gamepads in the game pad manager
  40831. */
  40832. readonly gamepads: Gamepad[];
  40833. /**
  40834. * Get the gamepad controllers based on type
  40835. * @param type The type of gamepad controller
  40836. * @returns Nullable gamepad
  40837. */
  40838. getGamepadByType(type?: number): Nullable<Gamepad>;
  40839. /**
  40840. * Disposes the gamepad manager
  40841. */
  40842. dispose(): void;
  40843. private _addNewGamepad;
  40844. private _startMonitoringGamepads;
  40845. private _stopMonitoringGamepads;
  40846. /** @hidden */
  40847. _checkGamepadsStatus(): void;
  40848. private _updateGamepadObjects;
  40849. }
  40850. }
  40851. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40852. import { Nullable } from "babylonjs/types";
  40853. import { Scene } from "babylonjs/scene";
  40854. import { ISceneComponent } from "babylonjs/sceneComponent";
  40855. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40856. module "babylonjs/scene" {
  40857. interface Scene {
  40858. /** @hidden */
  40859. _gamepadManager: Nullable<GamepadManager>;
  40860. /**
  40861. * Gets the gamepad manager associated with the scene
  40862. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40863. */
  40864. gamepadManager: GamepadManager;
  40865. }
  40866. }
  40867. module "babylonjs/Cameras/freeCameraInputsManager" {
  40868. /**
  40869. * Interface representing a free camera inputs manager
  40870. */
  40871. interface FreeCameraInputsManager {
  40872. /**
  40873. * Adds gamepad input support to the FreeCameraInputsManager.
  40874. * @returns the FreeCameraInputsManager
  40875. */
  40876. addGamepad(): FreeCameraInputsManager;
  40877. }
  40878. }
  40879. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40880. /**
  40881. * Interface representing an arc rotate camera inputs manager
  40882. */
  40883. interface ArcRotateCameraInputsManager {
  40884. /**
  40885. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40886. * @returns the camera inputs manager
  40887. */
  40888. addGamepad(): ArcRotateCameraInputsManager;
  40889. }
  40890. }
  40891. /**
  40892. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40893. */
  40894. export class GamepadSystemSceneComponent implements ISceneComponent {
  40895. /**
  40896. * The component name helpfull to identify the component in the list of scene components.
  40897. */
  40898. readonly name: string;
  40899. /**
  40900. * The scene the component belongs to.
  40901. */
  40902. scene: Scene;
  40903. /**
  40904. * Creates a new instance of the component for the given scene
  40905. * @param scene Defines the scene to register the component in
  40906. */
  40907. constructor(scene: Scene);
  40908. /**
  40909. * Registers the component in a given scene
  40910. */
  40911. register(): void;
  40912. /**
  40913. * Rebuilds the elements related to this component in case of
  40914. * context lost for instance.
  40915. */
  40916. rebuild(): void;
  40917. /**
  40918. * Disposes the component and the associated ressources
  40919. */
  40920. dispose(): void;
  40921. private _beforeCameraUpdate;
  40922. }
  40923. }
  40924. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40925. import { Observable } from "babylonjs/Misc/observable";
  40926. import { Nullable } from "babylonjs/types";
  40927. import { Camera } from "babylonjs/Cameras/camera";
  40928. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40929. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40930. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40931. import { Scene } from "babylonjs/scene";
  40932. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40933. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40935. import { Mesh } from "babylonjs/Meshes/mesh";
  40936. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40937. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40938. import "babylonjs/Meshes/Builders/groundBuilder";
  40939. import "babylonjs/Meshes/Builders/torusBuilder";
  40940. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40941. import "babylonjs/Gamepads/gamepadSceneComponent";
  40942. import "babylonjs/Animations/animatable";
  40943. /**
  40944. * Options to modify the vr teleportation behavior.
  40945. */
  40946. export interface VRTeleportationOptions {
  40947. /**
  40948. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40949. */
  40950. floorMeshName?: string;
  40951. /**
  40952. * A list of meshes to be used as the teleportation floor. (default: empty)
  40953. */
  40954. floorMeshes?: Mesh[];
  40955. }
  40956. /**
  40957. * Options to modify the vr experience helper's behavior.
  40958. */
  40959. export interface VRExperienceHelperOptions extends WebVROptions {
  40960. /**
  40961. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40962. */
  40963. createDeviceOrientationCamera?: boolean;
  40964. /**
  40965. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40966. */
  40967. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40968. /**
  40969. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40970. */
  40971. laserToggle?: boolean;
  40972. /**
  40973. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40974. */
  40975. floorMeshes?: Mesh[];
  40976. /**
  40977. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40978. */
  40979. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40980. }
  40981. /**
  40982. * Event containing information after VR has been entered
  40983. */
  40984. export class OnAfterEnteringVRObservableEvent {
  40985. /**
  40986. * If entering vr was successful
  40987. */
  40988. success: boolean;
  40989. }
  40990. /**
  40991. * Helps to quickly add VR support to an existing scene.
  40992. * See http://doc.babylonjs.com/how_to/webvr_helper
  40993. */
  40994. export class VRExperienceHelper {
  40995. /** Options to modify the vr experience helper's behavior. */
  40996. webVROptions: VRExperienceHelperOptions;
  40997. private _scene;
  40998. private _position;
  40999. private _btnVR;
  41000. private _btnVRDisplayed;
  41001. private _webVRsupported;
  41002. private _webVRready;
  41003. private _webVRrequesting;
  41004. private _webVRpresenting;
  41005. private _hasEnteredVR;
  41006. private _fullscreenVRpresenting;
  41007. private _canvas;
  41008. private _webVRCamera;
  41009. private _vrDeviceOrientationCamera;
  41010. private _deviceOrientationCamera;
  41011. private _existingCamera;
  41012. private _onKeyDown;
  41013. private _onVrDisplayPresentChange;
  41014. private _onVRDisplayChanged;
  41015. private _onVRRequestPresentStart;
  41016. private _onVRRequestPresentComplete;
  41017. /**
  41018. * Observable raised right before entering VR.
  41019. */
  41020. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41021. /**
  41022. * Observable raised when entering VR has completed.
  41023. */
  41024. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41025. /**
  41026. * Observable raised when exiting VR.
  41027. */
  41028. onExitingVRObservable: Observable<VRExperienceHelper>;
  41029. /**
  41030. * Observable raised when controller mesh is loaded.
  41031. */
  41032. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41033. /** Return this.onEnteringVRObservable
  41034. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41035. */
  41036. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41037. /** Return this.onExitingVRObservable
  41038. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41039. */
  41040. readonly onExitingVR: Observable<VRExperienceHelper>;
  41041. /** Return this.onControllerMeshLoadedObservable
  41042. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41043. */
  41044. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41045. private _rayLength;
  41046. private _useCustomVRButton;
  41047. private _teleportationRequested;
  41048. private _teleportActive;
  41049. private _floorMeshName;
  41050. private _floorMeshesCollection;
  41051. private _rotationAllowed;
  41052. private _teleportBackwardsVector;
  41053. private _teleportationTarget;
  41054. private _isDefaultTeleportationTarget;
  41055. private _postProcessMove;
  41056. private _teleportationFillColor;
  41057. private _teleportationBorderColor;
  41058. private _rotationAngle;
  41059. private _haloCenter;
  41060. private _cameraGazer;
  41061. private _padSensibilityUp;
  41062. private _padSensibilityDown;
  41063. private _leftController;
  41064. private _rightController;
  41065. /**
  41066. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41067. */
  41068. onNewMeshSelected: Observable<AbstractMesh>;
  41069. /**
  41070. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41071. */
  41072. onNewMeshPicked: Observable<PickingInfo>;
  41073. private _circleEase;
  41074. /**
  41075. * Observable raised before camera teleportation
  41076. */
  41077. onBeforeCameraTeleport: Observable<Vector3>;
  41078. /**
  41079. * Observable raised after camera teleportation
  41080. */
  41081. onAfterCameraTeleport: Observable<Vector3>;
  41082. /**
  41083. * Observable raised when current selected mesh gets unselected
  41084. */
  41085. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41086. private _raySelectionPredicate;
  41087. /**
  41088. * To be optionaly changed by user to define custom ray selection
  41089. */
  41090. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41091. /**
  41092. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41093. */
  41094. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41095. /**
  41096. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41097. */
  41098. teleportationEnabled: boolean;
  41099. private _defaultHeight;
  41100. private _teleportationInitialized;
  41101. private _interactionsEnabled;
  41102. private _interactionsRequested;
  41103. private _displayGaze;
  41104. private _displayLaserPointer;
  41105. /**
  41106. * The mesh used to display where the user is going to teleport.
  41107. */
  41108. /**
  41109. * Sets the mesh to be used to display where the user is going to teleport.
  41110. */
  41111. teleportationTarget: Mesh;
  41112. /**
  41113. * 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
  41114. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41115. * See http://doc.babylonjs.com/resources/baking_transformations
  41116. */
  41117. gazeTrackerMesh: Mesh;
  41118. /**
  41119. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41120. */
  41121. updateGazeTrackerScale: boolean;
  41122. /**
  41123. * If the gaze trackers color should be updated when selecting meshes
  41124. */
  41125. updateGazeTrackerColor: boolean;
  41126. /**
  41127. * The gaze tracking mesh corresponding to the left controller
  41128. */
  41129. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41130. /**
  41131. * The gaze tracking mesh corresponding to the right controller
  41132. */
  41133. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41134. /**
  41135. * If the ray of the gaze should be displayed.
  41136. */
  41137. /**
  41138. * Sets if the ray of the gaze should be displayed.
  41139. */
  41140. displayGaze: boolean;
  41141. /**
  41142. * If the ray of the LaserPointer should be displayed.
  41143. */
  41144. /**
  41145. * Sets if the ray of the LaserPointer should be displayed.
  41146. */
  41147. displayLaserPointer: boolean;
  41148. /**
  41149. * The deviceOrientationCamera used as the camera when not in VR.
  41150. */
  41151. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41152. /**
  41153. * Based on the current WebVR support, returns the current VR camera used.
  41154. */
  41155. readonly currentVRCamera: Nullable<Camera>;
  41156. /**
  41157. * The webVRCamera which is used when in VR.
  41158. */
  41159. readonly webVRCamera: WebVRFreeCamera;
  41160. /**
  41161. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41162. */
  41163. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41164. private readonly _teleportationRequestInitiated;
  41165. /**
  41166. * Defines wether or not Pointer lock should be requested when switching to
  41167. * full screen.
  41168. */
  41169. requestPointerLockOnFullScreen: boolean;
  41170. /**
  41171. * Instantiates a VRExperienceHelper.
  41172. * Helps to quickly add VR support to an existing scene.
  41173. * @param scene The scene the VRExperienceHelper belongs to.
  41174. * @param webVROptions Options to modify the vr experience helper's behavior.
  41175. */
  41176. constructor(scene: Scene,
  41177. /** Options to modify the vr experience helper's behavior. */
  41178. webVROptions?: VRExperienceHelperOptions);
  41179. private _onDefaultMeshLoaded;
  41180. private _onResize;
  41181. private _onFullscreenChange;
  41182. /**
  41183. * Gets a value indicating if we are currently in VR mode.
  41184. */
  41185. readonly isInVRMode: boolean;
  41186. private onVrDisplayPresentChange;
  41187. private onVRDisplayChanged;
  41188. private moveButtonToBottomRight;
  41189. private displayVRButton;
  41190. private updateButtonVisibility;
  41191. private _cachedAngularSensibility;
  41192. /**
  41193. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41194. * Otherwise, will use the fullscreen API.
  41195. */
  41196. enterVR(): void;
  41197. /**
  41198. * Attempt to exit VR, or fullscreen.
  41199. */
  41200. exitVR(): void;
  41201. /**
  41202. * The position of the vr experience helper.
  41203. */
  41204. /**
  41205. * Sets the position of the vr experience helper.
  41206. */
  41207. position: Vector3;
  41208. /**
  41209. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41210. */
  41211. enableInteractions(): void;
  41212. private readonly _noControllerIsActive;
  41213. private beforeRender;
  41214. private _isTeleportationFloor;
  41215. /**
  41216. * Adds a floor mesh to be used for teleportation.
  41217. * @param floorMesh the mesh to be used for teleportation.
  41218. */
  41219. addFloorMesh(floorMesh: Mesh): void;
  41220. /**
  41221. * Removes a floor mesh from being used for teleportation.
  41222. * @param floorMesh the mesh to be removed.
  41223. */
  41224. removeFloorMesh(floorMesh: Mesh): void;
  41225. /**
  41226. * Enables interactions and teleportation using the VR controllers and gaze.
  41227. * @param vrTeleportationOptions options to modify teleportation behavior.
  41228. */
  41229. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41230. private _onNewGamepadConnected;
  41231. private _tryEnableInteractionOnController;
  41232. private _onNewGamepadDisconnected;
  41233. private _enableInteractionOnController;
  41234. private _checkTeleportWithRay;
  41235. private _checkRotate;
  41236. private _checkTeleportBackwards;
  41237. private _enableTeleportationOnController;
  41238. private _createTeleportationCircles;
  41239. private _displayTeleportationTarget;
  41240. private _hideTeleportationTarget;
  41241. private _rotateCamera;
  41242. private _moveTeleportationSelectorTo;
  41243. private _workingVector;
  41244. private _workingQuaternion;
  41245. private _workingMatrix;
  41246. /**
  41247. * Teleports the users feet to the desired location
  41248. * @param location The location where the user's feet should be placed
  41249. */
  41250. teleportCamera(location: Vector3): void;
  41251. private _convertNormalToDirectionOfRay;
  41252. private _castRayAndSelectObject;
  41253. private _notifySelectedMeshUnselected;
  41254. /**
  41255. * Sets the color of the laser ray from the vr controllers.
  41256. * @param color new color for the ray.
  41257. */
  41258. changeLaserColor(color: Color3): void;
  41259. /**
  41260. * Sets the color of the ray from the vr headsets gaze.
  41261. * @param color new color for the ray.
  41262. */
  41263. changeGazeColor(color: Color3): void;
  41264. /**
  41265. * Exits VR and disposes of the vr experience helper
  41266. */
  41267. dispose(): void;
  41268. /**
  41269. * Gets the name of the VRExperienceHelper class
  41270. * @returns "VRExperienceHelper"
  41271. */
  41272. getClassName(): string;
  41273. }
  41274. }
  41275. declare module "babylonjs/Cameras/VR/index" {
  41276. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41277. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41278. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41279. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41280. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41281. export * from "babylonjs/Cameras/VR/webVRCamera";
  41282. }
  41283. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41284. import { Observable } from "babylonjs/Misc/observable";
  41285. import { Nullable } from "babylonjs/types";
  41286. import { IDisposable, Scene } from "babylonjs/scene";
  41287. import { Vector3 } from "babylonjs/Maths/math";
  41288. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41289. import { Ray } from "babylonjs/Culling/ray";
  41290. /**
  41291. * Manages an XRSession
  41292. * @see https://doc.babylonjs.com/how_to/webxr
  41293. */
  41294. export class WebXRSessionManager implements IDisposable {
  41295. private scene;
  41296. /**
  41297. * Fires every time a new xrFrame arrives which can be used to update the camera
  41298. */
  41299. onXRFrameObservable: Observable<any>;
  41300. /**
  41301. * Fires when the xr session is ended either by the device or manually done
  41302. */
  41303. onXRSessionEnded: Observable<any>;
  41304. /** @hidden */
  41305. _xrSession: XRSession;
  41306. /** @hidden */
  41307. _frameOfReference: XRFrameOfReference;
  41308. /** @hidden */
  41309. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41310. /** @hidden */
  41311. _currentXRFrame: Nullable<XRFrame>;
  41312. private _xrNavigator;
  41313. private _xrDevice;
  41314. private _tmpMatrix;
  41315. /**
  41316. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41317. * @param scene The scene which the session should be created for
  41318. */
  41319. constructor(scene: Scene);
  41320. /**
  41321. * Initializes the manager
  41322. * After initialization enterXR can be called to start an XR session
  41323. * @returns Promise which resolves after it is initialized
  41324. */
  41325. initializeAsync(): Promise<void>;
  41326. /**
  41327. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41328. * @param sessionCreationOptions xr options to create the session with
  41329. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41330. * @returns Promise which resolves after it enters XR
  41331. */
  41332. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41333. /**
  41334. * Stops the xrSession and restores the renderloop
  41335. * @returns Promise which resolves after it exits XR
  41336. */
  41337. exitXRAsync(): Promise<void>;
  41338. /**
  41339. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41340. * @param ray ray to cast into the environment
  41341. * @returns Promise which resolves with a collision point in the environment if it exists
  41342. */
  41343. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41344. /**
  41345. * Checks if a session would be supported for the creation options specified
  41346. * @param options creation options to check if they are supported
  41347. * @returns true if supported
  41348. */
  41349. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41350. /**
  41351. * @hidden
  41352. * Converts the render layer of xrSession to a render target
  41353. * @param session session to create render target for
  41354. * @param scene scene the new render target should be created for
  41355. */
  41356. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41357. /**
  41358. * Disposes of the session manager
  41359. */
  41360. dispose(): void;
  41361. }
  41362. }
  41363. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41364. import { Scene } from "babylonjs/scene";
  41365. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41366. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41367. /**
  41368. * WebXR Camera which holds the views for the xrSession
  41369. * @see https://doc.babylonjs.com/how_to/webxr
  41370. */
  41371. export class WebXRCamera extends FreeCamera {
  41372. private static _TmpMatrix;
  41373. /**
  41374. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41375. * @param name the name of the camera
  41376. * @param scene the scene to add the camera to
  41377. */
  41378. constructor(name: string, scene: Scene);
  41379. private _updateNumberOfRigCameras;
  41380. /** @hidden */
  41381. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41382. /**
  41383. * Updates the cameras position from the current pose information of the XR session
  41384. * @param xrSessionManager the session containing pose information
  41385. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41386. */
  41387. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41388. }
  41389. }
  41390. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41391. import { Nullable } from "babylonjs/types";
  41392. import { Observable } from "babylonjs/Misc/observable";
  41393. import { IDisposable, Scene } from "babylonjs/scene";
  41394. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41396. import { Ray } from "babylonjs/Culling/ray";
  41397. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41398. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41399. /**
  41400. * States of the webXR experience
  41401. */
  41402. export enum WebXRState {
  41403. /**
  41404. * Transitioning to being in XR mode
  41405. */
  41406. ENTERING_XR = 0,
  41407. /**
  41408. * Transitioning to non XR mode
  41409. */
  41410. EXITING_XR = 1,
  41411. /**
  41412. * In XR mode and presenting
  41413. */
  41414. IN_XR = 2,
  41415. /**
  41416. * Not entered XR mode
  41417. */
  41418. NOT_IN_XR = 3
  41419. }
  41420. /**
  41421. * Helper class used to enable XR
  41422. * @see https://doc.babylonjs.com/how_to/webxr
  41423. */
  41424. export class WebXRExperienceHelper implements IDisposable {
  41425. private scene;
  41426. /**
  41427. * 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
  41428. */
  41429. container: AbstractMesh;
  41430. /**
  41431. * Camera used to render xr content
  41432. */
  41433. camera: WebXRCamera;
  41434. /**
  41435. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41436. */
  41437. state: WebXRState;
  41438. private _setState;
  41439. private static _TmpVector;
  41440. /**
  41441. * Fires when the state of the experience helper has changed
  41442. */
  41443. onStateChangedObservable: Observable<WebXRState>;
  41444. /** @hidden */
  41445. _sessionManager: WebXRSessionManager;
  41446. private _nonVRCamera;
  41447. private _originalSceneAutoClear;
  41448. private _supported;
  41449. /**
  41450. * Creates the experience helper
  41451. * @param scene the scene to attach the experience helper to
  41452. * @returns a promise for the experience helper
  41453. */
  41454. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41455. /**
  41456. * Creates a WebXRExperienceHelper
  41457. * @param scene The scene the helper should be created in
  41458. */
  41459. private constructor();
  41460. /**
  41461. * Exits XR mode and returns the scene to its original state
  41462. * @returns promise that resolves after xr mode has exited
  41463. */
  41464. exitXRAsync(): Promise<void>;
  41465. /**
  41466. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41467. * @param sessionCreationOptions options for the XR session
  41468. * @param frameOfReference frame of reference of the XR session
  41469. * @returns promise that resolves after xr mode has entered
  41470. */
  41471. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41472. /**
  41473. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41474. * @param ray ray to cast into the environment
  41475. * @returns Promise which resolves with a collision point in the environment if it exists
  41476. */
  41477. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41478. /**
  41479. * Updates the global position of the camera by moving the camera's container
  41480. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41481. * @param position The desired global position of the camera
  41482. */
  41483. setPositionOfCameraUsingContainer(position: Vector3): void;
  41484. /**
  41485. * Rotates the xr camera by rotating the camera's container around the camera's position
  41486. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41487. * @param rotation the desired quaternion rotation to apply to the camera
  41488. */
  41489. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41490. /**
  41491. * Checks if the creation options are supported by the xr session
  41492. * @param options creation options
  41493. * @returns true if supported
  41494. */
  41495. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41496. /**
  41497. * Disposes of the experience helper
  41498. */
  41499. dispose(): void;
  41500. }
  41501. }
  41502. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41503. import { Nullable } from "babylonjs/types";
  41504. import { Observable } from "babylonjs/Misc/observable";
  41505. import { IDisposable, Scene } from "babylonjs/scene";
  41506. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41507. /**
  41508. * Button which can be used to enter a different mode of XR
  41509. */
  41510. export class WebXREnterExitUIButton {
  41511. /** button element */
  41512. element: HTMLElement;
  41513. /** XR initialization options for the button */
  41514. initializationOptions: XRSessionCreationOptions;
  41515. /**
  41516. * Creates a WebXREnterExitUIButton
  41517. * @param element button element
  41518. * @param initializationOptions XR initialization options for the button
  41519. */
  41520. constructor(
  41521. /** button element */
  41522. element: HTMLElement,
  41523. /** XR initialization options for the button */
  41524. initializationOptions: XRSessionCreationOptions);
  41525. /**
  41526. * Overwritable function which can be used to update the button's visuals when the state changes
  41527. * @param activeButton the current active button in the UI
  41528. */
  41529. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41530. }
  41531. /**
  41532. * Options to create the webXR UI
  41533. */
  41534. export class WebXREnterExitUIOptions {
  41535. /**
  41536. * Context to enter xr with
  41537. */
  41538. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41539. /**
  41540. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41541. */
  41542. customButtons?: Array<WebXREnterExitUIButton>;
  41543. }
  41544. /**
  41545. * UI to allow the user to enter/exit XR mode
  41546. */
  41547. export class WebXREnterExitUI implements IDisposable {
  41548. private scene;
  41549. private _overlay;
  41550. private _buttons;
  41551. private _activeButton;
  41552. /**
  41553. * Fired every time the active button is changed.
  41554. *
  41555. * When xr is entered via a button that launches xr that button will be the callback parameter
  41556. *
  41557. * When exiting xr the callback parameter will be null)
  41558. */
  41559. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41560. /**
  41561. * Creates UI to allow the user to enter/exit XR mode
  41562. * @param scene the scene to add the ui to
  41563. * @param helper the xr experience helper to enter/exit xr with
  41564. * @param options options to configure the UI
  41565. * @returns the created ui
  41566. */
  41567. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41568. private constructor();
  41569. private _updateButtons;
  41570. /**
  41571. * Disposes of the object
  41572. */
  41573. dispose(): void;
  41574. }
  41575. }
  41576. declare module "babylonjs/Cameras/XR/webXRInput" {
  41577. import { IDisposable, Scene } from "babylonjs/scene";
  41578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41579. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41580. /**
  41581. * Represents an XR input
  41582. */
  41583. export class WebXRController {
  41584. /**
  41585. * 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
  41586. */
  41587. grip?: AbstractMesh;
  41588. /**
  41589. * Pointer which can be used to select objects or attach a visible laser to
  41590. */
  41591. pointer: AbstractMesh;
  41592. /**
  41593. * Creates the controller
  41594. * @see https://doc.babylonjs.com/how_to/webxr
  41595. * @param scene the scene which the controller should be associated to
  41596. */
  41597. constructor(scene: Scene);
  41598. /**
  41599. * Disposes of the object
  41600. */
  41601. dispose(): void;
  41602. }
  41603. /**
  41604. * XR input used to track XR inputs such as controllers/rays
  41605. */
  41606. export class WebXRInput implements IDisposable {
  41607. private helper;
  41608. /**
  41609. * XR controllers being tracked
  41610. */
  41611. controllers: Array<WebXRController>;
  41612. private _tmpMatrix;
  41613. private _frameObserver;
  41614. /**
  41615. * Initializes the WebXRInput
  41616. * @param helper experience helper which the input should be created for
  41617. */
  41618. constructor(helper: WebXRExperienceHelper);
  41619. /**
  41620. * Disposes of the object
  41621. */
  41622. dispose(): void;
  41623. }
  41624. }
  41625. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41626. import { Nullable } from "babylonjs/types";
  41627. import { IDisposable } from "babylonjs/scene";
  41628. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41629. /**
  41630. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41631. */
  41632. export class WebXRManagedOutputCanvas implements IDisposable {
  41633. private _canvas;
  41634. /**
  41635. * xrpresent context of the canvas which can be used to display/mirror xr content
  41636. */
  41637. canvasContext: Nullable<WebGLRenderingContext>;
  41638. /**
  41639. * Initializes the canvas to be added/removed upon entering/exiting xr
  41640. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41641. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41642. */
  41643. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41644. /**
  41645. * Disposes of the object
  41646. */
  41647. dispose(): void;
  41648. private _setManagedOutputCanvas;
  41649. private _addCanvas;
  41650. private _removeCanvas;
  41651. }
  41652. }
  41653. declare module "babylonjs/Cameras/XR/index" {
  41654. export * from "babylonjs/Cameras/XR/webXRCamera";
  41655. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41656. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41657. export * from "babylonjs/Cameras/XR/webXRInput";
  41658. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41659. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41660. }
  41661. declare module "babylonjs/Cameras/RigModes/index" {
  41662. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41663. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41664. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41665. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41666. }
  41667. declare module "babylonjs/Cameras/index" {
  41668. export * from "babylonjs/Cameras/Inputs/index";
  41669. export * from "babylonjs/Cameras/cameraInputsManager";
  41670. export * from "babylonjs/Cameras/camera";
  41671. export * from "babylonjs/Cameras/targetCamera";
  41672. export * from "babylonjs/Cameras/freeCamera";
  41673. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41674. export * from "babylonjs/Cameras/touchCamera";
  41675. export * from "babylonjs/Cameras/arcRotateCamera";
  41676. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41677. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41678. export * from "babylonjs/Cameras/flyCamera";
  41679. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41680. export * from "babylonjs/Cameras/followCamera";
  41681. export * from "babylonjs/Cameras/gamepadCamera";
  41682. export * from "babylonjs/Cameras/Stereoscopic/index";
  41683. export * from "babylonjs/Cameras/universalCamera";
  41684. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41685. export * from "babylonjs/Cameras/VR/index";
  41686. export * from "babylonjs/Cameras/XR/index";
  41687. export * from "babylonjs/Cameras/RigModes/index";
  41688. }
  41689. declare module "babylonjs/Collisions/index" {
  41690. export * from "babylonjs/Collisions/collider";
  41691. export * from "babylonjs/Collisions/collisionCoordinator";
  41692. export * from "babylonjs/Collisions/pickingInfo";
  41693. export * from "babylonjs/Collisions/intersectionInfo";
  41694. }
  41695. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41696. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41697. import { Vector3, Plane } from "babylonjs/Maths/math";
  41698. import { Ray } from "babylonjs/Culling/ray";
  41699. /**
  41700. * Contains an array of blocks representing the octree
  41701. */
  41702. export interface IOctreeContainer<T> {
  41703. /**
  41704. * Blocks within the octree
  41705. */
  41706. blocks: Array<OctreeBlock<T>>;
  41707. }
  41708. /**
  41709. * Class used to store a cell in an octree
  41710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41711. */
  41712. export class OctreeBlock<T> {
  41713. /**
  41714. * Gets the content of the current block
  41715. */
  41716. entries: T[];
  41717. /**
  41718. * Gets the list of block children
  41719. */
  41720. blocks: Array<OctreeBlock<T>>;
  41721. private _depth;
  41722. private _maxDepth;
  41723. private _capacity;
  41724. private _minPoint;
  41725. private _maxPoint;
  41726. private _boundingVectors;
  41727. private _creationFunc;
  41728. /**
  41729. * Creates a new block
  41730. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41731. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41732. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41733. * @param depth defines the current depth of this block in the octree
  41734. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41735. * @param creationFunc defines a callback to call when an element is added to the block
  41736. */
  41737. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41738. /**
  41739. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41740. */
  41741. readonly capacity: number;
  41742. /**
  41743. * Gets the minimum vector (in world space) of the block's bounding box
  41744. */
  41745. readonly minPoint: Vector3;
  41746. /**
  41747. * Gets the maximum vector (in world space) of the block's bounding box
  41748. */
  41749. readonly maxPoint: Vector3;
  41750. /**
  41751. * Add a new element to this block
  41752. * @param entry defines the element to add
  41753. */
  41754. addEntry(entry: T): void;
  41755. /**
  41756. * Remove an element from this block
  41757. * @param entry defines the element to remove
  41758. */
  41759. removeEntry(entry: T): void;
  41760. /**
  41761. * Add an array of elements to this block
  41762. * @param entries defines the array of elements to add
  41763. */
  41764. addEntries(entries: T[]): void;
  41765. /**
  41766. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41767. * @param frustumPlanes defines the frustum planes to test
  41768. * @param selection defines the array to store current content if selection is positive
  41769. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41770. */
  41771. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41772. /**
  41773. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41774. * @param sphereCenter defines the bounding sphere center
  41775. * @param sphereRadius defines the bounding sphere radius
  41776. * @param selection defines the array to store current content if selection is positive
  41777. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41778. */
  41779. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41780. /**
  41781. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41782. * @param ray defines the ray to test with
  41783. * @param selection defines the array to store current content if selection is positive
  41784. */
  41785. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41786. /**
  41787. * Subdivide the content into child blocks (this block will then be empty)
  41788. */
  41789. createInnerBlocks(): void;
  41790. /**
  41791. * @hidden
  41792. */
  41793. 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;
  41794. }
  41795. }
  41796. declare module "babylonjs/Culling/Octrees/octree" {
  41797. import { SmartArray } from "babylonjs/Misc/smartArray";
  41798. import { Vector3, Plane } from "babylonjs/Maths/math";
  41799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41801. import { Ray } from "babylonjs/Culling/ray";
  41802. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41803. /**
  41804. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41805. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41806. */
  41807. export class Octree<T> {
  41808. /** 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.) */
  41809. maxDepth: number;
  41810. /**
  41811. * Blocks within the octree containing objects
  41812. */
  41813. blocks: Array<OctreeBlock<T>>;
  41814. /**
  41815. * Content stored in the octree
  41816. */
  41817. dynamicContent: T[];
  41818. private _maxBlockCapacity;
  41819. private _selectionContent;
  41820. private _creationFunc;
  41821. /**
  41822. * Creates a octree
  41823. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41824. * @param creationFunc function to be used to instatiate the octree
  41825. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41826. * @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.)
  41827. */
  41828. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41829. /** 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.) */
  41830. maxDepth?: number);
  41831. /**
  41832. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41833. * @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);
  41834. * @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);
  41835. * @param entries meshes to be added to the octree blocks
  41836. */
  41837. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41838. /**
  41839. * Adds a mesh to the octree
  41840. * @param entry Mesh to add to the octree
  41841. */
  41842. addMesh(entry: T): void;
  41843. /**
  41844. * Remove an element from the octree
  41845. * @param entry defines the element to remove
  41846. */
  41847. removeMesh(entry: T): void;
  41848. /**
  41849. * Selects an array of meshes within the frustum
  41850. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41851. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41852. * @returns array of meshes within the frustum
  41853. */
  41854. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41855. /**
  41856. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41857. * @param sphereCenter defines the bounding sphere center
  41858. * @param sphereRadius defines the bounding sphere radius
  41859. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41860. * @returns an array of objects that intersect the sphere
  41861. */
  41862. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41863. /**
  41864. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41865. * @param ray defines the ray to test with
  41866. * @returns array of intersected objects
  41867. */
  41868. intersectsRay(ray: Ray): SmartArray<T>;
  41869. /**
  41870. * Adds a mesh into the octree block if it intersects the block
  41871. */
  41872. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41873. /**
  41874. * Adds a submesh into the octree block if it intersects the block
  41875. */
  41876. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41877. }
  41878. }
  41879. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41880. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41881. import { Scene } from "babylonjs/scene";
  41882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41884. import { Ray } from "babylonjs/Culling/ray";
  41885. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41886. import { Collider } from "babylonjs/Collisions/collider";
  41887. module "babylonjs/scene" {
  41888. interface Scene {
  41889. /**
  41890. * @hidden
  41891. * Backing Filed
  41892. */
  41893. _selectionOctree: Octree<AbstractMesh>;
  41894. /**
  41895. * Gets the octree used to boost mesh selection (picking)
  41896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41897. */
  41898. selectionOctree: Octree<AbstractMesh>;
  41899. /**
  41900. * Creates or updates the octree used to boost selection (picking)
  41901. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41902. * @param maxCapacity defines the maximum capacity per leaf
  41903. * @param maxDepth defines the maximum depth of the octree
  41904. * @returns an octree of AbstractMesh
  41905. */
  41906. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41907. }
  41908. }
  41909. module "babylonjs/Meshes/abstractMesh" {
  41910. interface AbstractMesh {
  41911. /**
  41912. * @hidden
  41913. * Backing Field
  41914. */
  41915. _submeshesOctree: Octree<SubMesh>;
  41916. /**
  41917. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41918. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41919. * @param maxCapacity defines the maximum size of each block (64 by default)
  41920. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41921. * @returns the new octree
  41922. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41923. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41924. */
  41925. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41926. }
  41927. }
  41928. /**
  41929. * Defines the octree scene component responsible to manage any octrees
  41930. * in a given scene.
  41931. */
  41932. export class OctreeSceneComponent {
  41933. /**
  41934. * The component name help to identify the component in the list of scene components.
  41935. */
  41936. readonly name: string;
  41937. /**
  41938. * The scene the component belongs to.
  41939. */
  41940. scene: Scene;
  41941. /**
  41942. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41943. */
  41944. readonly checksIsEnabled: boolean;
  41945. /**
  41946. * Creates a new instance of the component for the given scene
  41947. * @param scene Defines the scene to register the component in
  41948. */
  41949. constructor(scene: Scene);
  41950. /**
  41951. * Registers the component in a given scene
  41952. */
  41953. register(): void;
  41954. /**
  41955. * Return the list of active meshes
  41956. * @returns the list of active meshes
  41957. */
  41958. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41959. /**
  41960. * Return the list of active sub meshes
  41961. * @param mesh The mesh to get the candidates sub meshes from
  41962. * @returns the list of active sub meshes
  41963. */
  41964. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41965. private _tempRay;
  41966. /**
  41967. * Return the list of sub meshes intersecting with a given local ray
  41968. * @param mesh defines the mesh to find the submesh for
  41969. * @param localRay defines the ray in local space
  41970. * @returns the list of intersecting sub meshes
  41971. */
  41972. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41973. /**
  41974. * Return the list of sub meshes colliding with a collider
  41975. * @param mesh defines the mesh to find the submesh for
  41976. * @param collider defines the collider to evaluate the collision against
  41977. * @returns the list of colliding sub meshes
  41978. */
  41979. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41980. /**
  41981. * Rebuilds the elements related to this component in case of
  41982. * context lost for instance.
  41983. */
  41984. rebuild(): void;
  41985. /**
  41986. * Disposes the component and the associated ressources.
  41987. */
  41988. dispose(): void;
  41989. }
  41990. }
  41991. declare module "babylonjs/Culling/Octrees/index" {
  41992. export * from "babylonjs/Culling/Octrees/octree";
  41993. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41994. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41995. }
  41996. declare module "babylonjs/Culling/index" {
  41997. export * from "babylonjs/Culling/boundingBox";
  41998. export * from "babylonjs/Culling/boundingInfo";
  41999. export * from "babylonjs/Culling/boundingSphere";
  42000. export * from "babylonjs/Culling/Octrees/index";
  42001. export * from "babylonjs/Culling/ray";
  42002. }
  42003. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42004. import { IDisposable, Scene } from "babylonjs/scene";
  42005. import { Nullable } from "babylonjs/types";
  42006. import { Observable } from "babylonjs/Misc/observable";
  42007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42008. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42009. /**
  42010. * Renders a layer on top of an existing scene
  42011. */
  42012. export class UtilityLayerRenderer implements IDisposable {
  42013. /** the original scene that will be rendered on top of */
  42014. originalScene: Scene;
  42015. private _pointerCaptures;
  42016. private _lastPointerEvents;
  42017. private static _DefaultUtilityLayer;
  42018. private static _DefaultKeepDepthUtilityLayer;
  42019. private _sharedGizmoLight;
  42020. /**
  42021. * @hidden
  42022. * Light which used by gizmos to get light shading
  42023. */
  42024. _getSharedGizmoLight(): HemisphericLight;
  42025. /**
  42026. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42027. */
  42028. pickUtilitySceneFirst: boolean;
  42029. /**
  42030. * 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)
  42031. */
  42032. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42033. /**
  42034. * 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)
  42035. */
  42036. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42037. /**
  42038. * The scene that is rendered on top of the original scene
  42039. */
  42040. utilityLayerScene: Scene;
  42041. /**
  42042. * If the utility layer should automatically be rendered on top of existing scene
  42043. */
  42044. shouldRender: boolean;
  42045. /**
  42046. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42047. */
  42048. onlyCheckPointerDownEvents: boolean;
  42049. /**
  42050. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42051. */
  42052. processAllEvents: boolean;
  42053. /**
  42054. * Observable raised when the pointer move from the utility layer scene to the main scene
  42055. */
  42056. onPointerOutObservable: Observable<number>;
  42057. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42058. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42059. private _afterRenderObserver;
  42060. private _sceneDisposeObserver;
  42061. private _originalPointerObserver;
  42062. /**
  42063. * Instantiates a UtilityLayerRenderer
  42064. * @param originalScene the original scene that will be rendered on top of
  42065. * @param handleEvents boolean indicating if the utility layer should handle events
  42066. */
  42067. constructor(
  42068. /** the original scene that will be rendered on top of */
  42069. originalScene: Scene, handleEvents?: boolean);
  42070. private _notifyObservers;
  42071. /**
  42072. * Renders the utility layers scene on top of the original scene
  42073. */
  42074. render(): void;
  42075. /**
  42076. * Disposes of the renderer
  42077. */
  42078. dispose(): void;
  42079. private _updateCamera;
  42080. }
  42081. }
  42082. declare module "babylonjs/Gizmos/gizmo" {
  42083. import { Nullable } from "babylonjs/types";
  42084. import { IDisposable } from "babylonjs/scene";
  42085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42086. import { Mesh } from "babylonjs/Meshes/mesh";
  42087. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42088. /**
  42089. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42090. */
  42091. export class Gizmo implements IDisposable {
  42092. /** The utility layer the gizmo will be added to */
  42093. gizmoLayer: UtilityLayerRenderer;
  42094. /**
  42095. * The root mesh of the gizmo
  42096. */
  42097. _rootMesh: Mesh;
  42098. private _attachedMesh;
  42099. /**
  42100. * Ratio for the scale of the gizmo (Default: 1)
  42101. */
  42102. scaleRatio: number;
  42103. /**
  42104. * If a custom mesh has been set (Default: false)
  42105. */
  42106. protected _customMeshSet: boolean;
  42107. /**
  42108. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42109. * * When set, interactions will be enabled
  42110. */
  42111. attachedMesh: Nullable<AbstractMesh>;
  42112. /**
  42113. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42114. * @param mesh The mesh to replace the default mesh of the gizmo
  42115. */
  42116. setCustomMesh(mesh: Mesh): void;
  42117. /**
  42118. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42119. */
  42120. updateGizmoRotationToMatchAttachedMesh: boolean;
  42121. /**
  42122. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42123. */
  42124. updateGizmoPositionToMatchAttachedMesh: boolean;
  42125. /**
  42126. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42127. */
  42128. protected _updateScale: boolean;
  42129. protected _interactionsEnabled: boolean;
  42130. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42131. private _beforeRenderObserver;
  42132. private _tempVector;
  42133. /**
  42134. * Creates a gizmo
  42135. * @param gizmoLayer The utility layer the gizmo will be added to
  42136. */
  42137. constructor(
  42138. /** The utility layer the gizmo will be added to */
  42139. gizmoLayer?: UtilityLayerRenderer);
  42140. /**
  42141. * Updates the gizmo to match the attached mesh's position/rotation
  42142. */
  42143. protected _update(): void;
  42144. /**
  42145. * Disposes of the gizmo
  42146. */
  42147. dispose(): void;
  42148. }
  42149. }
  42150. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42151. import { Observable } from "babylonjs/Misc/observable";
  42152. import { Nullable } from "babylonjs/types";
  42153. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42154. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42156. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42157. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42158. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42159. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42160. import { Scene } from "babylonjs/scene";
  42161. /**
  42162. * Single axis drag gizmo
  42163. */
  42164. export class AxisDragGizmo extends Gizmo {
  42165. /**
  42166. * Drag behavior responsible for the gizmos dragging interactions
  42167. */
  42168. dragBehavior: PointerDragBehavior;
  42169. private _pointerObserver;
  42170. /**
  42171. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42172. */
  42173. snapDistance: number;
  42174. /**
  42175. * Event that fires each time the gizmo snaps to a new location.
  42176. * * snapDistance is the the change in distance
  42177. */
  42178. onSnapObservable: Observable<{
  42179. snapDistance: number;
  42180. }>;
  42181. /** @hidden */
  42182. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42183. /** @hidden */
  42184. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42185. /**
  42186. * Creates an AxisDragGizmo
  42187. * @param gizmoLayer The utility layer the gizmo will be added to
  42188. * @param dragAxis The axis which the gizmo will be able to drag on
  42189. * @param color The color of the gizmo
  42190. */
  42191. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42192. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42193. /**
  42194. * Disposes of the gizmo
  42195. */
  42196. dispose(): void;
  42197. }
  42198. }
  42199. declare module "babylonjs/Debug/axesViewer" {
  42200. import { Vector3 } from "babylonjs/Maths/math";
  42201. import { Nullable } from "babylonjs/types";
  42202. import { Scene } from "babylonjs/scene";
  42203. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42204. /**
  42205. * The Axes viewer will show 3 axes in a specific point in space
  42206. */
  42207. export class AxesViewer {
  42208. private _xAxis;
  42209. private _yAxis;
  42210. private _zAxis;
  42211. private _scaleLinesFactor;
  42212. private _instanced;
  42213. /**
  42214. * Gets the hosting scene
  42215. */
  42216. scene: Scene;
  42217. /**
  42218. * Gets or sets a number used to scale line length
  42219. */
  42220. scaleLines: number;
  42221. /** Gets the node hierarchy used to render x-axis */
  42222. readonly xAxis: TransformNode;
  42223. /** Gets the node hierarchy used to render y-axis */
  42224. readonly yAxis: TransformNode;
  42225. /** Gets the node hierarchy used to render z-axis */
  42226. readonly zAxis: TransformNode;
  42227. /**
  42228. * Creates a new AxesViewer
  42229. * @param scene defines the hosting scene
  42230. * @param scaleLines defines a number used to scale line length (1 by default)
  42231. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42232. * @param xAxis defines the node hierarchy used to render the x-axis
  42233. * @param yAxis defines the node hierarchy used to render the y-axis
  42234. * @param zAxis defines the node hierarchy used to render the z-axis
  42235. */
  42236. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42237. /**
  42238. * Force the viewer to update
  42239. * @param position defines the position of the viewer
  42240. * @param xaxis defines the x axis of the viewer
  42241. * @param yaxis defines the y axis of the viewer
  42242. * @param zaxis defines the z axis of the viewer
  42243. */
  42244. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42245. /**
  42246. * Creates an instance of this axes viewer.
  42247. * @returns a new axes viewer with instanced meshes
  42248. */
  42249. createInstance(): AxesViewer;
  42250. /** Releases resources */
  42251. dispose(): void;
  42252. private static _SetRenderingGroupId;
  42253. }
  42254. }
  42255. declare module "babylonjs/Debug/boneAxesViewer" {
  42256. import { Nullable } from "babylonjs/types";
  42257. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42258. import { Vector3 } from "babylonjs/Maths/math";
  42259. import { Mesh } from "babylonjs/Meshes/mesh";
  42260. import { Bone } from "babylonjs/Bones/bone";
  42261. import { Scene } from "babylonjs/scene";
  42262. /**
  42263. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42264. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42265. */
  42266. export class BoneAxesViewer extends AxesViewer {
  42267. /**
  42268. * Gets or sets the target mesh where to display the axes viewer
  42269. */
  42270. mesh: Nullable<Mesh>;
  42271. /**
  42272. * Gets or sets the target bone where to display the axes viewer
  42273. */
  42274. bone: Nullable<Bone>;
  42275. /** Gets current position */
  42276. pos: Vector3;
  42277. /** Gets direction of X axis */
  42278. xaxis: Vector3;
  42279. /** Gets direction of Y axis */
  42280. yaxis: Vector3;
  42281. /** Gets direction of Z axis */
  42282. zaxis: Vector3;
  42283. /**
  42284. * Creates a new BoneAxesViewer
  42285. * @param scene defines the hosting scene
  42286. * @param bone defines the target bone
  42287. * @param mesh defines the target mesh
  42288. * @param scaleLines defines a scaling factor for line length (1 by default)
  42289. */
  42290. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42291. /**
  42292. * Force the viewer to update
  42293. */
  42294. update(): void;
  42295. /** Releases resources */
  42296. dispose(): void;
  42297. }
  42298. }
  42299. declare module "babylonjs/Debug/debugLayer" {
  42300. import { Observable } from "babylonjs/Misc/observable";
  42301. import { Scene } from "babylonjs/scene";
  42302. /**
  42303. * Interface used to define scene explorer extensibility option
  42304. */
  42305. export interface IExplorerExtensibilityOption {
  42306. /**
  42307. * Define the option label
  42308. */
  42309. label: string;
  42310. /**
  42311. * Defines the action to execute on click
  42312. */
  42313. action: (entity: any) => void;
  42314. }
  42315. /**
  42316. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42317. */
  42318. export interface IExplorerExtensibilityGroup {
  42319. /**
  42320. * Defines a predicate to test if a given type mut be extended
  42321. */
  42322. predicate: (entity: any) => boolean;
  42323. /**
  42324. * Gets the list of options added to a type
  42325. */
  42326. entries: IExplorerExtensibilityOption[];
  42327. }
  42328. /**
  42329. * Interface used to define the options to use to create the Inspector
  42330. */
  42331. export interface IInspectorOptions {
  42332. /**
  42333. * Display in overlay mode (default: false)
  42334. */
  42335. overlay?: boolean;
  42336. /**
  42337. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42338. */
  42339. globalRoot?: HTMLElement;
  42340. /**
  42341. * Display the Scene explorer
  42342. */
  42343. showExplorer?: boolean;
  42344. /**
  42345. * Display the property inspector
  42346. */
  42347. showInspector?: boolean;
  42348. /**
  42349. * Display in embed mode (both panes on the right)
  42350. */
  42351. embedMode?: boolean;
  42352. /**
  42353. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42354. */
  42355. handleResize?: boolean;
  42356. /**
  42357. * Allow the panes to popup (default: true)
  42358. */
  42359. enablePopup?: boolean;
  42360. /**
  42361. * Allow the panes to be closed by users (default: true)
  42362. */
  42363. enableClose?: boolean;
  42364. /**
  42365. * Optional list of extensibility entries
  42366. */
  42367. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42368. /**
  42369. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42370. */
  42371. inspectorURL?: string;
  42372. }
  42373. module "babylonjs/scene" {
  42374. interface Scene {
  42375. /**
  42376. * @hidden
  42377. * Backing field
  42378. */
  42379. _debugLayer: DebugLayer;
  42380. /**
  42381. * Gets the debug layer (aka Inspector) associated with the scene
  42382. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42383. */
  42384. debugLayer: DebugLayer;
  42385. }
  42386. }
  42387. /**
  42388. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42389. * what is happening in your scene
  42390. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42391. */
  42392. export class DebugLayer {
  42393. /**
  42394. * Define the url to get the inspector script from.
  42395. * By default it uses the babylonjs CDN.
  42396. * @ignoreNaming
  42397. */
  42398. static InspectorURL: string;
  42399. private _scene;
  42400. private BJSINSPECTOR;
  42401. /**
  42402. * Observable triggered when a property is changed through the inspector.
  42403. */
  42404. onPropertyChangedObservable: Observable<{
  42405. object: any;
  42406. property: string;
  42407. value: any;
  42408. initialValue: any;
  42409. }>;
  42410. /**
  42411. * Instantiates a new debug layer.
  42412. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42413. * what is happening in your scene
  42414. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42415. * @param scene Defines the scene to inspect
  42416. */
  42417. constructor(scene: Scene);
  42418. /** Creates the inspector window. */
  42419. private _createInspector;
  42420. /**
  42421. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42422. * @param entity defines the entity to select
  42423. * @param lineContainerTitle defines the specific block to highlight
  42424. */
  42425. select(entity: any, lineContainerTitle?: string): void;
  42426. /** Get the inspector from bundle or global */
  42427. private _getGlobalInspector;
  42428. /**
  42429. * Get if the inspector is visible or not.
  42430. * @returns true if visible otherwise, false
  42431. */
  42432. isVisible(): boolean;
  42433. /**
  42434. * Hide the inspector and close its window.
  42435. */
  42436. hide(): void;
  42437. /**
  42438. * Launch the debugLayer.
  42439. * @param config Define the configuration of the inspector
  42440. * @return a promise fulfilled when the debug layer is visible
  42441. */
  42442. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42443. }
  42444. }
  42445. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42446. import { Nullable } from "babylonjs/types";
  42447. import { Scene } from "babylonjs/scene";
  42448. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42449. import { Mesh } from "babylonjs/Meshes/mesh";
  42450. /**
  42451. * Class containing static functions to help procedurally build meshes
  42452. */
  42453. export class BoxBuilder {
  42454. /**
  42455. * Creates a box mesh
  42456. * * The parameter `size` sets the size (float) of each box side (default 1)
  42457. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42458. * * 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)
  42459. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42463. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42464. * @param name defines the name of the mesh
  42465. * @param options defines the options used to create the mesh
  42466. * @param scene defines the hosting scene
  42467. * @returns the box mesh
  42468. */
  42469. static CreateBox(name: string, options: {
  42470. size?: number;
  42471. width?: number;
  42472. height?: number;
  42473. depth?: number;
  42474. faceUV?: Vector4[];
  42475. faceColors?: Color4[];
  42476. sideOrientation?: number;
  42477. frontUVs?: Vector4;
  42478. backUVs?: Vector4;
  42479. wrap?: boolean;
  42480. topBaseAt?: number;
  42481. bottomBaseAt?: number;
  42482. updatable?: boolean;
  42483. }, scene?: Nullable<Scene>): Mesh;
  42484. }
  42485. }
  42486. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42487. import { Vector4 } from "babylonjs/Maths/math";
  42488. import { Mesh } from "babylonjs/Meshes/mesh";
  42489. /**
  42490. * Class containing static functions to help procedurally build meshes
  42491. */
  42492. export class SphereBuilder {
  42493. /**
  42494. * Creates a sphere mesh
  42495. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42496. * * 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`)
  42497. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42498. * * 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
  42499. * * 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)
  42500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42503. * @param name defines the name of the mesh
  42504. * @param options defines the options used to create the mesh
  42505. * @param scene defines the hosting scene
  42506. * @returns the sphere mesh
  42507. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42508. */
  42509. static CreateSphere(name: string, options: {
  42510. segments?: number;
  42511. diameter?: number;
  42512. diameterX?: number;
  42513. diameterY?: number;
  42514. diameterZ?: number;
  42515. arc?: number;
  42516. slice?: number;
  42517. sideOrientation?: number;
  42518. frontUVs?: Vector4;
  42519. backUVs?: Vector4;
  42520. updatable?: boolean;
  42521. }, scene: any): Mesh;
  42522. }
  42523. }
  42524. declare module "babylonjs/Debug/physicsViewer" {
  42525. import { Nullable } from "babylonjs/types";
  42526. import { Scene } from "babylonjs/scene";
  42527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42528. import { Mesh } from "babylonjs/Meshes/mesh";
  42529. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42530. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42531. /**
  42532. * Used to show the physics impostor around the specific mesh
  42533. */
  42534. export class PhysicsViewer {
  42535. /** @hidden */
  42536. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42537. /** @hidden */
  42538. protected _meshes: Array<Nullable<AbstractMesh>>;
  42539. /** @hidden */
  42540. protected _scene: Nullable<Scene>;
  42541. /** @hidden */
  42542. protected _numMeshes: number;
  42543. /** @hidden */
  42544. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42545. private _renderFunction;
  42546. private _utilityLayer;
  42547. private _debugBoxMesh;
  42548. private _debugSphereMesh;
  42549. private _debugCylinderMesh;
  42550. private _debugMaterial;
  42551. private _debugMeshMeshes;
  42552. /**
  42553. * Creates a new PhysicsViewer
  42554. * @param scene defines the hosting scene
  42555. */
  42556. constructor(scene: Scene);
  42557. /** @hidden */
  42558. protected _updateDebugMeshes(): void;
  42559. /**
  42560. * Renders a specified physic impostor
  42561. * @param impostor defines the impostor to render
  42562. * @param targetMesh defines the mesh represented by the impostor
  42563. * @returns the new debug mesh used to render the impostor
  42564. */
  42565. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42566. /**
  42567. * Hides a specified physic impostor
  42568. * @param impostor defines the impostor to hide
  42569. */
  42570. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42571. private _getDebugMaterial;
  42572. private _getDebugBoxMesh;
  42573. private _getDebugSphereMesh;
  42574. private _getDebugCylinderMesh;
  42575. private _getDebugMeshMesh;
  42576. private _getDebugMesh;
  42577. /** Releases all resources */
  42578. dispose(): void;
  42579. }
  42580. }
  42581. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42582. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42583. import { Nullable } from "babylonjs/types";
  42584. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42585. import { Scene } from "babylonjs/scene";
  42586. /**
  42587. * Class containing static functions to help procedurally build meshes
  42588. */
  42589. export class LinesBuilder {
  42590. /**
  42591. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42592. * * 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
  42593. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42594. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42595. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42596. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42597. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42598. * * 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
  42599. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42602. * @param name defines the name of the new line system
  42603. * @param options defines the options used to create the line system
  42604. * @param scene defines the hosting scene
  42605. * @returns a new line system mesh
  42606. */
  42607. static CreateLineSystem(name: string, options: {
  42608. lines: Vector3[][];
  42609. updatable?: boolean;
  42610. instance?: Nullable<LinesMesh>;
  42611. colors?: Nullable<Color4[][]>;
  42612. useVertexAlpha?: boolean;
  42613. }, scene: Nullable<Scene>): LinesMesh;
  42614. /**
  42615. * Creates a line mesh
  42616. * 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
  42617. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42618. * * The parameter `points` is an array successive Vector3
  42619. * * 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
  42620. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42621. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42622. * * When updating an instance, remember that only point positions can change, not the number of points
  42623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42625. * @param name defines the name of the new line system
  42626. * @param options defines the options used to create the line system
  42627. * @param scene defines the hosting scene
  42628. * @returns a new line mesh
  42629. */
  42630. static CreateLines(name: string, options: {
  42631. points: Vector3[];
  42632. updatable?: boolean;
  42633. instance?: Nullable<LinesMesh>;
  42634. colors?: Color4[];
  42635. useVertexAlpha?: boolean;
  42636. }, scene?: Nullable<Scene>): LinesMesh;
  42637. /**
  42638. * Creates a dashed line mesh
  42639. * * 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
  42640. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42641. * * The parameter `points` is an array successive Vector3
  42642. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42643. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42644. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42645. * * 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
  42646. * * When updating an instance, remember that only point positions can change, not the number of points
  42647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42648. * @param name defines the name of the mesh
  42649. * @param options defines the options used to create the mesh
  42650. * @param scene defines the hosting scene
  42651. * @returns the dashed line mesh
  42652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42653. */
  42654. static CreateDashedLines(name: string, options: {
  42655. points: Vector3[];
  42656. dashSize?: number;
  42657. gapSize?: number;
  42658. dashNb?: number;
  42659. updatable?: boolean;
  42660. instance?: LinesMesh;
  42661. }, scene?: Nullable<Scene>): LinesMesh;
  42662. }
  42663. }
  42664. declare module "babylonjs/Debug/rayHelper" {
  42665. import { Nullable } from "babylonjs/types";
  42666. import { Ray } from "babylonjs/Culling/ray";
  42667. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42668. import { Scene } from "babylonjs/scene";
  42669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42670. import "babylonjs/Meshes/Builders/linesBuilder";
  42671. /**
  42672. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42673. * in order to better appreciate the issue one might have.
  42674. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42675. */
  42676. export class RayHelper {
  42677. /**
  42678. * Defines the ray we are currently tryin to visualize.
  42679. */
  42680. ray: Nullable<Ray>;
  42681. private _renderPoints;
  42682. private _renderLine;
  42683. private _renderFunction;
  42684. private _scene;
  42685. private _updateToMeshFunction;
  42686. private _attachedToMesh;
  42687. private _meshSpaceDirection;
  42688. private _meshSpaceOrigin;
  42689. /**
  42690. * Helper function to create a colored helper in a scene in one line.
  42691. * @param ray Defines the ray we are currently tryin to visualize
  42692. * @param scene Defines the scene the ray is used in
  42693. * @param color Defines the color we want to see the ray in
  42694. * @returns The newly created ray helper.
  42695. */
  42696. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42697. /**
  42698. * Instantiate a new ray helper.
  42699. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42700. * in order to better appreciate the issue one might have.
  42701. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42702. * @param ray Defines the ray we are currently tryin to visualize
  42703. */
  42704. constructor(ray: Ray);
  42705. /**
  42706. * Shows the ray we are willing to debug.
  42707. * @param scene Defines the scene the ray needs to be rendered in
  42708. * @param color Defines the color the ray needs to be rendered in
  42709. */
  42710. show(scene: Scene, color?: Color3): void;
  42711. /**
  42712. * Hides the ray we are debugging.
  42713. */
  42714. hide(): void;
  42715. private _render;
  42716. /**
  42717. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42718. * @param mesh Defines the mesh we want the helper attached to
  42719. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42720. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42721. * @param length Defines the length of the ray
  42722. */
  42723. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42724. /**
  42725. * Detach the ray helper from the mesh it has previously been attached to.
  42726. */
  42727. detachFromMesh(): void;
  42728. private _updateToMesh;
  42729. /**
  42730. * Dispose the helper and release its associated resources.
  42731. */
  42732. dispose(): void;
  42733. }
  42734. }
  42735. declare module "babylonjs/Debug/skeletonViewer" {
  42736. import { Color3 } from "babylonjs/Maths/math";
  42737. import { Scene } from "babylonjs/scene";
  42738. import { Nullable } from "babylonjs/types";
  42739. import { Skeleton } from "babylonjs/Bones/skeleton";
  42740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42741. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42742. /**
  42743. * Class used to render a debug view of a given skeleton
  42744. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42745. */
  42746. export class SkeletonViewer {
  42747. /** defines the skeleton to render */
  42748. skeleton: Skeleton;
  42749. /** defines the mesh attached to the skeleton */
  42750. mesh: AbstractMesh;
  42751. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42752. autoUpdateBonesMatrices: boolean;
  42753. /** defines the rendering group id to use with the viewer */
  42754. renderingGroupId: number;
  42755. /** Gets or sets the color used to render the skeleton */
  42756. color: Color3;
  42757. private _scene;
  42758. private _debugLines;
  42759. private _debugMesh;
  42760. private _isEnabled;
  42761. private _renderFunction;
  42762. private _utilityLayer;
  42763. /**
  42764. * Returns the mesh used to render the bones
  42765. */
  42766. readonly debugMesh: Nullable<LinesMesh>;
  42767. /**
  42768. * Creates a new SkeletonViewer
  42769. * @param skeleton defines the skeleton to render
  42770. * @param mesh defines the mesh attached to the skeleton
  42771. * @param scene defines the hosting scene
  42772. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42773. * @param renderingGroupId defines the rendering group id to use with the viewer
  42774. */
  42775. constructor(
  42776. /** defines the skeleton to render */
  42777. skeleton: Skeleton,
  42778. /** defines the mesh attached to the skeleton */
  42779. mesh: AbstractMesh, scene: Scene,
  42780. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42781. autoUpdateBonesMatrices?: boolean,
  42782. /** defines the rendering group id to use with the viewer */
  42783. renderingGroupId?: number);
  42784. /** Gets or sets a boolean indicating if the viewer is enabled */
  42785. isEnabled: boolean;
  42786. private _getBonePosition;
  42787. private _getLinesForBonesWithLength;
  42788. private _getLinesForBonesNoLength;
  42789. /** Update the viewer to sync with current skeleton state */
  42790. update(): void;
  42791. /** Release associated resources */
  42792. dispose(): void;
  42793. }
  42794. }
  42795. declare module "babylonjs/Debug/index" {
  42796. export * from "babylonjs/Debug/axesViewer";
  42797. export * from "babylonjs/Debug/boneAxesViewer";
  42798. export * from "babylonjs/Debug/debugLayer";
  42799. export * from "babylonjs/Debug/physicsViewer";
  42800. export * from "babylonjs/Debug/rayHelper";
  42801. export * from "babylonjs/Debug/skeletonViewer";
  42802. }
  42803. declare module "babylonjs/Engines/nullEngine" {
  42804. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42805. import { Scene } from "babylonjs/scene";
  42806. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42807. import { Engine } from "babylonjs/Engines/engine";
  42808. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42809. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42810. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42811. import { Effect } from "babylonjs/Materials/effect";
  42812. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42813. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42814. /**
  42815. * Options to create the null engine
  42816. */
  42817. export class NullEngineOptions {
  42818. /**
  42819. * Render width (Default: 512)
  42820. */
  42821. renderWidth: number;
  42822. /**
  42823. * Render height (Default: 256)
  42824. */
  42825. renderHeight: number;
  42826. /**
  42827. * Texture size (Default: 512)
  42828. */
  42829. textureSize: number;
  42830. /**
  42831. * If delta time between frames should be constant
  42832. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42833. */
  42834. deterministicLockstep: boolean;
  42835. /**
  42836. * Maximum about of steps between frames (Default: 4)
  42837. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42838. */
  42839. lockstepMaxSteps: number;
  42840. }
  42841. /**
  42842. * The null engine class provides support for headless version of babylon.js.
  42843. * This can be used in server side scenario or for testing purposes
  42844. */
  42845. export class NullEngine extends Engine {
  42846. private _options;
  42847. /**
  42848. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42849. */
  42850. isDeterministicLockStep(): boolean;
  42851. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42852. getLockstepMaxSteps(): number;
  42853. /**
  42854. * Sets hardware scaling, used to save performance if needed
  42855. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42856. */
  42857. getHardwareScalingLevel(): number;
  42858. constructor(options?: NullEngineOptions);
  42859. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42860. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42861. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42862. getRenderWidth(useScreen?: boolean): number;
  42863. getRenderHeight(useScreen?: boolean): number;
  42864. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42865. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42866. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42867. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42868. bindSamplers(effect: Effect): void;
  42869. enableEffect(effect: Effect): void;
  42870. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42871. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42872. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42873. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42874. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42875. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42876. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42877. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42878. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42879. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42880. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42881. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42882. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42883. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42884. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42885. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42886. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42887. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42888. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42889. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42890. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42891. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42892. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42893. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42894. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42895. bindBuffers(vertexBuffers: {
  42896. [key: string]: VertexBuffer;
  42897. }, indexBuffer: DataBuffer, effect: Effect): void;
  42898. wipeCaches(bruteForce?: boolean): void;
  42899. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42900. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42901. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42902. /** @hidden */
  42903. _createTexture(): WebGLTexture;
  42904. /** @hidden */
  42905. _releaseTexture(texture: InternalTexture): void;
  42906. 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;
  42907. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42908. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42909. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42910. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42911. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42912. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42913. areAllEffectsReady(): boolean;
  42914. /**
  42915. * @hidden
  42916. * Get the current error code of the webGL context
  42917. * @returns the error code
  42918. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42919. */
  42920. getError(): number;
  42921. /** @hidden */
  42922. _getUnpackAlignement(): number;
  42923. /** @hidden */
  42924. _unpackFlipY(value: boolean): void;
  42925. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42926. /**
  42927. * Updates a dynamic vertex buffer.
  42928. * @param vertexBuffer the vertex buffer to update
  42929. * @param data the data used to update the vertex buffer
  42930. * @param byteOffset the byte offset of the data (optional)
  42931. * @param byteLength the byte length of the data (optional)
  42932. */
  42933. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42934. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42935. /** @hidden */
  42936. _bindTexture(channel: number, texture: InternalTexture): void;
  42937. /** @hidden */
  42938. _releaseBuffer(buffer: DataBuffer): boolean;
  42939. releaseEffects(): void;
  42940. displayLoadingUI(): void;
  42941. hideLoadingUI(): void;
  42942. /** @hidden */
  42943. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42944. /** @hidden */
  42945. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42946. /** @hidden */
  42947. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42948. /** @hidden */
  42949. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42950. }
  42951. }
  42952. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42953. import { Nullable, int } from "babylonjs/types";
  42954. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42955. /** @hidden */
  42956. export class _OcclusionDataStorage {
  42957. /** @hidden */
  42958. occlusionInternalRetryCounter: number;
  42959. /** @hidden */
  42960. isOcclusionQueryInProgress: boolean;
  42961. /** @hidden */
  42962. isOccluded: boolean;
  42963. /** @hidden */
  42964. occlusionRetryCount: number;
  42965. /** @hidden */
  42966. occlusionType: number;
  42967. /** @hidden */
  42968. occlusionQueryAlgorithmType: number;
  42969. }
  42970. module "babylonjs/Engines/engine" {
  42971. interface Engine {
  42972. /**
  42973. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42974. * @return the new query
  42975. */
  42976. createQuery(): WebGLQuery;
  42977. /**
  42978. * Delete and release a webGL query
  42979. * @param query defines the query to delete
  42980. * @return the current engine
  42981. */
  42982. deleteQuery(query: WebGLQuery): Engine;
  42983. /**
  42984. * Check if a given query has resolved and got its value
  42985. * @param query defines the query to check
  42986. * @returns true if the query got its value
  42987. */
  42988. isQueryResultAvailable(query: WebGLQuery): boolean;
  42989. /**
  42990. * Gets the value of a given query
  42991. * @param query defines the query to check
  42992. * @returns the value of the query
  42993. */
  42994. getQueryResult(query: WebGLQuery): number;
  42995. /**
  42996. * Initiates an occlusion query
  42997. * @param algorithmType defines the algorithm to use
  42998. * @param query defines the query to use
  42999. * @returns the current engine
  43000. * @see http://doc.babylonjs.com/features/occlusionquery
  43001. */
  43002. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43003. /**
  43004. * Ends an occlusion query
  43005. * @see http://doc.babylonjs.com/features/occlusionquery
  43006. * @param algorithmType defines the algorithm to use
  43007. * @returns the current engine
  43008. */
  43009. endOcclusionQuery(algorithmType: number): Engine;
  43010. /**
  43011. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43012. * Please note that only one query can be issued at a time
  43013. * @returns a time token used to track the time span
  43014. */
  43015. startTimeQuery(): Nullable<_TimeToken>;
  43016. /**
  43017. * Ends a time query
  43018. * @param token defines the token used to measure the time span
  43019. * @returns the time spent (in ns)
  43020. */
  43021. endTimeQuery(token: _TimeToken): int;
  43022. /** @hidden */
  43023. _currentNonTimestampToken: Nullable<_TimeToken>;
  43024. /** @hidden */
  43025. _createTimeQuery(): WebGLQuery;
  43026. /** @hidden */
  43027. _deleteTimeQuery(query: WebGLQuery): void;
  43028. /** @hidden */
  43029. _getGlAlgorithmType(algorithmType: number): number;
  43030. /** @hidden */
  43031. _getTimeQueryResult(query: WebGLQuery): any;
  43032. /** @hidden */
  43033. _getTimeQueryAvailability(query: WebGLQuery): any;
  43034. }
  43035. }
  43036. module "babylonjs/Meshes/abstractMesh" {
  43037. interface AbstractMesh {
  43038. /**
  43039. * Backing filed
  43040. * @hidden
  43041. */
  43042. __occlusionDataStorage: _OcclusionDataStorage;
  43043. /**
  43044. * Access property
  43045. * @hidden
  43046. */
  43047. _occlusionDataStorage: _OcclusionDataStorage;
  43048. /**
  43049. * 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.
  43050. * The default value is -1 which means don't break the query and wait till the result
  43051. * @see http://doc.babylonjs.com/features/occlusionquery
  43052. */
  43053. occlusionRetryCount: number;
  43054. /**
  43055. * 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:
  43056. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43057. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43058. * * 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.
  43059. * @see http://doc.babylonjs.com/features/occlusionquery
  43060. */
  43061. occlusionType: number;
  43062. /**
  43063. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43064. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43065. * * 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.
  43066. * @see http://doc.babylonjs.com/features/occlusionquery
  43067. */
  43068. occlusionQueryAlgorithmType: number;
  43069. /**
  43070. * 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
  43071. * @see http://doc.babylonjs.com/features/occlusionquery
  43072. */
  43073. isOccluded: boolean;
  43074. /**
  43075. * Flag to check the progress status of the query
  43076. * @see http://doc.babylonjs.com/features/occlusionquery
  43077. */
  43078. isOcclusionQueryInProgress: boolean;
  43079. }
  43080. }
  43081. }
  43082. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43083. import { Nullable } from "babylonjs/types";
  43084. /** @hidden */
  43085. export var _forceTransformFeedbackToBundle: boolean;
  43086. module "babylonjs/Engines/engine" {
  43087. interface Engine {
  43088. /**
  43089. * Creates a webGL transform feedback object
  43090. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43091. * @returns the webGL transform feedback object
  43092. */
  43093. createTransformFeedback(): WebGLTransformFeedback;
  43094. /**
  43095. * Delete a webGL transform feedback object
  43096. * @param value defines the webGL transform feedback object to delete
  43097. */
  43098. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43099. /**
  43100. * Bind a webGL transform feedback object to the webgl context
  43101. * @param value defines the webGL transform feedback object to bind
  43102. */
  43103. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43104. /**
  43105. * Begins a transform feedback operation
  43106. * @param usePoints defines if points or triangles must be used
  43107. */
  43108. beginTransformFeedback(usePoints: boolean): void;
  43109. /**
  43110. * Ends a transform feedback operation
  43111. */
  43112. endTransformFeedback(): void;
  43113. /**
  43114. * Specify the varyings to use with transform feedback
  43115. * @param program defines the associated webGL program
  43116. * @param value defines the list of strings representing the varying names
  43117. */
  43118. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43119. /**
  43120. * Bind a webGL buffer for a transform feedback operation
  43121. * @param value defines the webGL buffer to bind
  43122. */
  43123. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43124. }
  43125. }
  43126. }
  43127. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43128. import { Scene } from "babylonjs/scene";
  43129. import { Engine } from "babylonjs/Engines/engine";
  43130. import { Texture } from "babylonjs/Materials/Textures/texture";
  43131. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43132. import "babylonjs/Engines/Extensions/engine.multiRender";
  43133. /**
  43134. * Creation options of the multi render target texture.
  43135. */
  43136. export interface IMultiRenderTargetOptions {
  43137. /**
  43138. * Define if the texture needs to create mip maps after render.
  43139. */
  43140. generateMipMaps?: boolean;
  43141. /**
  43142. * Define the types of all the draw buffers we want to create
  43143. */
  43144. types?: number[];
  43145. /**
  43146. * Define the sampling modes of all the draw buffers we want to create
  43147. */
  43148. samplingModes?: number[];
  43149. /**
  43150. * Define if a depth buffer is required
  43151. */
  43152. generateDepthBuffer?: boolean;
  43153. /**
  43154. * Define if a stencil buffer is required
  43155. */
  43156. generateStencilBuffer?: boolean;
  43157. /**
  43158. * Define if a depth texture is required instead of a depth buffer
  43159. */
  43160. generateDepthTexture?: boolean;
  43161. /**
  43162. * Define the number of desired draw buffers
  43163. */
  43164. textureCount?: number;
  43165. /**
  43166. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43167. */
  43168. doNotChangeAspectRatio?: boolean;
  43169. /**
  43170. * Define the default type of the buffers we are creating
  43171. */
  43172. defaultType?: number;
  43173. }
  43174. /**
  43175. * A multi render target, like a render target provides the ability to render to a texture.
  43176. * Unlike the render target, it can render to several draw buffers in one draw.
  43177. * This is specially interesting in deferred rendering or for any effects requiring more than
  43178. * just one color from a single pass.
  43179. */
  43180. export class MultiRenderTarget extends RenderTargetTexture {
  43181. private _internalTextures;
  43182. private _textures;
  43183. private _multiRenderTargetOptions;
  43184. /**
  43185. * Get if draw buffers are currently supported by the used hardware and browser.
  43186. */
  43187. readonly isSupported: boolean;
  43188. /**
  43189. * Get the list of textures generated by the multi render target.
  43190. */
  43191. readonly textures: Texture[];
  43192. /**
  43193. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43194. */
  43195. readonly depthTexture: Texture;
  43196. /**
  43197. * Set the wrapping mode on U of all the textures we are rendering to.
  43198. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43199. */
  43200. wrapU: number;
  43201. /**
  43202. * Set the wrapping mode on V of all the textures we are rendering to.
  43203. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43204. */
  43205. wrapV: number;
  43206. /**
  43207. * Instantiate a new multi render target texture.
  43208. * A multi render target, like a render target provides the ability to render to a texture.
  43209. * Unlike the render target, it can render to several draw buffers in one draw.
  43210. * This is specially interesting in deferred rendering or for any effects requiring more than
  43211. * just one color from a single pass.
  43212. * @param name Define the name of the texture
  43213. * @param size Define the size of the buffers to render to
  43214. * @param count Define the number of target we are rendering into
  43215. * @param scene Define the scene the texture belongs to
  43216. * @param options Define the options used to create the multi render target
  43217. */
  43218. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43219. /** @hidden */
  43220. _rebuild(): void;
  43221. private _createInternalTextures;
  43222. private _createTextures;
  43223. /**
  43224. * Define the number of samples used if MSAA is enabled.
  43225. */
  43226. samples: number;
  43227. /**
  43228. * Resize all the textures in the multi render target.
  43229. * Be carrefull as it will recreate all the data in the new texture.
  43230. * @param size Define the new size
  43231. */
  43232. resize(size: any): void;
  43233. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43234. /**
  43235. * Dispose the render targets and their associated resources
  43236. */
  43237. dispose(): void;
  43238. /**
  43239. * Release all the underlying texture used as draw buffers.
  43240. */
  43241. releaseInternalTextures(): void;
  43242. }
  43243. }
  43244. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43245. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43246. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43247. import { Nullable } from "babylonjs/types";
  43248. module "babylonjs/Engines/engine" {
  43249. interface Engine {
  43250. /**
  43251. * Unbind a list of render target textures from the webGL context
  43252. * This is used only when drawBuffer extension or webGL2 are active
  43253. * @param textures defines the render target textures to unbind
  43254. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43255. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43256. */
  43257. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43258. /**
  43259. * Create a multi render target texture
  43260. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43261. * @param size defines the size of the texture
  43262. * @param options defines the creation options
  43263. * @returns the cube texture as an InternalTexture
  43264. */
  43265. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43266. /**
  43267. * Update the sample count for a given multiple render target texture
  43268. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43269. * @param textures defines the textures to update
  43270. * @param samples defines the sample count to set
  43271. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43272. */
  43273. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43274. }
  43275. }
  43276. }
  43277. declare module "babylonjs/Engines/Extensions/index" {
  43278. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43279. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43280. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43281. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43282. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43283. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43284. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43285. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43286. }
  43287. declare module "babylonjs/Engines/index" {
  43288. export * from "babylonjs/Engines/constants";
  43289. export * from "babylonjs/Engines/engine";
  43290. export * from "babylonjs/Engines/engineStore";
  43291. export * from "babylonjs/Engines/nullEngine";
  43292. export * from "babylonjs/Engines/Extensions/index";
  43293. export * from "babylonjs/Engines/IPipelineContext";
  43294. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43295. }
  43296. declare module "babylonjs/Events/clipboardEvents" {
  43297. /**
  43298. * Gather the list of clipboard event types as constants.
  43299. */
  43300. export class ClipboardEventTypes {
  43301. /**
  43302. * The clipboard event is fired when a copy command is active (pressed).
  43303. */
  43304. static readonly COPY: number;
  43305. /**
  43306. * The clipboard event is fired when a cut command is active (pressed).
  43307. */
  43308. static readonly CUT: number;
  43309. /**
  43310. * The clipboard event is fired when a paste command is active (pressed).
  43311. */
  43312. static readonly PASTE: number;
  43313. }
  43314. /**
  43315. * This class is used to store clipboard related info for the onClipboardObservable event.
  43316. */
  43317. export class ClipboardInfo {
  43318. /**
  43319. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43320. */
  43321. type: number;
  43322. /**
  43323. * Defines the related dom event
  43324. */
  43325. event: ClipboardEvent;
  43326. /**
  43327. *Creates an instance of ClipboardInfo.
  43328. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43329. * @param event Defines the related dom event
  43330. */
  43331. constructor(
  43332. /**
  43333. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43334. */
  43335. type: number,
  43336. /**
  43337. * Defines the related dom event
  43338. */
  43339. event: ClipboardEvent);
  43340. /**
  43341. * Get the clipboard event's type from the keycode.
  43342. * @param keyCode Defines the keyCode for the current keyboard event.
  43343. * @return {number}
  43344. */
  43345. static GetTypeFromCharacter(keyCode: number): number;
  43346. }
  43347. }
  43348. declare module "babylonjs/Events/index" {
  43349. export * from "babylonjs/Events/keyboardEvents";
  43350. export * from "babylonjs/Events/pointerEvents";
  43351. export * from "babylonjs/Events/clipboardEvents";
  43352. }
  43353. declare module "babylonjs/Loading/sceneLoader" {
  43354. import { Observable } from "babylonjs/Misc/observable";
  43355. import { Nullable } from "babylonjs/types";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { Engine } from "babylonjs/Engines/engine";
  43358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43359. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43360. import { AssetContainer } from "babylonjs/assetContainer";
  43361. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43362. import { Skeleton } from "babylonjs/Bones/skeleton";
  43363. /**
  43364. * Class used to represent data loading progression
  43365. */
  43366. export class SceneLoaderProgressEvent {
  43367. /** defines if data length to load can be evaluated */
  43368. readonly lengthComputable: boolean;
  43369. /** defines the loaded data length */
  43370. readonly loaded: number;
  43371. /** defines the data length to load */
  43372. readonly total: number;
  43373. /**
  43374. * Create a new progress event
  43375. * @param lengthComputable defines if data length to load can be evaluated
  43376. * @param loaded defines the loaded data length
  43377. * @param total defines the data length to load
  43378. */
  43379. constructor(
  43380. /** defines if data length to load can be evaluated */
  43381. lengthComputable: boolean,
  43382. /** defines the loaded data length */
  43383. loaded: number,
  43384. /** defines the data length to load */
  43385. total: number);
  43386. /**
  43387. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43388. * @param event defines the source event
  43389. * @returns a new SceneLoaderProgressEvent
  43390. */
  43391. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43392. }
  43393. /**
  43394. * Interface used by SceneLoader plugins to define supported file extensions
  43395. */
  43396. export interface ISceneLoaderPluginExtensions {
  43397. /**
  43398. * Defines the list of supported extensions
  43399. */
  43400. [extension: string]: {
  43401. isBinary: boolean;
  43402. };
  43403. }
  43404. /**
  43405. * Interface used by SceneLoader plugin factory
  43406. */
  43407. export interface ISceneLoaderPluginFactory {
  43408. /**
  43409. * Defines the name of the factory
  43410. */
  43411. name: string;
  43412. /**
  43413. * Function called to create a new plugin
  43414. * @return the new plugin
  43415. */
  43416. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43417. /**
  43418. * Boolean indicating if the plugin can direct load specific data
  43419. */
  43420. canDirectLoad?: (data: string) => boolean;
  43421. }
  43422. /**
  43423. * Interface used to define a SceneLoader plugin
  43424. */
  43425. export interface ISceneLoaderPlugin {
  43426. /**
  43427. * The friendly name of this plugin.
  43428. */
  43429. name: string;
  43430. /**
  43431. * The file extensions supported by this plugin.
  43432. */
  43433. extensions: string | ISceneLoaderPluginExtensions;
  43434. /**
  43435. * Import meshes into a scene.
  43436. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43437. * @param scene The scene to import into
  43438. * @param data The data to import
  43439. * @param rootUrl The root url for scene and resources
  43440. * @param meshes The meshes array to import into
  43441. * @param particleSystems The particle systems array to import into
  43442. * @param skeletons The skeletons array to import into
  43443. * @param onError The callback when import fails
  43444. * @returns True if successful or false otherwise
  43445. */
  43446. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43447. /**
  43448. * Load into a scene.
  43449. * @param scene The scene to load into
  43450. * @param data The data to import
  43451. * @param rootUrl The root url for scene and resources
  43452. * @param onError The callback when import fails
  43453. * @returns true if successful or false otherwise
  43454. */
  43455. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43456. /**
  43457. * The callback that returns true if the data can be directly loaded.
  43458. */
  43459. canDirectLoad?: (data: string) => boolean;
  43460. /**
  43461. * The callback that allows custom handling of the root url based on the response url.
  43462. */
  43463. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43464. /**
  43465. * Load into an asset container.
  43466. * @param scene The scene to load into
  43467. * @param data The data to import
  43468. * @param rootUrl The root url for scene and resources
  43469. * @param onError The callback when import fails
  43470. * @returns The loaded asset container
  43471. */
  43472. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43473. }
  43474. /**
  43475. * Interface used to define an async SceneLoader plugin
  43476. */
  43477. export interface ISceneLoaderPluginAsync {
  43478. /**
  43479. * The friendly name of this plugin.
  43480. */
  43481. name: string;
  43482. /**
  43483. * The file extensions supported by this plugin.
  43484. */
  43485. extensions: string | ISceneLoaderPluginExtensions;
  43486. /**
  43487. * Import meshes into a scene.
  43488. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43489. * @param scene The scene to import into
  43490. * @param data The data to import
  43491. * @param rootUrl The root url for scene and resources
  43492. * @param onProgress The callback when the load progresses
  43493. * @param fileName Defines the name of the file to load
  43494. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43495. */
  43496. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43497. meshes: AbstractMesh[];
  43498. particleSystems: IParticleSystem[];
  43499. skeletons: Skeleton[];
  43500. animationGroups: AnimationGroup[];
  43501. }>;
  43502. /**
  43503. * Load into a scene.
  43504. * @param scene The scene to load into
  43505. * @param data The data to import
  43506. * @param rootUrl The root url for scene and resources
  43507. * @param onProgress The callback when the load progresses
  43508. * @param fileName Defines the name of the file to load
  43509. * @returns Nothing
  43510. */
  43511. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43512. /**
  43513. * The callback that returns true if the data can be directly loaded.
  43514. */
  43515. canDirectLoad?: (data: string) => boolean;
  43516. /**
  43517. * The callback that allows custom handling of the root url based on the response url.
  43518. */
  43519. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43520. /**
  43521. * Load into an asset container.
  43522. * @param scene The scene to load into
  43523. * @param data The data to import
  43524. * @param rootUrl The root url for scene and resources
  43525. * @param onProgress The callback when the load progresses
  43526. * @param fileName Defines the name of the file to load
  43527. * @returns The loaded asset container
  43528. */
  43529. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43530. }
  43531. /**
  43532. * Class used to load scene from various file formats using registered plugins
  43533. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43534. */
  43535. export class SceneLoader {
  43536. /**
  43537. * No logging while loading
  43538. */
  43539. static readonly NO_LOGGING: number;
  43540. /**
  43541. * Minimal logging while loading
  43542. */
  43543. static readonly MINIMAL_LOGGING: number;
  43544. /**
  43545. * Summary logging while loading
  43546. */
  43547. static readonly SUMMARY_LOGGING: number;
  43548. /**
  43549. * Detailled logging while loading
  43550. */
  43551. static readonly DETAILED_LOGGING: number;
  43552. /**
  43553. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43554. */
  43555. static ForceFullSceneLoadingForIncremental: boolean;
  43556. /**
  43557. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43558. */
  43559. static ShowLoadingScreen: boolean;
  43560. /**
  43561. * Defines the current logging level (while loading the scene)
  43562. * @ignorenaming
  43563. */
  43564. static loggingLevel: number;
  43565. /**
  43566. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43567. */
  43568. static CleanBoneMatrixWeights: boolean;
  43569. /**
  43570. * Event raised when a plugin is used to load a scene
  43571. */
  43572. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43573. private static _registeredPlugins;
  43574. private static _getDefaultPlugin;
  43575. private static _getPluginForExtension;
  43576. private static _getPluginForDirectLoad;
  43577. private static _getPluginForFilename;
  43578. private static _getDirectLoad;
  43579. private static _loadData;
  43580. private static _getFileInfo;
  43581. /**
  43582. * Gets a plugin that can load the given extension
  43583. * @param extension defines the extension to load
  43584. * @returns a plugin or null if none works
  43585. */
  43586. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43587. /**
  43588. * Gets a boolean indicating that the given extension can be loaded
  43589. * @param extension defines the extension to load
  43590. * @returns true if the extension is supported
  43591. */
  43592. static IsPluginForExtensionAvailable(extension: string): boolean;
  43593. /**
  43594. * Adds a new plugin to the list of registered plugins
  43595. * @param plugin defines the plugin to add
  43596. */
  43597. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43598. /**
  43599. * Import meshes into a scene
  43600. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43601. * @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)
  43602. * @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)
  43603. * @param scene the instance of BABYLON.Scene to append to
  43604. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43605. * @param onProgress a callback with a progress event for each file being loaded
  43606. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43607. * @param pluginExtension the extension used to determine the plugin
  43608. * @returns The loaded plugin
  43609. */
  43610. 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>;
  43611. /**
  43612. * Import meshes into a scene
  43613. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43614. * @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)
  43615. * @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)
  43616. * @param scene the instance of BABYLON.Scene to append to
  43617. * @param onProgress a callback with a progress event for each file being loaded
  43618. * @param pluginExtension the extension used to determine the plugin
  43619. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43620. */
  43621. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43622. meshes: AbstractMesh[];
  43623. particleSystems: IParticleSystem[];
  43624. skeletons: Skeleton[];
  43625. animationGroups: AnimationGroup[];
  43626. }>;
  43627. /**
  43628. * Load a scene
  43629. * @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)
  43630. * @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)
  43631. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43632. * @param onSuccess a callback with the scene when import succeeds
  43633. * @param onProgress a callback with a progress event for each file being loaded
  43634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43635. * @param pluginExtension the extension used to determine the plugin
  43636. * @returns The loaded plugin
  43637. */
  43638. 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>;
  43639. /**
  43640. * Load a scene
  43641. * @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)
  43642. * @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)
  43643. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43644. * @param onProgress a callback with a progress event for each file being loaded
  43645. * @param pluginExtension the extension used to determine the plugin
  43646. * @returns The loaded scene
  43647. */
  43648. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43649. /**
  43650. * Append a scene
  43651. * @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)
  43652. * @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)
  43653. * @param scene is the instance of BABYLON.Scene to append to
  43654. * @param onSuccess a callback with the scene when import succeeds
  43655. * @param onProgress a callback with a progress event for each file being loaded
  43656. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43657. * @param pluginExtension the extension used to determine the plugin
  43658. * @returns The loaded plugin
  43659. */
  43660. 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>;
  43661. /**
  43662. * Append a scene
  43663. * @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)
  43664. * @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)
  43665. * @param scene is the instance of BABYLON.Scene to append to
  43666. * @param onProgress a callback with a progress event for each file being loaded
  43667. * @param pluginExtension the extension used to determine the plugin
  43668. * @returns The given scene
  43669. */
  43670. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43671. /**
  43672. * Load a scene into an asset container
  43673. * @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)
  43674. * @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)
  43675. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43676. * @param onSuccess a callback with the scene when import succeeds
  43677. * @param onProgress a callback with a progress event for each file being loaded
  43678. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43679. * @param pluginExtension the extension used to determine the plugin
  43680. * @returns The loaded plugin
  43681. */
  43682. 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>;
  43683. /**
  43684. * Load a scene into an asset container
  43685. * @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)
  43686. * @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)
  43687. * @param scene is the instance of Scene to append to
  43688. * @param onProgress a callback with a progress event for each file being loaded
  43689. * @param pluginExtension the extension used to determine the plugin
  43690. * @returns The loaded asset container
  43691. */
  43692. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43693. }
  43694. }
  43695. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43696. import { Scene } from "babylonjs/scene";
  43697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43698. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43699. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43700. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43701. /**
  43702. * Google Daydream controller
  43703. */
  43704. export class DaydreamController extends WebVRController {
  43705. /**
  43706. * Base Url for the controller model.
  43707. */
  43708. static MODEL_BASE_URL: string;
  43709. /**
  43710. * File name for the controller model.
  43711. */
  43712. static MODEL_FILENAME: string;
  43713. /**
  43714. * Gamepad Id prefix used to identify Daydream Controller.
  43715. */
  43716. static readonly GAMEPAD_ID_PREFIX: string;
  43717. /**
  43718. * Creates a new DaydreamController from a gamepad
  43719. * @param vrGamepad the gamepad that the controller should be created from
  43720. */
  43721. constructor(vrGamepad: any);
  43722. /**
  43723. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43724. * @param scene scene in which to add meshes
  43725. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43726. */
  43727. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43728. /**
  43729. * Called once for each button that changed state since the last frame
  43730. * @param buttonIdx Which button index changed
  43731. * @param state New state of the button
  43732. * @param changes Which properties on the state changed since last frame
  43733. */
  43734. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43735. }
  43736. }
  43737. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43738. import { Scene } from "babylonjs/scene";
  43739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43740. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43741. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43742. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43743. /**
  43744. * Gear VR Controller
  43745. */
  43746. export class GearVRController extends WebVRController {
  43747. /**
  43748. * Base Url for the controller model.
  43749. */
  43750. static MODEL_BASE_URL: string;
  43751. /**
  43752. * File name for the controller model.
  43753. */
  43754. static MODEL_FILENAME: string;
  43755. /**
  43756. * Gamepad Id prefix used to identify this controller.
  43757. */
  43758. static readonly GAMEPAD_ID_PREFIX: string;
  43759. private readonly _buttonIndexToObservableNameMap;
  43760. /**
  43761. * Creates a new GearVRController from a gamepad
  43762. * @param vrGamepad the gamepad that the controller should be created from
  43763. */
  43764. constructor(vrGamepad: any);
  43765. /**
  43766. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43767. * @param scene scene in which to add meshes
  43768. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43769. */
  43770. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43771. /**
  43772. * Called once for each button that changed state since the last frame
  43773. * @param buttonIdx Which button index changed
  43774. * @param state New state of the button
  43775. * @param changes Which properties on the state changed since last frame
  43776. */
  43777. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43778. }
  43779. }
  43780. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43781. import { Scene } from "babylonjs/scene";
  43782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43783. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43784. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43785. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43786. /**
  43787. * Generic Controller
  43788. */
  43789. export class GenericController extends WebVRController {
  43790. /**
  43791. * Base Url for the controller model.
  43792. */
  43793. static readonly MODEL_BASE_URL: string;
  43794. /**
  43795. * File name for the controller model.
  43796. */
  43797. static readonly MODEL_FILENAME: string;
  43798. /**
  43799. * Creates a new GenericController from a gamepad
  43800. * @param vrGamepad the gamepad that the controller should be created from
  43801. */
  43802. constructor(vrGamepad: any);
  43803. /**
  43804. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43805. * @param scene scene in which to add meshes
  43806. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43807. */
  43808. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43809. /**
  43810. * Called once for each button that changed state since the last frame
  43811. * @param buttonIdx Which button index changed
  43812. * @param state New state of the button
  43813. * @param changes Which properties on the state changed since last frame
  43814. */
  43815. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43816. }
  43817. }
  43818. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43819. import { Observable } from "babylonjs/Misc/observable";
  43820. import { Scene } from "babylonjs/scene";
  43821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43822. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43823. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43824. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43825. /**
  43826. * Oculus Touch Controller
  43827. */
  43828. export class OculusTouchController extends WebVRController {
  43829. /**
  43830. * Base Url for the controller model.
  43831. */
  43832. static MODEL_BASE_URL: string;
  43833. /**
  43834. * File name for the left controller model.
  43835. */
  43836. static MODEL_LEFT_FILENAME: string;
  43837. /**
  43838. * File name for the right controller model.
  43839. */
  43840. static MODEL_RIGHT_FILENAME: string;
  43841. /**
  43842. * Fired when the secondary trigger on this controller is modified
  43843. */
  43844. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43845. /**
  43846. * Fired when the thumb rest on this controller is modified
  43847. */
  43848. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43849. /**
  43850. * Creates a new OculusTouchController from a gamepad
  43851. * @param vrGamepad the gamepad that the controller should be created from
  43852. */
  43853. constructor(vrGamepad: any);
  43854. /**
  43855. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43856. * @param scene scene in which to add meshes
  43857. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43858. */
  43859. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43860. /**
  43861. * Fired when the A button on this controller is modified
  43862. */
  43863. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43864. /**
  43865. * Fired when the B button on this controller is modified
  43866. */
  43867. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43868. /**
  43869. * Fired when the X button on this controller is modified
  43870. */
  43871. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43872. /**
  43873. * Fired when the Y button on this controller is modified
  43874. */
  43875. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43876. /**
  43877. * Called once for each button that changed state since the last frame
  43878. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43879. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43880. * 2) secondary trigger (same)
  43881. * 3) A (right) X (left), touch, pressed = value
  43882. * 4) B / Y
  43883. * 5) thumb rest
  43884. * @param buttonIdx Which button index changed
  43885. * @param state New state of the button
  43886. * @param changes Which properties on the state changed since last frame
  43887. */
  43888. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43889. }
  43890. }
  43891. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43892. import { Scene } from "babylonjs/scene";
  43893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43894. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43895. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43896. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43897. import { Observable } from "babylonjs/Misc/observable";
  43898. /**
  43899. * Vive Controller
  43900. */
  43901. export class ViveController extends WebVRController {
  43902. /**
  43903. * Base Url for the controller model.
  43904. */
  43905. static MODEL_BASE_URL: string;
  43906. /**
  43907. * File name for the controller model.
  43908. */
  43909. static MODEL_FILENAME: string;
  43910. /**
  43911. * Creates a new ViveController from a gamepad
  43912. * @param vrGamepad the gamepad that the controller should be created from
  43913. */
  43914. constructor(vrGamepad: any);
  43915. /**
  43916. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43917. * @param scene scene in which to add meshes
  43918. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43919. */
  43920. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43921. /**
  43922. * Fired when the left button on this controller is modified
  43923. */
  43924. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43925. /**
  43926. * Fired when the right button on this controller is modified
  43927. */
  43928. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43929. /**
  43930. * Fired when the menu button on this controller is modified
  43931. */
  43932. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43933. /**
  43934. * Called once for each button that changed state since the last frame
  43935. * Vive mapping:
  43936. * 0: touchpad
  43937. * 1: trigger
  43938. * 2: left AND right buttons
  43939. * 3: menu button
  43940. * @param buttonIdx Which button index changed
  43941. * @param state New state of the button
  43942. * @param changes Which properties on the state changed since last frame
  43943. */
  43944. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43945. }
  43946. }
  43947. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43948. import { Observable } from "babylonjs/Misc/observable";
  43949. import { Scene } from "babylonjs/scene";
  43950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43951. import { Ray } from "babylonjs/Culling/ray";
  43952. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43953. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43954. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43955. /**
  43956. * Defines the WindowsMotionController object that the state of the windows motion controller
  43957. */
  43958. export class WindowsMotionController extends WebVRController {
  43959. /**
  43960. * The base url used to load the left and right controller models
  43961. */
  43962. static MODEL_BASE_URL: string;
  43963. /**
  43964. * The name of the left controller model file
  43965. */
  43966. static MODEL_LEFT_FILENAME: string;
  43967. /**
  43968. * The name of the right controller model file
  43969. */
  43970. static MODEL_RIGHT_FILENAME: string;
  43971. /**
  43972. * The controller name prefix for this controller type
  43973. */
  43974. static readonly GAMEPAD_ID_PREFIX: string;
  43975. /**
  43976. * The controller id pattern for this controller type
  43977. */
  43978. private static readonly GAMEPAD_ID_PATTERN;
  43979. private _loadedMeshInfo;
  43980. private readonly _mapping;
  43981. /**
  43982. * Fired when the trackpad on this controller is clicked
  43983. */
  43984. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43985. /**
  43986. * Fired when the trackpad on this controller is modified
  43987. */
  43988. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43989. /**
  43990. * The current x and y values of this controller's trackpad
  43991. */
  43992. trackpad: StickValues;
  43993. /**
  43994. * Creates a new WindowsMotionController from a gamepad
  43995. * @param vrGamepad the gamepad that the controller should be created from
  43996. */
  43997. constructor(vrGamepad: any);
  43998. /**
  43999. * Fired when the trigger on this controller is modified
  44000. */
  44001. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44002. /**
  44003. * Fired when the menu button on this controller is modified
  44004. */
  44005. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44006. /**
  44007. * Fired when the grip button on this controller is modified
  44008. */
  44009. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44010. /**
  44011. * Fired when the thumbstick button on this controller is modified
  44012. */
  44013. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44014. /**
  44015. * Fired when the touchpad button on this controller is modified
  44016. */
  44017. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44018. /**
  44019. * Fired when the touchpad values on this controller are modified
  44020. */
  44021. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44022. private _updateTrackpad;
  44023. /**
  44024. * Called once per frame by the engine.
  44025. */
  44026. update(): void;
  44027. /**
  44028. * Called once for each button that changed state since the last frame
  44029. * @param buttonIdx Which button index changed
  44030. * @param state New state of the button
  44031. * @param changes Which properties on the state changed since last frame
  44032. */
  44033. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44034. /**
  44035. * Moves the buttons on the controller mesh based on their current state
  44036. * @param buttonName the name of the button to move
  44037. * @param buttonValue the value of the button which determines the buttons new position
  44038. */
  44039. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44040. /**
  44041. * Moves the axis on the controller mesh based on its current state
  44042. * @param axis the index of the axis
  44043. * @param axisValue the value of the axis which determines the meshes new position
  44044. * @hidden
  44045. */
  44046. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44047. /**
  44048. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44049. * @param scene scene in which to add meshes
  44050. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44051. */
  44052. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44053. /**
  44054. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44055. * can be transformed by button presses and axes values, based on this._mapping.
  44056. *
  44057. * @param scene scene in which the meshes exist
  44058. * @param meshes list of meshes that make up the controller model to process
  44059. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44060. */
  44061. private processModel;
  44062. private createMeshInfo;
  44063. /**
  44064. * Gets the ray of the controller in the direction the controller is pointing
  44065. * @param length the length the resulting ray should be
  44066. * @returns a ray in the direction the controller is pointing
  44067. */
  44068. getForwardRay(length?: number): Ray;
  44069. /**
  44070. * Disposes of the controller
  44071. */
  44072. dispose(): void;
  44073. }
  44074. }
  44075. declare module "babylonjs/Gamepads/Controllers/index" {
  44076. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44077. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44078. export * from "babylonjs/Gamepads/Controllers/genericController";
  44079. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44080. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44081. export * from "babylonjs/Gamepads/Controllers/viveController";
  44082. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44083. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44084. }
  44085. declare module "babylonjs/Gamepads/index" {
  44086. export * from "babylonjs/Gamepads/Controllers/index";
  44087. export * from "babylonjs/Gamepads/gamepad";
  44088. export * from "babylonjs/Gamepads/gamepadManager";
  44089. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44090. export * from "babylonjs/Gamepads/xboxGamepad";
  44091. }
  44092. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44093. import { Observable } from "babylonjs/Misc/observable";
  44094. import { Nullable } from "babylonjs/types";
  44095. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44097. import { Mesh } from "babylonjs/Meshes/mesh";
  44098. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44099. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44100. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44101. /**
  44102. * Single axis scale gizmo
  44103. */
  44104. export class AxisScaleGizmo extends Gizmo {
  44105. private _coloredMaterial;
  44106. /**
  44107. * Drag behavior responsible for the gizmos dragging interactions
  44108. */
  44109. dragBehavior: PointerDragBehavior;
  44110. private _pointerObserver;
  44111. /**
  44112. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44113. */
  44114. snapDistance: number;
  44115. /**
  44116. * Event that fires each time the gizmo snaps to a new location.
  44117. * * snapDistance is the the change in distance
  44118. */
  44119. onSnapObservable: Observable<{
  44120. snapDistance: number;
  44121. }>;
  44122. /**
  44123. * If the scaling operation should be done on all axis (default: false)
  44124. */
  44125. uniformScaling: boolean;
  44126. /**
  44127. * Creates an AxisScaleGizmo
  44128. * @param gizmoLayer The utility layer the gizmo will be added to
  44129. * @param dragAxis The axis which the gizmo will be able to scale on
  44130. * @param color The color of the gizmo
  44131. */
  44132. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44133. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44134. /**
  44135. * Disposes of the gizmo
  44136. */
  44137. dispose(): void;
  44138. /**
  44139. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44140. * @param mesh The mesh to replace the default mesh of the gizmo
  44141. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44142. */
  44143. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44144. }
  44145. }
  44146. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44147. import { Observable } from "babylonjs/Misc/observable";
  44148. import { Nullable } from "babylonjs/types";
  44149. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44151. import { Mesh } from "babylonjs/Meshes/mesh";
  44152. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44153. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44154. import "babylonjs/Meshes/Builders/boxBuilder";
  44155. /**
  44156. * Bounding box gizmo
  44157. */
  44158. export class BoundingBoxGizmo extends Gizmo {
  44159. private _lineBoundingBox;
  44160. private _rotateSpheresParent;
  44161. private _scaleBoxesParent;
  44162. private _boundingDimensions;
  44163. private _renderObserver;
  44164. private _pointerObserver;
  44165. private _scaleDragSpeed;
  44166. private _tmpQuaternion;
  44167. private _tmpVector;
  44168. private _tmpRotationMatrix;
  44169. /**
  44170. * 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)
  44171. */
  44172. ignoreChildren: boolean;
  44173. /**
  44174. * 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)
  44175. */
  44176. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44177. /**
  44178. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44179. */
  44180. rotationSphereSize: number;
  44181. /**
  44182. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44183. */
  44184. scaleBoxSize: number;
  44185. /**
  44186. * 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)
  44187. */
  44188. fixedDragMeshScreenSize: boolean;
  44189. /**
  44190. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44191. */
  44192. fixedDragMeshScreenSizeDistanceFactor: number;
  44193. /**
  44194. * Fired when a rotation sphere or scale box is dragged
  44195. */
  44196. onDragStartObservable: Observable<{}>;
  44197. /**
  44198. * Fired when a scale box is dragged
  44199. */
  44200. onScaleBoxDragObservable: Observable<{}>;
  44201. /**
  44202. * Fired when a scale box drag is ended
  44203. */
  44204. onScaleBoxDragEndObservable: Observable<{}>;
  44205. /**
  44206. * Fired when a rotation sphere is dragged
  44207. */
  44208. onRotationSphereDragObservable: Observable<{}>;
  44209. /**
  44210. * Fired when a rotation sphere drag is ended
  44211. */
  44212. onRotationSphereDragEndObservable: Observable<{}>;
  44213. /**
  44214. * 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)
  44215. */
  44216. scalePivot: Nullable<Vector3>;
  44217. /**
  44218. * Mesh used as a pivot to rotate the attached mesh
  44219. */
  44220. private _anchorMesh;
  44221. private _existingMeshScale;
  44222. private _dragMesh;
  44223. private pointerDragBehavior;
  44224. private coloredMaterial;
  44225. private hoverColoredMaterial;
  44226. /**
  44227. * Sets the color of the bounding box gizmo
  44228. * @param color the color to set
  44229. */
  44230. setColor(color: Color3): void;
  44231. /**
  44232. * Creates an BoundingBoxGizmo
  44233. * @param gizmoLayer The utility layer the gizmo will be added to
  44234. * @param color The color of the gizmo
  44235. */
  44236. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44237. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44238. private _selectNode;
  44239. /**
  44240. * Updates the bounding box information for the Gizmo
  44241. */
  44242. updateBoundingBox(): void;
  44243. private _updateRotationSpheres;
  44244. private _updateScaleBoxes;
  44245. /**
  44246. * Enables rotation on the specified axis and disables rotation on the others
  44247. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44248. */
  44249. setEnabledRotationAxis(axis: string): void;
  44250. /**
  44251. * Enables/disables scaling
  44252. * @param enable if scaling should be enabled
  44253. */
  44254. setEnabledScaling(enable: boolean): void;
  44255. private _updateDummy;
  44256. /**
  44257. * Enables a pointer drag behavior on the bounding box of the gizmo
  44258. */
  44259. enableDragBehavior(): void;
  44260. /**
  44261. * Disposes of the gizmo
  44262. */
  44263. dispose(): void;
  44264. /**
  44265. * 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)
  44266. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44267. * @returns the bounding box mesh with the passed in mesh as a child
  44268. */
  44269. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44270. /**
  44271. * CustomMeshes are not supported by this gizmo
  44272. * @param mesh The mesh to replace the default mesh of the gizmo
  44273. */
  44274. setCustomMesh(mesh: Mesh): void;
  44275. }
  44276. }
  44277. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44278. import { Observable } from "babylonjs/Misc/observable";
  44279. import { Nullable } from "babylonjs/types";
  44280. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44282. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44283. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44284. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44285. import "babylonjs/Meshes/Builders/linesBuilder";
  44286. /**
  44287. * Single plane rotation gizmo
  44288. */
  44289. export class PlaneRotationGizmo extends Gizmo {
  44290. /**
  44291. * Drag behavior responsible for the gizmos dragging interactions
  44292. */
  44293. dragBehavior: PointerDragBehavior;
  44294. private _pointerObserver;
  44295. /**
  44296. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44297. */
  44298. snapDistance: number;
  44299. /**
  44300. * Event that fires each time the gizmo snaps to a new location.
  44301. * * snapDistance is the the change in distance
  44302. */
  44303. onSnapObservable: Observable<{
  44304. snapDistance: number;
  44305. }>;
  44306. /**
  44307. * Creates a PlaneRotationGizmo
  44308. * @param gizmoLayer The utility layer the gizmo will be added to
  44309. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44310. * @param color The color of the gizmo
  44311. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44312. */
  44313. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44315. /**
  44316. * Disposes of the gizmo
  44317. */
  44318. dispose(): void;
  44319. }
  44320. }
  44321. declare module "babylonjs/Gizmos/rotationGizmo" {
  44322. import { Observable } from "babylonjs/Misc/observable";
  44323. import { Nullable } from "babylonjs/types";
  44324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44325. import { Mesh } from "babylonjs/Meshes/mesh";
  44326. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44327. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44328. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44329. /**
  44330. * Gizmo that enables rotating a mesh along 3 axis
  44331. */
  44332. export class RotationGizmo extends Gizmo {
  44333. /**
  44334. * Internal gizmo used for interactions on the x axis
  44335. */
  44336. xGizmo: PlaneRotationGizmo;
  44337. /**
  44338. * Internal gizmo used for interactions on the y axis
  44339. */
  44340. yGizmo: PlaneRotationGizmo;
  44341. /**
  44342. * Internal gizmo used for interactions on the z axis
  44343. */
  44344. zGizmo: PlaneRotationGizmo;
  44345. /** Fires an event when any of it's sub gizmos are dragged */
  44346. onDragStartObservable: Observable<{}>;
  44347. /** Fires an event when any of it's sub gizmos are released from dragging */
  44348. onDragEndObservable: Observable<{}>;
  44349. attachedMesh: Nullable<AbstractMesh>;
  44350. /**
  44351. * Creates a RotationGizmo
  44352. * @param gizmoLayer The utility layer the gizmo will be added to
  44353. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44354. */
  44355. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44356. updateGizmoRotationToMatchAttachedMesh: boolean;
  44357. /**
  44358. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44359. */
  44360. snapDistance: number;
  44361. /**
  44362. * Ratio for the scale of the gizmo (Default: 1)
  44363. */
  44364. scaleRatio: number;
  44365. /**
  44366. * Disposes of the gizmo
  44367. */
  44368. dispose(): void;
  44369. /**
  44370. * CustomMeshes are not supported by this gizmo
  44371. * @param mesh The mesh to replace the default mesh of the gizmo
  44372. */
  44373. setCustomMesh(mesh: Mesh): void;
  44374. }
  44375. }
  44376. declare module "babylonjs/Gizmos/positionGizmo" {
  44377. import { Observable } from "babylonjs/Misc/observable";
  44378. import { Nullable } from "babylonjs/types";
  44379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44380. import { Mesh } from "babylonjs/Meshes/mesh";
  44381. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44382. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44383. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44384. /**
  44385. * Gizmo that enables dragging a mesh along 3 axis
  44386. */
  44387. export class PositionGizmo extends Gizmo {
  44388. /**
  44389. * Internal gizmo used for interactions on the x axis
  44390. */
  44391. xGizmo: AxisDragGizmo;
  44392. /**
  44393. * Internal gizmo used for interactions on the y axis
  44394. */
  44395. yGizmo: AxisDragGizmo;
  44396. /**
  44397. * Internal gizmo used for interactions on the z axis
  44398. */
  44399. zGizmo: AxisDragGizmo;
  44400. /** Fires an event when any of it's sub gizmos are dragged */
  44401. onDragStartObservable: Observable<{}>;
  44402. /** Fires an event when any of it's sub gizmos are released from dragging */
  44403. onDragEndObservable: Observable<{}>;
  44404. attachedMesh: Nullable<AbstractMesh>;
  44405. /**
  44406. * Creates a PositionGizmo
  44407. * @param gizmoLayer The utility layer the gizmo will be added to
  44408. */
  44409. constructor(gizmoLayer?: UtilityLayerRenderer);
  44410. updateGizmoRotationToMatchAttachedMesh: boolean;
  44411. /**
  44412. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44413. */
  44414. snapDistance: number;
  44415. /**
  44416. * Ratio for the scale of the gizmo (Default: 1)
  44417. */
  44418. scaleRatio: number;
  44419. /**
  44420. * Disposes of the gizmo
  44421. */
  44422. dispose(): void;
  44423. /**
  44424. * CustomMeshes are not supported by this gizmo
  44425. * @param mesh The mesh to replace the default mesh of the gizmo
  44426. */
  44427. setCustomMesh(mesh: Mesh): void;
  44428. }
  44429. }
  44430. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44431. import { Scene } from "babylonjs/scene";
  44432. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44433. import { Mesh } from "babylonjs/Meshes/mesh";
  44434. import { Nullable } from "babylonjs/types";
  44435. /**
  44436. * Class containing static functions to help procedurally build meshes
  44437. */
  44438. export class PolyhedronBuilder {
  44439. /**
  44440. * Creates a polyhedron mesh
  44441. * * 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
  44442. * * The parameter `size` (positive float, default 1) sets the polygon size
  44443. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44444. * * 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`
  44445. * * 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
  44446. * * 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)`)
  44447. * * 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
  44448. * * 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
  44449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44452. * @param name defines the name of the mesh
  44453. * @param options defines the options used to create the mesh
  44454. * @param scene defines the hosting scene
  44455. * @returns the polyhedron mesh
  44456. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44457. */
  44458. static CreatePolyhedron(name: string, options: {
  44459. type?: number;
  44460. size?: number;
  44461. sizeX?: number;
  44462. sizeY?: number;
  44463. sizeZ?: number;
  44464. custom?: any;
  44465. faceUV?: Vector4[];
  44466. faceColors?: Color4[];
  44467. flat?: boolean;
  44468. updatable?: boolean;
  44469. sideOrientation?: number;
  44470. frontUVs?: Vector4;
  44471. backUVs?: Vector4;
  44472. }, scene?: Nullable<Scene>): Mesh;
  44473. }
  44474. }
  44475. declare module "babylonjs/Gizmos/scaleGizmo" {
  44476. import { Observable } from "babylonjs/Misc/observable";
  44477. import { Nullable } from "babylonjs/types";
  44478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44479. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44480. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44481. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44482. /**
  44483. * Gizmo that enables scaling a mesh along 3 axis
  44484. */
  44485. export class ScaleGizmo extends Gizmo {
  44486. /**
  44487. * Internal gizmo used for interactions on the x axis
  44488. */
  44489. xGizmo: AxisScaleGizmo;
  44490. /**
  44491. * Internal gizmo used for interactions on the y axis
  44492. */
  44493. yGizmo: AxisScaleGizmo;
  44494. /**
  44495. * Internal gizmo used for interactions on the z axis
  44496. */
  44497. zGizmo: AxisScaleGizmo;
  44498. /**
  44499. * Internal gizmo used to scale all axis equally
  44500. */
  44501. uniformScaleGizmo: AxisScaleGizmo;
  44502. /** Fires an event when any of it's sub gizmos are dragged */
  44503. onDragStartObservable: Observable<{}>;
  44504. /** Fires an event when any of it's sub gizmos are released from dragging */
  44505. onDragEndObservable: Observable<{}>;
  44506. attachedMesh: Nullable<AbstractMesh>;
  44507. /**
  44508. * Creates a ScaleGizmo
  44509. * @param gizmoLayer The utility layer the gizmo will be added to
  44510. */
  44511. constructor(gizmoLayer?: UtilityLayerRenderer);
  44512. updateGizmoRotationToMatchAttachedMesh: boolean;
  44513. /**
  44514. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44515. */
  44516. snapDistance: number;
  44517. /**
  44518. * Ratio for the scale of the gizmo (Default: 1)
  44519. */
  44520. scaleRatio: number;
  44521. /**
  44522. * Disposes of the gizmo
  44523. */
  44524. dispose(): void;
  44525. }
  44526. }
  44527. declare module "babylonjs/Gizmos/gizmoManager" {
  44528. import { Observable } from "babylonjs/Misc/observable";
  44529. import { Nullable } from "babylonjs/types";
  44530. import { Scene, IDisposable } from "babylonjs/scene";
  44531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44532. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44533. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44534. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44535. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44536. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44537. /**
  44538. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44539. */
  44540. export class GizmoManager implements IDisposable {
  44541. private scene;
  44542. /**
  44543. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44544. */
  44545. gizmos: {
  44546. positionGizmo: Nullable<PositionGizmo>;
  44547. rotationGizmo: Nullable<RotationGizmo>;
  44548. scaleGizmo: Nullable<ScaleGizmo>;
  44549. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44550. };
  44551. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44552. clearGizmoOnEmptyPointerEvent: boolean;
  44553. /** Fires an event when the manager is attached to a mesh */
  44554. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44555. private _gizmosEnabled;
  44556. private _pointerObserver;
  44557. private _attachedMesh;
  44558. private _boundingBoxColor;
  44559. private _defaultUtilityLayer;
  44560. private _defaultKeepDepthUtilityLayer;
  44561. /**
  44562. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44563. */
  44564. boundingBoxDragBehavior: SixDofDragBehavior;
  44565. /**
  44566. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44567. */
  44568. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44569. /**
  44570. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44571. */
  44572. usePointerToAttachGizmos: boolean;
  44573. /**
  44574. * Instatiates a gizmo manager
  44575. * @param scene the scene to overlay the gizmos on top of
  44576. */
  44577. constructor(scene: Scene);
  44578. /**
  44579. * Attaches a set of gizmos to the specified mesh
  44580. * @param mesh The mesh the gizmo's should be attached to
  44581. */
  44582. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44583. /**
  44584. * If the position gizmo is enabled
  44585. */
  44586. positionGizmoEnabled: boolean;
  44587. /**
  44588. * If the rotation gizmo is enabled
  44589. */
  44590. rotationGizmoEnabled: boolean;
  44591. /**
  44592. * If the scale gizmo is enabled
  44593. */
  44594. scaleGizmoEnabled: boolean;
  44595. /**
  44596. * If the boundingBox gizmo is enabled
  44597. */
  44598. boundingBoxGizmoEnabled: boolean;
  44599. /**
  44600. * Disposes of the gizmo manager
  44601. */
  44602. dispose(): void;
  44603. }
  44604. }
  44605. declare module "babylonjs/Lights/directionalLight" {
  44606. import { Camera } from "babylonjs/Cameras/camera";
  44607. import { Scene } from "babylonjs/scene";
  44608. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44610. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44611. import { Effect } from "babylonjs/Materials/effect";
  44612. /**
  44613. * A directional light is defined by a direction (what a surprise!).
  44614. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44615. * 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.
  44616. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44617. */
  44618. export class DirectionalLight extends ShadowLight {
  44619. private _shadowFrustumSize;
  44620. /**
  44621. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44622. */
  44623. /**
  44624. * Specifies a fix frustum size for the shadow generation.
  44625. */
  44626. shadowFrustumSize: number;
  44627. private _shadowOrthoScale;
  44628. /**
  44629. * Gets the shadow projection scale against the optimal computed one.
  44630. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44631. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44632. */
  44633. /**
  44634. * Sets the shadow projection scale against the optimal computed one.
  44635. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44636. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44637. */
  44638. shadowOrthoScale: number;
  44639. /**
  44640. * Automatically compute the projection matrix to best fit (including all the casters)
  44641. * on each frame.
  44642. */
  44643. autoUpdateExtends: boolean;
  44644. private _orthoLeft;
  44645. private _orthoRight;
  44646. private _orthoTop;
  44647. private _orthoBottom;
  44648. /**
  44649. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44650. * The directional light is emitted from everywhere in the given direction.
  44651. * It can cast shadows.
  44652. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44653. * @param name The friendly name of the light
  44654. * @param direction The direction of the light
  44655. * @param scene The scene the light belongs to
  44656. */
  44657. constructor(name: string, direction: Vector3, scene: Scene);
  44658. /**
  44659. * Returns the string "DirectionalLight".
  44660. * @return The class name
  44661. */
  44662. getClassName(): string;
  44663. /**
  44664. * Returns the integer 1.
  44665. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44666. */
  44667. getTypeID(): number;
  44668. /**
  44669. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44670. * Returns the DirectionalLight Shadow projection matrix.
  44671. */
  44672. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44673. /**
  44674. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44675. * Returns the DirectionalLight Shadow projection matrix.
  44676. */
  44677. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44678. /**
  44679. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44680. * Returns the DirectionalLight Shadow projection matrix.
  44681. */
  44682. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44683. protected _buildUniformLayout(): void;
  44684. /**
  44685. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44686. * @param effect The effect to update
  44687. * @param lightIndex The index of the light in the effect to update
  44688. * @returns The directional light
  44689. */
  44690. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44691. /**
  44692. * Gets the minZ used for shadow according to both the scene and the light.
  44693. *
  44694. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44695. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44696. * @param activeCamera The camera we are returning the min for
  44697. * @returns the depth min z
  44698. */
  44699. getDepthMinZ(activeCamera: Camera): number;
  44700. /**
  44701. * Gets the maxZ used for shadow according to both the scene and the light.
  44702. *
  44703. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44704. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44705. * @param activeCamera The camera we are returning the max for
  44706. * @returns the depth max z
  44707. */
  44708. getDepthMaxZ(activeCamera: Camera): number;
  44709. /**
  44710. * Prepares the list of defines specific to the light type.
  44711. * @param defines the list of defines
  44712. * @param lightIndex defines the index of the light for the effect
  44713. */
  44714. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44715. }
  44716. }
  44717. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44718. import { Mesh } from "babylonjs/Meshes/mesh";
  44719. /**
  44720. * Class containing static functions to help procedurally build meshes
  44721. */
  44722. export class HemisphereBuilder {
  44723. /**
  44724. * Creates a hemisphere mesh
  44725. * @param name defines the name of the mesh
  44726. * @param options defines the options used to create the mesh
  44727. * @param scene defines the hosting scene
  44728. * @returns the hemisphere mesh
  44729. */
  44730. static CreateHemisphere(name: string, options: {
  44731. segments?: number;
  44732. diameter?: number;
  44733. sideOrientation?: number;
  44734. }, scene: any): Mesh;
  44735. }
  44736. }
  44737. declare module "babylonjs/Lights/spotLight" {
  44738. import { Nullable } from "babylonjs/types";
  44739. import { Scene } from "babylonjs/scene";
  44740. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44742. import { Effect } from "babylonjs/Materials/effect";
  44743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44744. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44745. /**
  44746. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44747. * These values define a cone of light starting from the position, emitting toward the direction.
  44748. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44749. * and the exponent defines the speed of the decay of the light with distance (reach).
  44750. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44751. */
  44752. export class SpotLight extends ShadowLight {
  44753. private _angle;
  44754. private _innerAngle;
  44755. private _cosHalfAngle;
  44756. private _lightAngleScale;
  44757. private _lightAngleOffset;
  44758. /**
  44759. * Gets the cone angle of the spot light in Radians.
  44760. */
  44761. /**
  44762. * Sets the cone angle of the spot light in Radians.
  44763. */
  44764. angle: number;
  44765. /**
  44766. * Only used in gltf falloff mode, this defines the angle where
  44767. * the directional falloff will start before cutting at angle which could be seen
  44768. * as outer angle.
  44769. */
  44770. /**
  44771. * Only used in gltf falloff mode, this defines the angle where
  44772. * the directional falloff will start before cutting at angle which could be seen
  44773. * as outer angle.
  44774. */
  44775. innerAngle: number;
  44776. private _shadowAngleScale;
  44777. /**
  44778. * Allows scaling the angle of the light for shadow generation only.
  44779. */
  44780. /**
  44781. * Allows scaling the angle of the light for shadow generation only.
  44782. */
  44783. shadowAngleScale: number;
  44784. /**
  44785. * The light decay speed with the distance from the emission spot.
  44786. */
  44787. exponent: number;
  44788. private _projectionTextureMatrix;
  44789. /**
  44790. * Allows reading the projecton texture
  44791. */
  44792. readonly projectionTextureMatrix: Matrix;
  44793. protected _projectionTextureLightNear: number;
  44794. /**
  44795. * Gets the near clip of the Spotlight for texture projection.
  44796. */
  44797. /**
  44798. * Sets the near clip of the Spotlight for texture projection.
  44799. */
  44800. projectionTextureLightNear: number;
  44801. protected _projectionTextureLightFar: number;
  44802. /**
  44803. * Gets the far clip of the Spotlight for texture projection.
  44804. */
  44805. /**
  44806. * Sets the far clip of the Spotlight for texture projection.
  44807. */
  44808. projectionTextureLightFar: number;
  44809. protected _projectionTextureUpDirection: Vector3;
  44810. /**
  44811. * Gets the Up vector of the Spotlight for texture projection.
  44812. */
  44813. /**
  44814. * Sets the Up vector of the Spotlight for texture projection.
  44815. */
  44816. projectionTextureUpDirection: Vector3;
  44817. private _projectionTexture;
  44818. /**
  44819. * Gets the projection texture of the light.
  44820. */
  44821. /**
  44822. * Sets the projection texture of the light.
  44823. */
  44824. projectionTexture: Nullable<BaseTexture>;
  44825. private _projectionTextureViewLightDirty;
  44826. private _projectionTextureProjectionLightDirty;
  44827. private _projectionTextureDirty;
  44828. private _projectionTextureViewTargetVector;
  44829. private _projectionTextureViewLightMatrix;
  44830. private _projectionTextureProjectionLightMatrix;
  44831. private _projectionTextureScalingMatrix;
  44832. /**
  44833. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44834. * It can cast shadows.
  44835. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44836. * @param name The light friendly name
  44837. * @param position The position of the spot light in the scene
  44838. * @param direction The direction of the light in the scene
  44839. * @param angle The cone angle of the light in Radians
  44840. * @param exponent The light decay speed with the distance from the emission spot
  44841. * @param scene The scene the lights belongs to
  44842. */
  44843. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44844. /**
  44845. * Returns the string "SpotLight".
  44846. * @returns the class name
  44847. */
  44848. getClassName(): string;
  44849. /**
  44850. * Returns the integer 2.
  44851. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44852. */
  44853. getTypeID(): number;
  44854. /**
  44855. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44856. */
  44857. protected _setDirection(value: Vector3): void;
  44858. /**
  44859. * Overrides the position setter to recompute the projection texture view light Matrix.
  44860. */
  44861. protected _setPosition(value: Vector3): void;
  44862. /**
  44863. * 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.
  44864. * Returns the SpotLight.
  44865. */
  44866. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44867. protected _computeProjectionTextureViewLightMatrix(): void;
  44868. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44869. /**
  44870. * Main function for light texture projection matrix computing.
  44871. */
  44872. protected _computeProjectionTextureMatrix(): void;
  44873. protected _buildUniformLayout(): void;
  44874. private _computeAngleValues;
  44875. /**
  44876. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44877. * @param effect The effect to update
  44878. * @param lightIndex The index of the light in the effect to update
  44879. * @returns The spot light
  44880. */
  44881. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44882. /**
  44883. * Disposes the light and the associated resources.
  44884. */
  44885. dispose(): void;
  44886. /**
  44887. * Prepares the list of defines specific to the light type.
  44888. * @param defines the list of defines
  44889. * @param lightIndex defines the index of the light for the effect
  44890. */
  44891. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44892. }
  44893. }
  44894. declare module "babylonjs/Gizmos/lightGizmo" {
  44895. import { Nullable } from "babylonjs/types";
  44896. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44897. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44898. import { Light } from "babylonjs/Lights/light";
  44899. /**
  44900. * Gizmo that enables viewing a light
  44901. */
  44902. export class LightGizmo extends Gizmo {
  44903. private _lightMesh;
  44904. private _material;
  44905. /**
  44906. * Creates a LightGizmo
  44907. * @param gizmoLayer The utility layer the gizmo will be added to
  44908. */
  44909. constructor(gizmoLayer?: UtilityLayerRenderer);
  44910. private _light;
  44911. /**
  44912. * The light that the gizmo is attached to
  44913. */
  44914. light: Nullable<Light>;
  44915. /**
  44916. * @hidden
  44917. * Updates the gizmo to match the attached mesh's position/rotation
  44918. */
  44919. protected _update(): void;
  44920. private static _Scale;
  44921. /**
  44922. * Creates the lines for a light mesh
  44923. */
  44924. private static _createLightLines;
  44925. private static _CreateHemisphericLightMesh;
  44926. private static _CreatePointLightMesh;
  44927. private static _CreateSpotLightMesh;
  44928. private static _CreateDirectionalLightMesh;
  44929. }
  44930. }
  44931. declare module "babylonjs/Gizmos/index" {
  44932. export * from "babylonjs/Gizmos/axisDragGizmo";
  44933. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44934. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44935. export * from "babylonjs/Gizmos/gizmo";
  44936. export * from "babylonjs/Gizmos/gizmoManager";
  44937. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44938. export * from "babylonjs/Gizmos/positionGizmo";
  44939. export * from "babylonjs/Gizmos/rotationGizmo";
  44940. export * from "babylonjs/Gizmos/scaleGizmo";
  44941. export * from "babylonjs/Gizmos/lightGizmo";
  44942. }
  44943. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44944. /** @hidden */
  44945. export var backgroundFragmentDeclaration: {
  44946. name: string;
  44947. shader: string;
  44948. };
  44949. }
  44950. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44951. /** @hidden */
  44952. export var backgroundUboDeclaration: {
  44953. name: string;
  44954. shader: string;
  44955. };
  44956. }
  44957. declare module "babylonjs/Shaders/background.fragment" {
  44958. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44959. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44960. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44961. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44962. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44963. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44964. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44965. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44966. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44967. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44968. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44969. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44970. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44971. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44972. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44973. /** @hidden */
  44974. export var backgroundPixelShader: {
  44975. name: string;
  44976. shader: string;
  44977. };
  44978. }
  44979. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44980. /** @hidden */
  44981. export var backgroundVertexDeclaration: {
  44982. name: string;
  44983. shader: string;
  44984. };
  44985. }
  44986. declare module "babylonjs/Shaders/background.vertex" {
  44987. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44988. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44990. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44991. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44992. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44993. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44994. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44995. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44996. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44997. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44998. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44999. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45000. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45001. /** @hidden */
  45002. export var backgroundVertexShader: {
  45003. name: string;
  45004. shader: string;
  45005. };
  45006. }
  45007. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45008. import { Nullable, int, float } from "babylonjs/types";
  45009. import { Scene } from "babylonjs/scene";
  45010. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45011. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45013. import { Mesh } from "babylonjs/Meshes/mesh";
  45014. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45015. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45016. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45018. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45019. import "babylonjs/Shaders/background.fragment";
  45020. import "babylonjs/Shaders/background.vertex";
  45021. /**
  45022. * Background material used to create an efficient environement around your scene.
  45023. */
  45024. export class BackgroundMaterial extends PushMaterial {
  45025. /**
  45026. * Standard reflectance value at parallel view angle.
  45027. */
  45028. static StandardReflectance0: number;
  45029. /**
  45030. * Standard reflectance value at grazing angle.
  45031. */
  45032. static StandardReflectance90: number;
  45033. protected _primaryColor: Color3;
  45034. /**
  45035. * Key light Color (multiply against the environement texture)
  45036. */
  45037. primaryColor: Color3;
  45038. protected __perceptualColor: Nullable<Color3>;
  45039. /**
  45040. * Experimental Internal Use Only.
  45041. *
  45042. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45043. * This acts as a helper to set the primary color to a more "human friendly" value.
  45044. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45045. * output color as close as possible from the chosen value.
  45046. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45047. * part of lighting setup.)
  45048. */
  45049. _perceptualColor: Nullable<Color3>;
  45050. protected _primaryColorShadowLevel: float;
  45051. /**
  45052. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45053. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45054. */
  45055. primaryColorShadowLevel: float;
  45056. protected _primaryColorHighlightLevel: float;
  45057. /**
  45058. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45059. * The primary color is used at the level chosen to define what the white area would look.
  45060. */
  45061. primaryColorHighlightLevel: float;
  45062. protected _reflectionTexture: Nullable<BaseTexture>;
  45063. /**
  45064. * Reflection Texture used in the material.
  45065. * Should be author in a specific way for the best result (refer to the documentation).
  45066. */
  45067. reflectionTexture: Nullable<BaseTexture>;
  45068. protected _reflectionBlur: float;
  45069. /**
  45070. * Reflection Texture level of blur.
  45071. *
  45072. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45073. * texture twice.
  45074. */
  45075. reflectionBlur: float;
  45076. protected _diffuseTexture: Nullable<BaseTexture>;
  45077. /**
  45078. * Diffuse Texture used in the material.
  45079. * Should be author in a specific way for the best result (refer to the documentation).
  45080. */
  45081. diffuseTexture: Nullable<BaseTexture>;
  45082. protected _shadowLights: Nullable<IShadowLight[]>;
  45083. /**
  45084. * Specify the list of lights casting shadow on the material.
  45085. * All scene shadow lights will be included if null.
  45086. */
  45087. shadowLights: Nullable<IShadowLight[]>;
  45088. protected _shadowLevel: float;
  45089. /**
  45090. * Helps adjusting the shadow to a softer level if required.
  45091. * 0 means black shadows and 1 means no shadows.
  45092. */
  45093. shadowLevel: float;
  45094. protected _sceneCenter: Vector3;
  45095. /**
  45096. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45097. * It is usually zero but might be interesting to modify according to your setup.
  45098. */
  45099. sceneCenter: Vector3;
  45100. protected _opacityFresnel: boolean;
  45101. /**
  45102. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45103. * This helps ensuring a nice transition when the camera goes under the ground.
  45104. */
  45105. opacityFresnel: boolean;
  45106. protected _reflectionFresnel: boolean;
  45107. /**
  45108. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45109. * This helps adding a mirror texture on the ground.
  45110. */
  45111. reflectionFresnel: boolean;
  45112. protected _reflectionFalloffDistance: number;
  45113. /**
  45114. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45115. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45116. */
  45117. reflectionFalloffDistance: number;
  45118. protected _reflectionAmount: number;
  45119. /**
  45120. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45121. */
  45122. reflectionAmount: number;
  45123. protected _reflectionReflectance0: number;
  45124. /**
  45125. * This specifies the weight of the reflection at grazing angle.
  45126. */
  45127. reflectionReflectance0: number;
  45128. protected _reflectionReflectance90: number;
  45129. /**
  45130. * This specifies the weight of the reflection at a perpendicular point of view.
  45131. */
  45132. reflectionReflectance90: number;
  45133. /**
  45134. * Sets the reflection reflectance fresnel values according to the default standard
  45135. * empirically know to work well :-)
  45136. */
  45137. reflectionStandardFresnelWeight: number;
  45138. protected _useRGBColor: boolean;
  45139. /**
  45140. * Helps to directly use the maps channels instead of their level.
  45141. */
  45142. useRGBColor: boolean;
  45143. protected _enableNoise: boolean;
  45144. /**
  45145. * This helps reducing the banding effect that could occur on the background.
  45146. */
  45147. enableNoise: boolean;
  45148. /**
  45149. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45150. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45151. * Recommended to be keep at 1.0 except for special cases.
  45152. */
  45153. fovMultiplier: number;
  45154. private _fovMultiplier;
  45155. /**
  45156. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45157. */
  45158. useEquirectangularFOV: boolean;
  45159. private _maxSimultaneousLights;
  45160. /**
  45161. * Number of Simultaneous lights allowed on the material.
  45162. */
  45163. maxSimultaneousLights: int;
  45164. /**
  45165. * Default configuration related to image processing available in the Background Material.
  45166. */
  45167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45168. /**
  45169. * Keep track of the image processing observer to allow dispose and replace.
  45170. */
  45171. private _imageProcessingObserver;
  45172. /**
  45173. * Attaches a new image processing configuration to the PBR Material.
  45174. * @param configuration (if null the scene configuration will be use)
  45175. */
  45176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45177. /**
  45178. * Gets the image processing configuration used either in this material.
  45179. */
  45180. /**
  45181. * Sets the Default image processing configuration used either in the this material.
  45182. *
  45183. * If sets to null, the scene one is in use.
  45184. */
  45185. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45186. /**
  45187. * Gets wether the color curves effect is enabled.
  45188. */
  45189. /**
  45190. * Sets wether the color curves effect is enabled.
  45191. */
  45192. cameraColorCurvesEnabled: boolean;
  45193. /**
  45194. * Gets wether the color grading effect is enabled.
  45195. */
  45196. /**
  45197. * Gets wether the color grading effect is enabled.
  45198. */
  45199. cameraColorGradingEnabled: boolean;
  45200. /**
  45201. * Gets wether tonemapping is enabled or not.
  45202. */
  45203. /**
  45204. * Sets wether tonemapping is enabled or not
  45205. */
  45206. cameraToneMappingEnabled: boolean;
  45207. /**
  45208. * The camera exposure used on this material.
  45209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45210. * This corresponds to a photographic exposure.
  45211. */
  45212. /**
  45213. * The camera exposure used on this material.
  45214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45215. * This corresponds to a photographic exposure.
  45216. */
  45217. cameraExposure: float;
  45218. /**
  45219. * Gets The camera contrast used on this material.
  45220. */
  45221. /**
  45222. * Sets The camera contrast used on this material.
  45223. */
  45224. cameraContrast: float;
  45225. /**
  45226. * Gets the Color Grading 2D Lookup Texture.
  45227. */
  45228. /**
  45229. * Sets the Color Grading 2D Lookup Texture.
  45230. */
  45231. cameraColorGradingTexture: Nullable<BaseTexture>;
  45232. /**
  45233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45235. * 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;
  45236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45237. */
  45238. /**
  45239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45241. * 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;
  45242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45243. */
  45244. cameraColorCurves: Nullable<ColorCurves>;
  45245. /**
  45246. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45247. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45248. */
  45249. switchToBGR: boolean;
  45250. private _renderTargets;
  45251. private _reflectionControls;
  45252. private _white;
  45253. private _primaryShadowColor;
  45254. private _primaryHighlightColor;
  45255. /**
  45256. * Instantiates a Background Material in the given scene
  45257. * @param name The friendly name of the material
  45258. * @param scene The scene to add the material to
  45259. */
  45260. constructor(name: string, scene: Scene);
  45261. /**
  45262. * Gets a boolean indicating that current material needs to register RTT
  45263. */
  45264. readonly hasRenderTargetTextures: boolean;
  45265. /**
  45266. * The entire material has been created in order to prevent overdraw.
  45267. * @returns false
  45268. */
  45269. needAlphaTesting(): boolean;
  45270. /**
  45271. * The entire material has been created in order to prevent overdraw.
  45272. * @returns true if blending is enable
  45273. */
  45274. needAlphaBlending(): boolean;
  45275. /**
  45276. * Checks wether the material is ready to be rendered for a given mesh.
  45277. * @param mesh The mesh to render
  45278. * @param subMesh The submesh to check against
  45279. * @param useInstances Specify wether or not the material is used with instances
  45280. * @returns true if all the dependencies are ready (Textures, Effects...)
  45281. */
  45282. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45283. /**
  45284. * Compute the primary color according to the chosen perceptual color.
  45285. */
  45286. private _computePrimaryColorFromPerceptualColor;
  45287. /**
  45288. * Compute the highlights and shadow colors according to their chosen levels.
  45289. */
  45290. private _computePrimaryColors;
  45291. /**
  45292. * Build the uniform buffer used in the material.
  45293. */
  45294. buildUniformLayout(): void;
  45295. /**
  45296. * Unbind the material.
  45297. */
  45298. unbind(): void;
  45299. /**
  45300. * Bind only the world matrix to the material.
  45301. * @param world The world matrix to bind.
  45302. */
  45303. bindOnlyWorldMatrix(world: Matrix): void;
  45304. /**
  45305. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45306. * @param world The world matrix to bind.
  45307. * @param subMesh The submesh to bind for.
  45308. */
  45309. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45310. /**
  45311. * Dispose the material.
  45312. * @param forceDisposeEffect Force disposal of the associated effect.
  45313. * @param forceDisposeTextures Force disposal of the associated textures.
  45314. */
  45315. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45316. /**
  45317. * Clones the material.
  45318. * @param name The cloned name.
  45319. * @returns The cloned material.
  45320. */
  45321. clone(name: string): BackgroundMaterial;
  45322. /**
  45323. * Serializes the current material to its JSON representation.
  45324. * @returns The JSON representation.
  45325. */
  45326. serialize(): any;
  45327. /**
  45328. * Gets the class name of the material
  45329. * @returns "BackgroundMaterial"
  45330. */
  45331. getClassName(): string;
  45332. /**
  45333. * Parse a JSON input to create back a background material.
  45334. * @param source The JSON data to parse
  45335. * @param scene The scene to create the parsed material in
  45336. * @param rootUrl The root url of the assets the material depends upon
  45337. * @returns the instantiated BackgroundMaterial.
  45338. */
  45339. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45340. }
  45341. }
  45342. declare module "babylonjs/Helpers/environmentHelper" {
  45343. import { Observable } from "babylonjs/Misc/observable";
  45344. import { Nullable } from "babylonjs/types";
  45345. import { Scene } from "babylonjs/scene";
  45346. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45348. import { Mesh } from "babylonjs/Meshes/mesh";
  45349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45350. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45351. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45352. import "babylonjs/Meshes/Builders/planeBuilder";
  45353. import "babylonjs/Meshes/Builders/boxBuilder";
  45354. /**
  45355. * Represents the different options available during the creation of
  45356. * a Environment helper.
  45357. *
  45358. * This can control the default ground, skybox and image processing setup of your scene.
  45359. */
  45360. export interface IEnvironmentHelperOptions {
  45361. /**
  45362. * Specifies wether or not to create a ground.
  45363. * True by default.
  45364. */
  45365. createGround: boolean;
  45366. /**
  45367. * Specifies the ground size.
  45368. * 15 by default.
  45369. */
  45370. groundSize: number;
  45371. /**
  45372. * The texture used on the ground for the main color.
  45373. * Comes from the BabylonJS CDN by default.
  45374. *
  45375. * Remarks: Can be either a texture or a url.
  45376. */
  45377. groundTexture: string | BaseTexture;
  45378. /**
  45379. * The color mixed in the ground texture by default.
  45380. * BabylonJS clearColor by default.
  45381. */
  45382. groundColor: Color3;
  45383. /**
  45384. * Specifies the ground opacity.
  45385. * 1 by default.
  45386. */
  45387. groundOpacity: number;
  45388. /**
  45389. * Enables the ground to receive shadows.
  45390. * True by default.
  45391. */
  45392. enableGroundShadow: boolean;
  45393. /**
  45394. * Helps preventing the shadow to be fully black on the ground.
  45395. * 0.5 by default.
  45396. */
  45397. groundShadowLevel: number;
  45398. /**
  45399. * Creates a mirror texture attach to the ground.
  45400. * false by default.
  45401. */
  45402. enableGroundMirror: boolean;
  45403. /**
  45404. * Specifies the ground mirror size ratio.
  45405. * 0.3 by default as the default kernel is 64.
  45406. */
  45407. groundMirrorSizeRatio: number;
  45408. /**
  45409. * Specifies the ground mirror blur kernel size.
  45410. * 64 by default.
  45411. */
  45412. groundMirrorBlurKernel: number;
  45413. /**
  45414. * Specifies the ground mirror visibility amount.
  45415. * 1 by default
  45416. */
  45417. groundMirrorAmount: number;
  45418. /**
  45419. * Specifies the ground mirror reflectance weight.
  45420. * This uses the standard weight of the background material to setup the fresnel effect
  45421. * of the mirror.
  45422. * 1 by default.
  45423. */
  45424. groundMirrorFresnelWeight: number;
  45425. /**
  45426. * Specifies the ground mirror Falloff distance.
  45427. * This can helps reducing the size of the reflection.
  45428. * 0 by Default.
  45429. */
  45430. groundMirrorFallOffDistance: number;
  45431. /**
  45432. * Specifies the ground mirror texture type.
  45433. * Unsigned Int by Default.
  45434. */
  45435. groundMirrorTextureType: number;
  45436. /**
  45437. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45438. * the shown objects.
  45439. */
  45440. groundYBias: number;
  45441. /**
  45442. * Specifies wether or not to create a skybox.
  45443. * True by default.
  45444. */
  45445. createSkybox: boolean;
  45446. /**
  45447. * Specifies the skybox size.
  45448. * 20 by default.
  45449. */
  45450. skyboxSize: number;
  45451. /**
  45452. * The texture used on the skybox for the main color.
  45453. * Comes from the BabylonJS CDN by default.
  45454. *
  45455. * Remarks: Can be either a texture or a url.
  45456. */
  45457. skyboxTexture: string | BaseTexture;
  45458. /**
  45459. * The color mixed in the skybox texture by default.
  45460. * BabylonJS clearColor by default.
  45461. */
  45462. skyboxColor: Color3;
  45463. /**
  45464. * The background rotation around the Y axis of the scene.
  45465. * This helps aligning the key lights of your scene with the background.
  45466. * 0 by default.
  45467. */
  45468. backgroundYRotation: number;
  45469. /**
  45470. * Compute automatically the size of the elements to best fit with the scene.
  45471. */
  45472. sizeAuto: boolean;
  45473. /**
  45474. * Default position of the rootMesh if autoSize is not true.
  45475. */
  45476. rootPosition: Vector3;
  45477. /**
  45478. * Sets up the image processing in the scene.
  45479. * true by default.
  45480. */
  45481. setupImageProcessing: boolean;
  45482. /**
  45483. * The texture used as your environment texture in the scene.
  45484. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45485. *
  45486. * Remarks: Can be either a texture or a url.
  45487. */
  45488. environmentTexture: string | BaseTexture;
  45489. /**
  45490. * The value of the exposure to apply to the scene.
  45491. * 0.6 by default if setupImageProcessing is true.
  45492. */
  45493. cameraExposure: number;
  45494. /**
  45495. * The value of the contrast to apply to the scene.
  45496. * 1.6 by default if setupImageProcessing is true.
  45497. */
  45498. cameraContrast: number;
  45499. /**
  45500. * Specifies wether or not tonemapping should be enabled in the scene.
  45501. * true by default if setupImageProcessing is true.
  45502. */
  45503. toneMappingEnabled: boolean;
  45504. }
  45505. /**
  45506. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45507. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45508. * It also helps with the default setup of your imageProcessing configuration.
  45509. */
  45510. export class EnvironmentHelper {
  45511. /**
  45512. * Default ground texture URL.
  45513. */
  45514. private static _groundTextureCDNUrl;
  45515. /**
  45516. * Default skybox texture URL.
  45517. */
  45518. private static _skyboxTextureCDNUrl;
  45519. /**
  45520. * Default environment texture URL.
  45521. */
  45522. private static _environmentTextureCDNUrl;
  45523. /**
  45524. * Creates the default options for the helper.
  45525. */
  45526. private static _getDefaultOptions;
  45527. private _rootMesh;
  45528. /**
  45529. * Gets the root mesh created by the helper.
  45530. */
  45531. readonly rootMesh: Mesh;
  45532. private _skybox;
  45533. /**
  45534. * Gets the skybox created by the helper.
  45535. */
  45536. readonly skybox: Nullable<Mesh>;
  45537. private _skyboxTexture;
  45538. /**
  45539. * Gets the skybox texture created by the helper.
  45540. */
  45541. readonly skyboxTexture: Nullable<BaseTexture>;
  45542. private _skyboxMaterial;
  45543. /**
  45544. * Gets the skybox material created by the helper.
  45545. */
  45546. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45547. private _ground;
  45548. /**
  45549. * Gets the ground mesh created by the helper.
  45550. */
  45551. readonly ground: Nullable<Mesh>;
  45552. private _groundTexture;
  45553. /**
  45554. * Gets the ground texture created by the helper.
  45555. */
  45556. readonly groundTexture: Nullable<BaseTexture>;
  45557. private _groundMirror;
  45558. /**
  45559. * Gets the ground mirror created by the helper.
  45560. */
  45561. readonly groundMirror: Nullable<MirrorTexture>;
  45562. /**
  45563. * Gets the ground mirror render list to helps pushing the meshes
  45564. * you wish in the ground reflection.
  45565. */
  45566. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45567. private _groundMaterial;
  45568. /**
  45569. * Gets the ground material created by the helper.
  45570. */
  45571. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45572. /**
  45573. * Stores the creation options.
  45574. */
  45575. private readonly _scene;
  45576. private _options;
  45577. /**
  45578. * This observable will be notified with any error during the creation of the environment,
  45579. * mainly texture creation errors.
  45580. */
  45581. onErrorObservable: Observable<{
  45582. message?: string;
  45583. exception?: any;
  45584. }>;
  45585. /**
  45586. * constructor
  45587. * @param options Defines the options we want to customize the helper
  45588. * @param scene The scene to add the material to
  45589. */
  45590. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45591. /**
  45592. * Updates the background according to the new options
  45593. * @param options
  45594. */
  45595. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45596. /**
  45597. * Sets the primary color of all the available elements.
  45598. * @param color the main color to affect to the ground and the background
  45599. */
  45600. setMainColor(color: Color3): void;
  45601. /**
  45602. * Setup the image processing according to the specified options.
  45603. */
  45604. private _setupImageProcessing;
  45605. /**
  45606. * Setup the environment texture according to the specified options.
  45607. */
  45608. private _setupEnvironmentTexture;
  45609. /**
  45610. * Setup the background according to the specified options.
  45611. */
  45612. private _setupBackground;
  45613. /**
  45614. * Get the scene sizes according to the setup.
  45615. */
  45616. private _getSceneSize;
  45617. /**
  45618. * Setup the ground according to the specified options.
  45619. */
  45620. private _setupGround;
  45621. /**
  45622. * Setup the ground material according to the specified options.
  45623. */
  45624. private _setupGroundMaterial;
  45625. /**
  45626. * Setup the ground diffuse texture according to the specified options.
  45627. */
  45628. private _setupGroundDiffuseTexture;
  45629. /**
  45630. * Setup the ground mirror texture according to the specified options.
  45631. */
  45632. private _setupGroundMirrorTexture;
  45633. /**
  45634. * Setup the ground to receive the mirror texture.
  45635. */
  45636. private _setupMirrorInGroundMaterial;
  45637. /**
  45638. * Setup the skybox according to the specified options.
  45639. */
  45640. private _setupSkybox;
  45641. /**
  45642. * Setup the skybox material according to the specified options.
  45643. */
  45644. private _setupSkyboxMaterial;
  45645. /**
  45646. * Setup the skybox reflection texture according to the specified options.
  45647. */
  45648. private _setupSkyboxReflectionTexture;
  45649. private _errorHandler;
  45650. /**
  45651. * Dispose all the elements created by the Helper.
  45652. */
  45653. dispose(): void;
  45654. }
  45655. }
  45656. declare module "babylonjs/Helpers/photoDome" {
  45657. import { Observable } from "babylonjs/Misc/observable";
  45658. import { Nullable } from "babylonjs/types";
  45659. import { Scene } from "babylonjs/scene";
  45660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45661. import { Mesh } from "babylonjs/Meshes/mesh";
  45662. import { Texture } from "babylonjs/Materials/Textures/texture";
  45663. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45664. import "babylonjs/Meshes/Builders/sphereBuilder";
  45665. /**
  45666. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45667. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45668. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45669. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45670. */
  45671. export class PhotoDome extends TransformNode {
  45672. private _useDirectMapping;
  45673. /**
  45674. * The texture being displayed on the sphere
  45675. */
  45676. protected _photoTexture: Texture;
  45677. /**
  45678. * Gets or sets the texture being displayed on the sphere
  45679. */
  45680. photoTexture: Texture;
  45681. /**
  45682. * Observable raised when an error occured while loading the 360 image
  45683. */
  45684. onLoadErrorObservable: Observable<string>;
  45685. /**
  45686. * The skybox material
  45687. */
  45688. protected _material: BackgroundMaterial;
  45689. /**
  45690. * The surface used for the skybox
  45691. */
  45692. protected _mesh: Mesh;
  45693. /**
  45694. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45695. * Also see the options.resolution property.
  45696. */
  45697. fovMultiplier: number;
  45698. /**
  45699. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45700. * @param name Element's name, child elements will append suffixes for their own names.
  45701. * @param urlsOfPhoto defines the url of the photo to display
  45702. * @param options defines an object containing optional or exposed sub element properties
  45703. * @param onError defines a callback called when an error occured while loading the texture
  45704. */
  45705. constructor(name: string, urlOfPhoto: string, options: {
  45706. resolution?: number;
  45707. size?: number;
  45708. useDirectMapping?: boolean;
  45709. faceForward?: boolean;
  45710. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45711. /**
  45712. * Releases resources associated with this node.
  45713. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45714. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45715. */
  45716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45717. }
  45718. }
  45719. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45720. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45721. /** @hidden */
  45722. export var rgbdDecodePixelShader: {
  45723. name: string;
  45724. shader: string;
  45725. };
  45726. }
  45727. declare module "babylonjs/Misc/brdfTextureTools" {
  45728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45729. import { Scene } from "babylonjs/scene";
  45730. import "babylonjs/Shaders/rgbdDecode.fragment";
  45731. /**
  45732. * Class used to host texture specific utilities
  45733. */
  45734. export class BRDFTextureTools {
  45735. /**
  45736. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45737. * @param texture the texture to expand.
  45738. */
  45739. private static _ExpandDefaultBRDFTexture;
  45740. /**
  45741. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45742. * @param scene defines the hosting scene
  45743. * @returns the environment BRDF texture
  45744. */
  45745. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45746. private static _environmentBRDFBase64Texture;
  45747. }
  45748. }
  45749. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45750. import { Nullable } from "babylonjs/types";
  45751. import { IAnimatable } from "babylonjs/Misc/tools";
  45752. import { Color3 } from "babylonjs/Maths/math";
  45753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45754. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45755. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45756. import { Engine } from "babylonjs/Engines/engine";
  45757. import { Scene } from "babylonjs/scene";
  45758. /**
  45759. * @hidden
  45760. */
  45761. export interface IMaterialClearCoatDefines {
  45762. CLEARCOAT: boolean;
  45763. CLEARCOAT_DEFAULTIOR: boolean;
  45764. CLEARCOAT_TEXTURE: boolean;
  45765. CLEARCOAT_TEXTUREDIRECTUV: number;
  45766. CLEARCOAT_BUMP: boolean;
  45767. CLEARCOAT_BUMPDIRECTUV: number;
  45768. CLEARCOAT_TINT: boolean;
  45769. CLEARCOAT_TINT_TEXTURE: boolean;
  45770. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45771. /** @hidden */
  45772. _areTexturesDirty: boolean;
  45773. }
  45774. /**
  45775. * Define the code related to the clear coat parameters of the pbr material.
  45776. */
  45777. export class PBRClearCoatConfiguration {
  45778. /**
  45779. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45780. * The default fits with a polyurethane material.
  45781. */
  45782. private static readonly _DefaultIndiceOfRefraction;
  45783. private _isEnabled;
  45784. /**
  45785. * Defines if the clear coat is enabled in the material.
  45786. */
  45787. isEnabled: boolean;
  45788. /**
  45789. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45790. */
  45791. intensity: number;
  45792. /**
  45793. * Defines the clear coat layer roughness.
  45794. */
  45795. roughness: number;
  45796. private _indiceOfRefraction;
  45797. /**
  45798. * Defines the indice of refraction of the clear coat.
  45799. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45800. * The default fits with a polyurethane material.
  45801. * Changing the default value is more performance intensive.
  45802. */
  45803. indiceOfRefraction: number;
  45804. private _texture;
  45805. /**
  45806. * Stores the clear coat values in a texture.
  45807. */
  45808. texture: Nullable<BaseTexture>;
  45809. private _bumpTexture;
  45810. /**
  45811. * Define the clear coat specific bump texture.
  45812. */
  45813. bumpTexture: Nullable<BaseTexture>;
  45814. private _isTintEnabled;
  45815. /**
  45816. * Defines if the clear coat tint is enabled in the material.
  45817. */
  45818. isTintEnabled: boolean;
  45819. /**
  45820. * Defines the clear coat tint of the material.
  45821. * This is only use if tint is enabled
  45822. */
  45823. tintColor: Color3;
  45824. /**
  45825. * Defines the distance at which the tint color should be found in the
  45826. * clear coat media.
  45827. * This is only use if tint is enabled
  45828. */
  45829. tintColorAtDistance: number;
  45830. /**
  45831. * Defines the clear coat layer thickness.
  45832. * This is only use if tint is enabled
  45833. */
  45834. tintThickness: number;
  45835. private _tintTexture;
  45836. /**
  45837. * Stores the clear tint values in a texture.
  45838. * rgb is tint
  45839. * a is a thickness factor
  45840. */
  45841. tintTexture: Nullable<BaseTexture>;
  45842. /** @hidden */
  45843. private _internalMarkAllSubMeshesAsTexturesDirty;
  45844. /** @hidden */
  45845. _markAllSubMeshesAsTexturesDirty(): void;
  45846. /**
  45847. * Instantiate a new istance of clear coat configuration.
  45848. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45849. */
  45850. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45851. /**
  45852. * Gets wehter the submesh is ready to be used or not.
  45853. * @param defines the list of "defines" to update.
  45854. * @param scene defines the scene the material belongs to.
  45855. * @param engine defines the engine the material belongs to.
  45856. * @param disableBumpMap defines wether the material disables bump or not.
  45857. * @returns - boolean indicating that the submesh is ready or not.
  45858. */
  45859. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45860. /**
  45861. * Checks to see if a texture is used in the material.
  45862. * @param defines the list of "defines" to update.
  45863. * @param scene defines the scene to the material belongs to.
  45864. */
  45865. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45866. /**
  45867. * Binds the material data.
  45868. * @param uniformBuffer defines the Uniform buffer to fill in.
  45869. * @param scene defines the scene the material belongs to.
  45870. * @param engine defines the engine the material belongs to.
  45871. * @param disableBumpMap defines wether the material disables bump or not.
  45872. * @param isFrozen defines wether the material is frozen or not.
  45873. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45874. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45875. */
  45876. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45877. /**
  45878. * Checks to see if a texture is used in the material.
  45879. * @param texture - Base texture to use.
  45880. * @returns - Boolean specifying if a texture is used in the material.
  45881. */
  45882. hasTexture(texture: BaseTexture): boolean;
  45883. /**
  45884. * Returns an array of the actively used textures.
  45885. * @param activeTextures Array of BaseTextures
  45886. */
  45887. getActiveTextures(activeTextures: BaseTexture[]): void;
  45888. /**
  45889. * Returns the animatable textures.
  45890. * @param animatables Array of animatable textures.
  45891. */
  45892. getAnimatables(animatables: IAnimatable[]): void;
  45893. /**
  45894. * Disposes the resources of the material.
  45895. * @param forceDisposeTextures - Forces the disposal of all textures.
  45896. */
  45897. dispose(forceDisposeTextures?: boolean): void;
  45898. /**
  45899. * Get the current class name of the texture useful for serialization or dynamic coding.
  45900. * @returns "PBRClearCoatConfiguration"
  45901. */
  45902. getClassName(): string;
  45903. /**
  45904. * Add fallbacks to the effect fallbacks list.
  45905. * @param defines defines the Base texture to use.
  45906. * @param fallbacks defines the current fallback list.
  45907. * @param currentRank defines the current fallback rank.
  45908. * @returns the new fallback rank.
  45909. */
  45910. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45911. /**
  45912. * Add the required uniforms to the current list.
  45913. * @param uniforms defines the current uniform list.
  45914. */
  45915. static AddUniforms(uniforms: string[]): void;
  45916. /**
  45917. * Add the required samplers to the current list.
  45918. * @param samplers defines the current sampler list.
  45919. */
  45920. static AddSamplers(samplers: string[]): void;
  45921. /**
  45922. * Add the required uniforms to the current buffer.
  45923. * @param uniformBuffer defines the current uniform buffer.
  45924. */
  45925. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45926. /**
  45927. * Makes a duplicate of the current configuration into another one.
  45928. * @param clearCoatConfiguration define the config where to copy the info
  45929. */
  45930. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45931. /**
  45932. * Serializes this clear coat configuration.
  45933. * @returns - An object with the serialized config.
  45934. */
  45935. serialize(): any;
  45936. /**
  45937. * Parses a Clear Coat Configuration from a serialized object.
  45938. * @param source - Serialized object.
  45939. */
  45940. parse(source: any): void;
  45941. }
  45942. }
  45943. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45944. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45945. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45947. import { Vector2 } from "babylonjs/Maths/math";
  45948. import { Scene } from "babylonjs/scene";
  45949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45950. import { IAnimatable } from "babylonjs/Misc/tools";
  45951. import { Nullable } from "babylonjs/types";
  45952. /**
  45953. * @hidden
  45954. */
  45955. export interface IMaterialAnisotropicDefines {
  45956. ANISOTROPIC: boolean;
  45957. ANISOTROPIC_TEXTURE: boolean;
  45958. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45959. MAINUV1: boolean;
  45960. _areTexturesDirty: boolean;
  45961. _needUVs: boolean;
  45962. }
  45963. /**
  45964. * Define the code related to the anisotropic parameters of the pbr material.
  45965. */
  45966. export class PBRAnisotropicConfiguration {
  45967. private _isEnabled;
  45968. /**
  45969. * Defines if the anisotropy is enabled in the material.
  45970. */
  45971. isEnabled: boolean;
  45972. /**
  45973. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45974. */
  45975. intensity: number;
  45976. /**
  45977. * Defines if the effect is along the tangents, bitangents or in between.
  45978. * By default, the effect is "strectching" the highlights along the tangents.
  45979. */
  45980. direction: Vector2;
  45981. private _texture;
  45982. /**
  45983. * Stores the anisotropy values in a texture.
  45984. * rg is direction (like normal from -1 to 1)
  45985. * b is a intensity
  45986. */
  45987. texture: Nullable<BaseTexture>;
  45988. /** @hidden */
  45989. private _internalMarkAllSubMeshesAsTexturesDirty;
  45990. /** @hidden */
  45991. _markAllSubMeshesAsTexturesDirty(): void;
  45992. /**
  45993. * Instantiate a new istance of anisotropy configuration.
  45994. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45995. */
  45996. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45997. /**
  45998. * Specifies that the submesh is ready to be used.
  45999. * @param defines the list of "defines" to update.
  46000. * @param scene defines the scene the material belongs to.
  46001. * @returns - boolean indicating that the submesh is ready or not.
  46002. */
  46003. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46004. /**
  46005. * Checks to see if a texture is used in the material.
  46006. * @param defines the list of "defines" to update.
  46007. * @param mesh the mesh we are preparing the defines for.
  46008. * @param scene defines the scene the material belongs to.
  46009. */
  46010. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46011. /**
  46012. * Binds the material data.
  46013. * @param uniformBuffer defines the Uniform buffer to fill in.
  46014. * @param scene defines the scene the material belongs to.
  46015. * @param isFrozen defines wether the material is frozen or not.
  46016. */
  46017. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46018. /**
  46019. * Checks to see if a texture is used in the material.
  46020. * @param texture - Base texture to use.
  46021. * @returns - Boolean specifying if a texture is used in the material.
  46022. */
  46023. hasTexture(texture: BaseTexture): boolean;
  46024. /**
  46025. * Returns an array of the actively used textures.
  46026. * @param activeTextures Array of BaseTextures
  46027. */
  46028. getActiveTextures(activeTextures: BaseTexture[]): void;
  46029. /**
  46030. * Returns the animatable textures.
  46031. * @param animatables Array of animatable textures.
  46032. */
  46033. getAnimatables(animatables: IAnimatable[]): void;
  46034. /**
  46035. * Disposes the resources of the material.
  46036. * @param forceDisposeTextures - Forces the disposal of all textures.
  46037. */
  46038. dispose(forceDisposeTextures?: boolean): void;
  46039. /**
  46040. * Get the current class name of the texture useful for serialization or dynamic coding.
  46041. * @returns "PBRAnisotropicConfiguration"
  46042. */
  46043. getClassName(): string;
  46044. /**
  46045. * Add fallbacks to the effect fallbacks list.
  46046. * @param defines defines the Base texture to use.
  46047. * @param fallbacks defines the current fallback list.
  46048. * @param currentRank defines the current fallback rank.
  46049. * @returns the new fallback rank.
  46050. */
  46051. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46052. /**
  46053. * Add the required uniforms to the current list.
  46054. * @param uniforms defines the current uniform list.
  46055. */
  46056. static AddUniforms(uniforms: string[]): void;
  46057. /**
  46058. * Add the required uniforms to the current buffer.
  46059. * @param uniformBuffer defines the current uniform buffer.
  46060. */
  46061. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46062. /**
  46063. * Add the required samplers to the current list.
  46064. * @param samplers defines the current sampler list.
  46065. */
  46066. static AddSamplers(samplers: string[]): void;
  46067. /**
  46068. * Makes a duplicate of the current configuration into another one.
  46069. * @param anisotropicConfiguration define the config where to copy the info
  46070. */
  46071. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46072. /**
  46073. * Serializes this anisotropy configuration.
  46074. * @returns - An object with the serialized config.
  46075. */
  46076. serialize(): any;
  46077. /**
  46078. * Parses a anisotropy Configuration from a serialized object.
  46079. * @param source - Serialized object.
  46080. */
  46081. parse(source: any): void;
  46082. }
  46083. }
  46084. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46085. /**
  46086. * @hidden
  46087. */
  46088. export interface IMaterialBRDFDefines {
  46089. BRDF_V_HEIGHT_CORRELATED: boolean;
  46090. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46091. /** @hidden */
  46092. _areMiscDirty: boolean;
  46093. }
  46094. /**
  46095. * Define the code related to the BRDF parameters of the pbr material.
  46096. */
  46097. export class PBRBRDFConfiguration {
  46098. /**
  46099. * Default value used for the energy conservation.
  46100. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46101. */
  46102. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46103. /**
  46104. * Default value used for the Smith Visibility Height Correlated mode.
  46105. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46106. */
  46107. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46108. private _useEnergyConservation;
  46109. /**
  46110. * Defines if the material uses energy conservation.
  46111. */
  46112. useEnergyConservation: boolean;
  46113. private _useSmithVisibilityHeightCorrelated;
  46114. /**
  46115. * LEGACY Mode set to false
  46116. * Defines if the material uses height smith correlated visibility term.
  46117. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46118. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46119. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46120. * Not relying on height correlated will also disable energy conservation.
  46121. */
  46122. useSmithVisibilityHeightCorrelated: boolean;
  46123. /** @hidden */
  46124. private _internalMarkAllSubMeshesAsMiscDirty;
  46125. /** @hidden */
  46126. _markAllSubMeshesAsMiscDirty(): void;
  46127. /**
  46128. * Instantiate a new istance of clear coat configuration.
  46129. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46130. */
  46131. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46132. /**
  46133. * Checks to see if a texture is used in the material.
  46134. * @param defines the list of "defines" to update.
  46135. */
  46136. prepareDefines(defines: IMaterialBRDFDefines): void;
  46137. /**
  46138. * Get the current class name of the texture useful for serialization or dynamic coding.
  46139. * @returns "PBRClearCoatConfiguration"
  46140. */
  46141. getClassName(): string;
  46142. /**
  46143. * Makes a duplicate of the current configuration into another one.
  46144. * @param brdfConfiguration define the config where to copy the info
  46145. */
  46146. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46147. /**
  46148. * Serializes this BRDF configuration.
  46149. * @returns - An object with the serialized config.
  46150. */
  46151. serialize(): any;
  46152. /**
  46153. * Parses a BRDF Configuration from a serialized object.
  46154. * @param source - Serialized object.
  46155. */
  46156. parse(source: any): void;
  46157. }
  46158. }
  46159. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46160. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46161. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46162. import { Color3 } from "babylonjs/Maths/math";
  46163. import { Scene } from "babylonjs/scene";
  46164. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46165. import { IAnimatable } from "babylonjs/Misc/tools";
  46166. import { Nullable } from "babylonjs/types";
  46167. /**
  46168. * @hidden
  46169. */
  46170. export interface IMaterialSheenDefines {
  46171. SHEEN: boolean;
  46172. SHEEN_TEXTURE: boolean;
  46173. SHEEN_TEXTUREDIRECTUV: number;
  46174. SHEEN_LINKWITHALBEDO: boolean;
  46175. /** @hidden */
  46176. _areTexturesDirty: boolean;
  46177. }
  46178. /**
  46179. * Define the code related to the Sheen parameters of the pbr material.
  46180. */
  46181. export class PBRSheenConfiguration {
  46182. private _isEnabled;
  46183. /**
  46184. * Defines if the material uses sheen.
  46185. */
  46186. isEnabled: boolean;
  46187. private _linkSheenWithAlbedo;
  46188. /**
  46189. * Defines if the sheen is linked to the sheen color.
  46190. */
  46191. linkSheenWithAlbedo: boolean;
  46192. /**
  46193. * Defines the sheen intensity.
  46194. */
  46195. intensity: number;
  46196. /**
  46197. * Defines the sheen color.
  46198. */
  46199. color: Color3;
  46200. private _texture;
  46201. /**
  46202. * Stores the sheen tint values in a texture.
  46203. * rgb is tint
  46204. * a is a intensity
  46205. */
  46206. texture: Nullable<BaseTexture>;
  46207. /** @hidden */
  46208. private _internalMarkAllSubMeshesAsTexturesDirty;
  46209. /** @hidden */
  46210. _markAllSubMeshesAsTexturesDirty(): void;
  46211. /**
  46212. * Instantiate a new istance of clear coat configuration.
  46213. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46214. */
  46215. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46216. /**
  46217. * Specifies that the submesh is ready to be used.
  46218. * @param defines the list of "defines" to update.
  46219. * @param scene defines the scene the material belongs to.
  46220. * @returns - boolean indicating that the submesh is ready or not.
  46221. */
  46222. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46223. /**
  46224. * Checks to see if a texture is used in the material.
  46225. * @param defines the list of "defines" to update.
  46226. * @param scene defines the scene the material belongs to.
  46227. */
  46228. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46229. /**
  46230. * Binds the material data.
  46231. * @param uniformBuffer defines the Uniform buffer to fill in.
  46232. * @param scene defines the scene the material belongs to.
  46233. * @param isFrozen defines wether the material is frozen or not.
  46234. */
  46235. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46236. /**
  46237. * Checks to see if a texture is used in the material.
  46238. * @param texture - Base texture to use.
  46239. * @returns - Boolean specifying if a texture is used in the material.
  46240. */
  46241. hasTexture(texture: BaseTexture): boolean;
  46242. /**
  46243. * Returns an array of the actively used textures.
  46244. * @param activeTextures Array of BaseTextures
  46245. */
  46246. getActiveTextures(activeTextures: BaseTexture[]): void;
  46247. /**
  46248. * Returns the animatable textures.
  46249. * @param animatables Array of animatable textures.
  46250. */
  46251. getAnimatables(animatables: IAnimatable[]): void;
  46252. /**
  46253. * Disposes the resources of the material.
  46254. * @param forceDisposeTextures - Forces the disposal of all textures.
  46255. */
  46256. dispose(forceDisposeTextures?: boolean): void;
  46257. /**
  46258. * Get the current class name of the texture useful for serialization or dynamic coding.
  46259. * @returns "PBRSheenConfiguration"
  46260. */
  46261. getClassName(): string;
  46262. /**
  46263. * Add fallbacks to the effect fallbacks list.
  46264. * @param defines defines the Base texture to use.
  46265. * @param fallbacks defines the current fallback list.
  46266. * @param currentRank defines the current fallback rank.
  46267. * @returns the new fallback rank.
  46268. */
  46269. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46270. /**
  46271. * Add the required uniforms to the current list.
  46272. * @param uniforms defines the current uniform list.
  46273. */
  46274. static AddUniforms(uniforms: string[]): void;
  46275. /**
  46276. * Add the required uniforms to the current buffer.
  46277. * @param uniformBuffer defines the current uniform buffer.
  46278. */
  46279. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46280. /**
  46281. * Add the required samplers to the current list.
  46282. * @param samplers defines the current sampler list.
  46283. */
  46284. static AddSamplers(samplers: string[]): void;
  46285. /**
  46286. * Makes a duplicate of the current configuration into another one.
  46287. * @param sheenConfiguration define the config where to copy the info
  46288. */
  46289. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46290. /**
  46291. * Serializes this BRDF configuration.
  46292. * @returns - An object with the serialized config.
  46293. */
  46294. serialize(): any;
  46295. /**
  46296. * Parses a Sheen Configuration from a serialized object.
  46297. * @param source - Serialized object.
  46298. */
  46299. parse(source: any): void;
  46300. }
  46301. }
  46302. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46303. import { Nullable } from "babylonjs/types";
  46304. import { IAnimatable } from "babylonjs/Misc/tools";
  46305. import { Color3 } from "babylonjs/Maths/math";
  46306. import { SmartArray } from "babylonjs/Misc/smartArray";
  46307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46308. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46309. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46310. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46311. import { Engine } from "babylonjs/Engines/engine";
  46312. import { Scene } from "babylonjs/scene";
  46313. /**
  46314. * @hidden
  46315. */
  46316. export interface IMaterialSubSurfaceDefines {
  46317. SUBSURFACE: boolean;
  46318. SS_REFRACTION: boolean;
  46319. SS_TRANSLUCENCY: boolean;
  46320. SS_SCATERRING: boolean;
  46321. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46322. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46323. SS_REFRACTIONMAP_3D: boolean;
  46324. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46325. SS_LODINREFRACTIONALPHA: boolean;
  46326. SS_GAMMAREFRACTION: boolean;
  46327. SS_RGBDREFRACTION: boolean;
  46328. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46329. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46330. /** @hidden */
  46331. _areTexturesDirty: boolean;
  46332. }
  46333. /**
  46334. * Define the code related to the sub surface parameters of the pbr material.
  46335. */
  46336. export class PBRSubSurfaceConfiguration {
  46337. private _isRefractionEnabled;
  46338. /**
  46339. * Defines if the refraction is enabled in the material.
  46340. */
  46341. isRefractionEnabled: boolean;
  46342. private _isTranslucencyEnabled;
  46343. /**
  46344. * Defines if the translucency is enabled in the material.
  46345. */
  46346. isTranslucencyEnabled: boolean;
  46347. private _isScatteringEnabled;
  46348. /**
  46349. * Defines the refraction intensity of the material.
  46350. * The refraction when enabled replaces the Diffuse part of the material.
  46351. * The intensity helps transitionning between diffuse and refraction.
  46352. */
  46353. refractionIntensity: number;
  46354. /**
  46355. * Defines the translucency intensity of the material.
  46356. * When translucency has been enabled, this defines how much of the "translucency"
  46357. * is addded to the diffuse part of the material.
  46358. */
  46359. translucencyIntensity: number;
  46360. /**
  46361. * Defines the scattering intensity of the material.
  46362. * When scattering has been enabled, this defines how much of the "scattered light"
  46363. * is addded to the diffuse part of the material.
  46364. */
  46365. scatteringIntensity: number;
  46366. private _thicknessTexture;
  46367. /**
  46368. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46369. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46370. * 0 would mean minimumThickness
  46371. * 1 would mean maximumThickness
  46372. * The other channels might be use as a mask to vary the different effects intensity.
  46373. */
  46374. thicknessTexture: Nullable<BaseTexture>;
  46375. private _refractionTexture;
  46376. /**
  46377. * Defines the texture to use for refraction.
  46378. */
  46379. refractionTexture: Nullable<BaseTexture>;
  46380. private _indexOfRefraction;
  46381. /**
  46382. * Defines the indice of refraction used in the material.
  46383. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46384. */
  46385. indexOfRefraction: number;
  46386. private _invertRefractionY;
  46387. /**
  46388. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46389. */
  46390. invertRefractionY: boolean;
  46391. private _linkRefractionWithTransparency;
  46392. /**
  46393. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46394. * Materials half opaque for instance using refraction could benefit from this control.
  46395. */
  46396. linkRefractionWithTransparency: boolean;
  46397. /**
  46398. * Defines the minimum thickness stored in the thickness map.
  46399. * If no thickness map is defined, this value will be used to simulate thickness.
  46400. */
  46401. minimumThickness: number;
  46402. /**
  46403. * Defines the maximum thickness stored in the thickness map.
  46404. */
  46405. maximumThickness: number;
  46406. /**
  46407. * Defines the volume tint of the material.
  46408. * This is used for both translucency and scattering.
  46409. */
  46410. tintColor: Color3;
  46411. /**
  46412. * Defines the distance at which the tint color should be found in the media.
  46413. * This is used for refraction only.
  46414. */
  46415. tintColorAtDistance: number;
  46416. /**
  46417. * Defines how far each channel transmit through the media.
  46418. * It is defined as a color to simplify it selection.
  46419. */
  46420. diffusionDistance: Color3;
  46421. private _useMaskFromThicknessTexture;
  46422. /**
  46423. * Stores the intensity of the different subsurface effects in the thickness texture.
  46424. * * the green channel is the translucency intensity.
  46425. * * the blue channel is the scattering intensity.
  46426. * * the alpha channel is the refraction intensity.
  46427. */
  46428. useMaskFromThicknessTexture: boolean;
  46429. /** @hidden */
  46430. private _internalMarkAllSubMeshesAsTexturesDirty;
  46431. /** @hidden */
  46432. _markAllSubMeshesAsTexturesDirty(): void;
  46433. /**
  46434. * Instantiate a new istance of sub surface configuration.
  46435. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46436. */
  46437. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46438. /**
  46439. * Gets wehter the submesh is ready to be used or not.
  46440. * @param defines the list of "defines" to update.
  46441. * @param scene defines the scene the material belongs to.
  46442. * @returns - boolean indicating that the submesh is ready or not.
  46443. */
  46444. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46445. /**
  46446. * Checks to see if a texture is used in the material.
  46447. * @param defines the list of "defines" to update.
  46448. * @param scene defines the scene to the material belongs to.
  46449. */
  46450. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46451. /**
  46452. * Binds the material data.
  46453. * @param uniformBuffer defines the Uniform buffer to fill in.
  46454. * @param scene defines the scene the material belongs to.
  46455. * @param engine defines the engine the material belongs to.
  46456. * @param isFrozen defines wether the material is frozen or not.
  46457. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46458. */
  46459. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46460. /**
  46461. * Unbinds the material from the mesh.
  46462. * @param activeEffect defines the effect that should be unbound from.
  46463. * @returns true if unbound, otherwise false
  46464. */
  46465. unbind(activeEffect: Effect): boolean;
  46466. /**
  46467. * Returns the texture used for refraction or null if none is used.
  46468. * @param scene defines the scene the material belongs to.
  46469. * @returns - Refraction texture if present. If no refraction texture and refraction
  46470. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46471. */
  46472. private _getRefractionTexture;
  46473. /**
  46474. * Returns true if alpha blending should be disabled.
  46475. */
  46476. readonly disableAlphaBlending: boolean;
  46477. /**
  46478. * Fills the list of render target textures.
  46479. * @param renderTargets the list of render targets to update
  46480. */
  46481. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46482. /**
  46483. * Checks to see if a texture is used in the material.
  46484. * @param texture - Base texture to use.
  46485. * @returns - Boolean specifying if a texture is used in the material.
  46486. */
  46487. hasTexture(texture: BaseTexture): boolean;
  46488. /**
  46489. * Gets a boolean indicating that current material needs to register RTT
  46490. * @returns true if this uses a render target otherwise false.
  46491. */
  46492. hasRenderTargetTextures(): boolean;
  46493. /**
  46494. * Returns an array of the actively used textures.
  46495. * @param activeTextures Array of BaseTextures
  46496. */
  46497. getActiveTextures(activeTextures: BaseTexture[]): void;
  46498. /**
  46499. * Returns the animatable textures.
  46500. * @param animatables Array of animatable textures.
  46501. */
  46502. getAnimatables(animatables: IAnimatable[]): void;
  46503. /**
  46504. * Disposes the resources of the material.
  46505. * @param forceDisposeTextures - Forces the disposal of all textures.
  46506. */
  46507. dispose(forceDisposeTextures?: boolean): void;
  46508. /**
  46509. * Get the current class name of the texture useful for serialization or dynamic coding.
  46510. * @returns "PBRSubSurfaceConfiguration"
  46511. */
  46512. getClassName(): string;
  46513. /**
  46514. * Add fallbacks to the effect fallbacks list.
  46515. * @param defines defines the Base texture to use.
  46516. * @param fallbacks defines the current fallback list.
  46517. * @param currentRank defines the current fallback rank.
  46518. * @returns the new fallback rank.
  46519. */
  46520. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46521. /**
  46522. * Add the required uniforms to the current list.
  46523. * @param uniforms defines the current uniform list.
  46524. */
  46525. static AddUniforms(uniforms: string[]): void;
  46526. /**
  46527. * Add the required samplers to the current list.
  46528. * @param samplers defines the current sampler list.
  46529. */
  46530. static AddSamplers(samplers: string[]): void;
  46531. /**
  46532. * Add the required uniforms to the current buffer.
  46533. * @param uniformBuffer defines the current uniform buffer.
  46534. */
  46535. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46536. /**
  46537. * Makes a duplicate of the current configuration into another one.
  46538. * @param configuration define the config where to copy the info
  46539. */
  46540. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46541. /**
  46542. * Serializes this Sub Surface configuration.
  46543. * @returns - An object with the serialized config.
  46544. */
  46545. serialize(): any;
  46546. /**
  46547. * Parses a Sub Surface Configuration from a serialized object.
  46548. * @param source - Serialized object.
  46549. */
  46550. parse(source: any): void;
  46551. }
  46552. }
  46553. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46554. /** @hidden */
  46555. export var pbrFragmentDeclaration: {
  46556. name: string;
  46557. shader: string;
  46558. };
  46559. }
  46560. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46561. /** @hidden */
  46562. export var pbrUboDeclaration: {
  46563. name: string;
  46564. shader: string;
  46565. };
  46566. }
  46567. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46568. /** @hidden */
  46569. export var pbrFragmentExtraDeclaration: {
  46570. name: string;
  46571. shader: string;
  46572. };
  46573. }
  46574. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46575. /** @hidden */
  46576. export var pbrFragmentSamplersDeclaration: {
  46577. name: string;
  46578. shader: string;
  46579. };
  46580. }
  46581. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46582. /** @hidden */
  46583. export var pbrHelperFunctions: {
  46584. name: string;
  46585. shader: string;
  46586. };
  46587. }
  46588. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46589. /** @hidden */
  46590. export var harmonicsFunctions: {
  46591. name: string;
  46592. shader: string;
  46593. };
  46594. }
  46595. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46596. /** @hidden */
  46597. export var pbrDirectLightingSetupFunctions: {
  46598. name: string;
  46599. shader: string;
  46600. };
  46601. }
  46602. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46603. /** @hidden */
  46604. export var pbrDirectLightingFalloffFunctions: {
  46605. name: string;
  46606. shader: string;
  46607. };
  46608. }
  46609. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46610. /** @hidden */
  46611. export var pbrBRDFFunctions: {
  46612. name: string;
  46613. shader: string;
  46614. };
  46615. }
  46616. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46617. /** @hidden */
  46618. export var pbrDirectLightingFunctions: {
  46619. name: string;
  46620. shader: string;
  46621. };
  46622. }
  46623. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46624. /** @hidden */
  46625. export var pbrIBLFunctions: {
  46626. name: string;
  46627. shader: string;
  46628. };
  46629. }
  46630. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46631. /** @hidden */
  46632. export var pbrDebug: {
  46633. name: string;
  46634. shader: string;
  46635. };
  46636. }
  46637. declare module "babylonjs/Shaders/pbr.fragment" {
  46638. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46639. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46640. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46641. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46642. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46643. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46644. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46645. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46646. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46647. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46648. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46649. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46650. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46651. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46652. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46653. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46654. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46655. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46656. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46657. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46658. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46659. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46660. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46661. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46662. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46663. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46664. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46665. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46666. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46667. /** @hidden */
  46668. export var pbrPixelShader: {
  46669. name: string;
  46670. shader: string;
  46671. };
  46672. }
  46673. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46674. /** @hidden */
  46675. export var pbrVertexDeclaration: {
  46676. name: string;
  46677. shader: string;
  46678. };
  46679. }
  46680. declare module "babylonjs/Shaders/pbr.vertex" {
  46681. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46682. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46683. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46684. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46685. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46686. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46687. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46688. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46689. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46690. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46691. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46692. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46693. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46694. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46695. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46696. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46697. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46698. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46699. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46700. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46701. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46702. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46703. /** @hidden */
  46704. export var pbrVertexShader: {
  46705. name: string;
  46706. shader: string;
  46707. };
  46708. }
  46709. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46710. import { IAnimatable } from "babylonjs/Misc/tools";
  46711. import { Nullable } from "babylonjs/types";
  46712. import { Scene } from "babylonjs/scene";
  46713. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46714. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46716. import { Mesh } from "babylonjs/Meshes/mesh";
  46717. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46718. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46719. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46720. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46721. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46722. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46723. import { Material } from "babylonjs/Materials/material";
  46724. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46725. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46726. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46727. import "babylonjs/Shaders/pbr.fragment";
  46728. import "babylonjs/Shaders/pbr.vertex";
  46729. /**
  46730. * Manages the defines for the PBR Material.
  46731. * @hidden
  46732. */
  46733. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46734. PBR: boolean;
  46735. MAINUV1: boolean;
  46736. MAINUV2: boolean;
  46737. UV1: boolean;
  46738. UV2: boolean;
  46739. ALBEDO: boolean;
  46740. ALBEDODIRECTUV: number;
  46741. VERTEXCOLOR: boolean;
  46742. AMBIENT: boolean;
  46743. AMBIENTDIRECTUV: number;
  46744. AMBIENTINGRAYSCALE: boolean;
  46745. OPACITY: boolean;
  46746. VERTEXALPHA: boolean;
  46747. OPACITYDIRECTUV: number;
  46748. OPACITYRGB: boolean;
  46749. ALPHATEST: boolean;
  46750. DEPTHPREPASS: boolean;
  46751. ALPHABLEND: boolean;
  46752. ALPHAFROMALBEDO: boolean;
  46753. ALPHATESTVALUE: string;
  46754. SPECULAROVERALPHA: boolean;
  46755. RADIANCEOVERALPHA: boolean;
  46756. ALPHAFRESNEL: boolean;
  46757. LINEARALPHAFRESNEL: boolean;
  46758. PREMULTIPLYALPHA: boolean;
  46759. EMISSIVE: boolean;
  46760. EMISSIVEDIRECTUV: number;
  46761. REFLECTIVITY: boolean;
  46762. REFLECTIVITYDIRECTUV: number;
  46763. SPECULARTERM: boolean;
  46764. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46765. MICROSURFACEAUTOMATIC: boolean;
  46766. LODBASEDMICROSFURACE: boolean;
  46767. MICROSURFACEMAP: boolean;
  46768. MICROSURFACEMAPDIRECTUV: number;
  46769. METALLICWORKFLOW: boolean;
  46770. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46771. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46772. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46773. AOSTOREINMETALMAPRED: boolean;
  46774. ENVIRONMENTBRDF: boolean;
  46775. ENVIRONMENTBRDF_RGBD: boolean;
  46776. NORMAL: boolean;
  46777. TANGENT: boolean;
  46778. BUMP: boolean;
  46779. BUMPDIRECTUV: number;
  46780. OBJECTSPACE_NORMALMAP: boolean;
  46781. PARALLAX: boolean;
  46782. PARALLAXOCCLUSION: boolean;
  46783. NORMALXYSCALE: boolean;
  46784. LIGHTMAP: boolean;
  46785. LIGHTMAPDIRECTUV: number;
  46786. USELIGHTMAPASSHADOWMAP: boolean;
  46787. GAMMALIGHTMAP: boolean;
  46788. REFLECTION: boolean;
  46789. REFLECTIONMAP_3D: boolean;
  46790. REFLECTIONMAP_SPHERICAL: boolean;
  46791. REFLECTIONMAP_PLANAR: boolean;
  46792. REFLECTIONMAP_CUBIC: boolean;
  46793. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46794. REFLECTIONMAP_PROJECTION: boolean;
  46795. REFLECTIONMAP_SKYBOX: boolean;
  46796. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46797. REFLECTIONMAP_EXPLICIT: boolean;
  46798. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46799. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46800. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46801. INVERTCUBICMAP: boolean;
  46802. USESPHERICALFROMREFLECTIONMAP: boolean;
  46803. USESPHERICALINVERTEX: boolean;
  46804. REFLECTIONMAP_OPPOSITEZ: boolean;
  46805. LODINREFLECTIONALPHA: boolean;
  46806. GAMMAREFLECTION: boolean;
  46807. RGBDREFLECTION: boolean;
  46808. RADIANCEOCCLUSION: boolean;
  46809. HORIZONOCCLUSION: boolean;
  46810. INSTANCES: boolean;
  46811. NUM_BONE_INFLUENCERS: number;
  46812. BonesPerMesh: number;
  46813. BONETEXTURE: boolean;
  46814. NONUNIFORMSCALING: boolean;
  46815. MORPHTARGETS: boolean;
  46816. MORPHTARGETS_NORMAL: boolean;
  46817. MORPHTARGETS_TANGENT: boolean;
  46818. NUM_MORPH_INFLUENCERS: number;
  46819. IMAGEPROCESSING: boolean;
  46820. VIGNETTE: boolean;
  46821. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46822. VIGNETTEBLENDMODEOPAQUE: boolean;
  46823. TONEMAPPING: boolean;
  46824. TONEMAPPING_ACES: boolean;
  46825. CONTRAST: boolean;
  46826. COLORCURVES: boolean;
  46827. COLORGRADING: boolean;
  46828. COLORGRADING3D: boolean;
  46829. SAMPLER3DGREENDEPTH: boolean;
  46830. SAMPLER3DBGRMAP: boolean;
  46831. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46832. EXPOSURE: boolean;
  46833. MULTIVIEW: boolean;
  46834. USEPHYSICALLIGHTFALLOFF: boolean;
  46835. USEGLTFLIGHTFALLOFF: boolean;
  46836. TWOSIDEDLIGHTING: boolean;
  46837. SHADOWFLOAT: boolean;
  46838. CLIPPLANE: boolean;
  46839. CLIPPLANE2: boolean;
  46840. CLIPPLANE3: boolean;
  46841. CLIPPLANE4: boolean;
  46842. POINTSIZE: boolean;
  46843. FOG: boolean;
  46844. LOGARITHMICDEPTH: boolean;
  46845. FORCENORMALFORWARD: boolean;
  46846. SPECULARAA: boolean;
  46847. CLEARCOAT: boolean;
  46848. CLEARCOAT_DEFAULTIOR: boolean;
  46849. CLEARCOAT_TEXTURE: boolean;
  46850. CLEARCOAT_TEXTUREDIRECTUV: number;
  46851. CLEARCOAT_BUMP: boolean;
  46852. CLEARCOAT_BUMPDIRECTUV: number;
  46853. CLEARCOAT_TINT: boolean;
  46854. CLEARCOAT_TINT_TEXTURE: boolean;
  46855. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46856. ANISOTROPIC: boolean;
  46857. ANISOTROPIC_TEXTURE: boolean;
  46858. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46859. BRDF_V_HEIGHT_CORRELATED: boolean;
  46860. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46861. SHEEN: boolean;
  46862. SHEEN_TEXTURE: boolean;
  46863. SHEEN_TEXTUREDIRECTUV: number;
  46864. SHEEN_LINKWITHALBEDO: boolean;
  46865. SUBSURFACE: boolean;
  46866. SS_REFRACTION: boolean;
  46867. SS_TRANSLUCENCY: boolean;
  46868. SS_SCATERRING: boolean;
  46869. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46870. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46871. SS_REFRACTIONMAP_3D: boolean;
  46872. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46873. SS_LODINREFRACTIONALPHA: boolean;
  46874. SS_GAMMAREFRACTION: boolean;
  46875. SS_RGBDREFRACTION: boolean;
  46876. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46877. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46878. UNLIT: boolean;
  46879. DEBUGMODE: number;
  46880. /**
  46881. * Initializes the PBR Material defines.
  46882. */
  46883. constructor();
  46884. /**
  46885. * Resets the PBR Material defines.
  46886. */
  46887. reset(): void;
  46888. }
  46889. /**
  46890. * The Physically based material base class of BJS.
  46891. *
  46892. * This offers the main features of a standard PBR material.
  46893. * For more information, please refer to the documentation :
  46894. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46895. */
  46896. export abstract class PBRBaseMaterial extends PushMaterial {
  46897. /**
  46898. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46899. */
  46900. static readonly PBRMATERIAL_OPAQUE: number;
  46901. /**
  46902. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46903. */
  46904. static readonly PBRMATERIAL_ALPHATEST: number;
  46905. /**
  46906. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46907. */
  46908. static readonly PBRMATERIAL_ALPHABLEND: number;
  46909. /**
  46910. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46911. * They are also discarded below the alpha cutoff threshold to improve performances.
  46912. */
  46913. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46914. /**
  46915. * Defines the default value of how much AO map is occluding the analytical lights
  46916. * (point spot...).
  46917. */
  46918. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46919. /**
  46920. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46921. */
  46922. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46923. /**
  46924. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46925. * to enhance interoperability with other engines.
  46926. */
  46927. static readonly LIGHTFALLOFF_GLTF: number;
  46928. /**
  46929. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46930. * to enhance interoperability with other materials.
  46931. */
  46932. static readonly LIGHTFALLOFF_STANDARD: number;
  46933. /**
  46934. * Intensity of the direct lights e.g. the four lights available in your scene.
  46935. * This impacts both the direct diffuse and specular highlights.
  46936. */
  46937. protected _directIntensity: number;
  46938. /**
  46939. * Intensity of the emissive part of the material.
  46940. * This helps controlling the emissive effect without modifying the emissive color.
  46941. */
  46942. protected _emissiveIntensity: number;
  46943. /**
  46944. * Intensity of the environment e.g. how much the environment will light the object
  46945. * either through harmonics for rough material or through the refelction for shiny ones.
  46946. */
  46947. protected _environmentIntensity: number;
  46948. /**
  46949. * This is a special control allowing the reduction of the specular highlights coming from the
  46950. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46951. */
  46952. protected _specularIntensity: number;
  46953. /**
  46954. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46955. */
  46956. private _lightingInfos;
  46957. /**
  46958. * Debug Control allowing disabling the bump map on this material.
  46959. */
  46960. protected _disableBumpMap: boolean;
  46961. /**
  46962. * AKA Diffuse Texture in standard nomenclature.
  46963. */
  46964. protected _albedoTexture: Nullable<BaseTexture>;
  46965. /**
  46966. * AKA Occlusion Texture in other nomenclature.
  46967. */
  46968. protected _ambientTexture: Nullable<BaseTexture>;
  46969. /**
  46970. * AKA Occlusion Texture Intensity in other nomenclature.
  46971. */
  46972. protected _ambientTextureStrength: number;
  46973. /**
  46974. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46975. * 1 means it completely occludes it
  46976. * 0 mean it has no impact
  46977. */
  46978. protected _ambientTextureImpactOnAnalyticalLights: number;
  46979. /**
  46980. * Stores the alpha values in a texture.
  46981. */
  46982. protected _opacityTexture: Nullable<BaseTexture>;
  46983. /**
  46984. * Stores the reflection values in a texture.
  46985. */
  46986. protected _reflectionTexture: Nullable<BaseTexture>;
  46987. /**
  46988. * Stores the emissive values in a texture.
  46989. */
  46990. protected _emissiveTexture: Nullable<BaseTexture>;
  46991. /**
  46992. * AKA Specular texture in other nomenclature.
  46993. */
  46994. protected _reflectivityTexture: Nullable<BaseTexture>;
  46995. /**
  46996. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46997. */
  46998. protected _metallicTexture: Nullable<BaseTexture>;
  46999. /**
  47000. * Specifies the metallic scalar of the metallic/roughness workflow.
  47001. * Can also be used to scale the metalness values of the metallic texture.
  47002. */
  47003. protected _metallic: Nullable<number>;
  47004. /**
  47005. * Specifies the roughness scalar of the metallic/roughness workflow.
  47006. * Can also be used to scale the roughness values of the metallic texture.
  47007. */
  47008. protected _roughness: Nullable<number>;
  47009. /**
  47010. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47011. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47012. */
  47013. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47014. /**
  47015. * Stores surface normal data used to displace a mesh in a texture.
  47016. */
  47017. protected _bumpTexture: Nullable<BaseTexture>;
  47018. /**
  47019. * Stores the pre-calculated light information of a mesh in a texture.
  47020. */
  47021. protected _lightmapTexture: Nullable<BaseTexture>;
  47022. /**
  47023. * The color of a material in ambient lighting.
  47024. */
  47025. protected _ambientColor: Color3;
  47026. /**
  47027. * AKA Diffuse Color in other nomenclature.
  47028. */
  47029. protected _albedoColor: Color3;
  47030. /**
  47031. * AKA Specular Color in other nomenclature.
  47032. */
  47033. protected _reflectivityColor: Color3;
  47034. /**
  47035. * The color applied when light is reflected from a material.
  47036. */
  47037. protected _reflectionColor: Color3;
  47038. /**
  47039. * The color applied when light is emitted from a material.
  47040. */
  47041. protected _emissiveColor: Color3;
  47042. /**
  47043. * AKA Glossiness in other nomenclature.
  47044. */
  47045. protected _microSurface: number;
  47046. /**
  47047. * Specifies that the material will use the light map as a show map.
  47048. */
  47049. protected _useLightmapAsShadowmap: boolean;
  47050. /**
  47051. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47052. * makes the reflect vector face the model (under horizon).
  47053. */
  47054. protected _useHorizonOcclusion: boolean;
  47055. /**
  47056. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47057. * too much the area relying on ambient texture to define their ambient occlusion.
  47058. */
  47059. protected _useRadianceOcclusion: boolean;
  47060. /**
  47061. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47062. */
  47063. protected _useAlphaFromAlbedoTexture: boolean;
  47064. /**
  47065. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47066. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47067. */
  47068. protected _useSpecularOverAlpha: boolean;
  47069. /**
  47070. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47071. */
  47072. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47073. /**
  47074. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47075. */
  47076. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47077. /**
  47078. * Specifies if the metallic texture contains the roughness information in its green channel.
  47079. */
  47080. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47081. /**
  47082. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47083. */
  47084. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47085. /**
  47086. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47087. */
  47088. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47089. /**
  47090. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47091. */
  47092. protected _useAmbientInGrayScale: boolean;
  47093. /**
  47094. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47095. * The material will try to infer what glossiness each pixel should be.
  47096. */
  47097. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47098. /**
  47099. * Defines the falloff type used in this material.
  47100. * It by default is Physical.
  47101. */
  47102. protected _lightFalloff: number;
  47103. /**
  47104. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47105. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47106. */
  47107. protected _useRadianceOverAlpha: boolean;
  47108. /**
  47109. * Allows using an object space normal map (instead of tangent space).
  47110. */
  47111. protected _useObjectSpaceNormalMap: boolean;
  47112. /**
  47113. * Allows using the bump map in parallax mode.
  47114. */
  47115. protected _useParallax: boolean;
  47116. /**
  47117. * Allows using the bump map in parallax occlusion mode.
  47118. */
  47119. protected _useParallaxOcclusion: boolean;
  47120. /**
  47121. * Controls the scale bias of the parallax mode.
  47122. */
  47123. protected _parallaxScaleBias: number;
  47124. /**
  47125. * If sets to true, disables all the lights affecting the material.
  47126. */
  47127. protected _disableLighting: boolean;
  47128. /**
  47129. * Number of Simultaneous lights allowed on the material.
  47130. */
  47131. protected _maxSimultaneousLights: number;
  47132. /**
  47133. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47134. */
  47135. protected _invertNormalMapX: boolean;
  47136. /**
  47137. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47138. */
  47139. protected _invertNormalMapY: boolean;
  47140. /**
  47141. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47142. */
  47143. protected _twoSidedLighting: boolean;
  47144. /**
  47145. * Defines the alpha limits in alpha test mode.
  47146. */
  47147. protected _alphaCutOff: number;
  47148. /**
  47149. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47150. */
  47151. protected _forceAlphaTest: boolean;
  47152. /**
  47153. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47154. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47155. */
  47156. protected _useAlphaFresnel: boolean;
  47157. /**
  47158. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47159. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47160. */
  47161. protected _useLinearAlphaFresnel: boolean;
  47162. /**
  47163. * The transparency mode of the material.
  47164. */
  47165. protected _transparencyMode: Nullable<number>;
  47166. /**
  47167. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47168. * from cos thetav and roughness:
  47169. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47170. */
  47171. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47172. /**
  47173. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47174. */
  47175. protected _forceIrradianceInFragment: boolean;
  47176. /**
  47177. * Force normal to face away from face.
  47178. */
  47179. protected _forceNormalForward: boolean;
  47180. /**
  47181. * Enables specular anti aliasing in the PBR shader.
  47182. * It will both interacts on the Geometry for analytical and IBL lighting.
  47183. * It also prefilter the roughness map based on the bump values.
  47184. */
  47185. protected _enableSpecularAntiAliasing: boolean;
  47186. /**
  47187. * Default configuration related to image processing available in the PBR Material.
  47188. */
  47189. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47190. /**
  47191. * Keep track of the image processing observer to allow dispose and replace.
  47192. */
  47193. private _imageProcessingObserver;
  47194. /**
  47195. * Attaches a new image processing configuration to the PBR Material.
  47196. * @param configuration
  47197. */
  47198. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47199. /**
  47200. * Stores the available render targets.
  47201. */
  47202. private _renderTargets;
  47203. /**
  47204. * Sets the global ambient color for the material used in lighting calculations.
  47205. */
  47206. private _globalAmbientColor;
  47207. /**
  47208. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47209. */
  47210. private _useLogarithmicDepth;
  47211. /**
  47212. * If set to true, no lighting calculations will be applied.
  47213. */
  47214. private _unlit;
  47215. private _debugMode;
  47216. /**
  47217. * @hidden
  47218. * This is reserved for the inspector.
  47219. * Defines the material debug mode.
  47220. * It helps seeing only some components of the material while troubleshooting.
  47221. */
  47222. debugMode: number;
  47223. /**
  47224. * @hidden
  47225. * This is reserved for the inspector.
  47226. * Specify from where on screen the debug mode should start.
  47227. * The value goes from -1 (full screen) to 1 (not visible)
  47228. * It helps with side by side comparison against the final render
  47229. * This defaults to -1
  47230. */
  47231. private debugLimit;
  47232. /**
  47233. * @hidden
  47234. * This is reserved for the inspector.
  47235. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47236. * You can use the factor to better multiply the final value.
  47237. */
  47238. private debugFactor;
  47239. /**
  47240. * Defines the clear coat layer parameters for the material.
  47241. */
  47242. readonly clearCoat: PBRClearCoatConfiguration;
  47243. /**
  47244. * Defines the anisotropic parameters for the material.
  47245. */
  47246. readonly anisotropy: PBRAnisotropicConfiguration;
  47247. /**
  47248. * Defines the BRDF parameters for the material.
  47249. */
  47250. readonly brdf: PBRBRDFConfiguration;
  47251. /**
  47252. * Defines the Sheen parameters for the material.
  47253. */
  47254. readonly sheen: PBRSheenConfiguration;
  47255. /**
  47256. * Defines the SubSurface parameters for the material.
  47257. */
  47258. readonly subSurface: PBRSubSurfaceConfiguration;
  47259. /**
  47260. * Custom callback helping to override the default shader used in the material.
  47261. */
  47262. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47263. /**
  47264. * Instantiates a new PBRMaterial instance.
  47265. *
  47266. * @param name The material name
  47267. * @param scene The scene the material will be use in.
  47268. */
  47269. constructor(name: string, scene: Scene);
  47270. /**
  47271. * Gets a boolean indicating that current material needs to register RTT
  47272. */
  47273. readonly hasRenderTargetTextures: boolean;
  47274. /**
  47275. * Gets the name of the material class.
  47276. */
  47277. getClassName(): string;
  47278. /**
  47279. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47280. */
  47281. /**
  47282. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47283. */
  47284. useLogarithmicDepth: boolean;
  47285. /**
  47286. * Gets the current transparency mode.
  47287. */
  47288. /**
  47289. * Sets the transparency mode of the material.
  47290. *
  47291. * | Value | Type | Description |
  47292. * | ----- | ----------------------------------- | ----------- |
  47293. * | 0 | OPAQUE | |
  47294. * | 1 | ALPHATEST | |
  47295. * | 2 | ALPHABLEND | |
  47296. * | 3 | ALPHATESTANDBLEND | |
  47297. *
  47298. */
  47299. transparencyMode: Nullable<number>;
  47300. /**
  47301. * Returns true if alpha blending should be disabled.
  47302. */
  47303. private readonly _disableAlphaBlending;
  47304. /**
  47305. * Specifies whether or not this material should be rendered in alpha blend mode.
  47306. */
  47307. needAlphaBlending(): boolean;
  47308. /**
  47309. * Specifies if the mesh will require alpha blending.
  47310. * @param mesh - BJS mesh.
  47311. */
  47312. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47313. /**
  47314. * Specifies whether or not this material should be rendered in alpha test mode.
  47315. */
  47316. needAlphaTesting(): boolean;
  47317. /**
  47318. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47319. */
  47320. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47321. /**
  47322. * Gets the texture used for the alpha test.
  47323. */
  47324. getAlphaTestTexture(): Nullable<BaseTexture>;
  47325. /**
  47326. * Specifies that the submesh is ready to be used.
  47327. * @param mesh - BJS mesh.
  47328. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47329. * @param useInstances - Specifies that instances should be used.
  47330. * @returns - boolean indicating that the submesh is ready or not.
  47331. */
  47332. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47333. /**
  47334. * Specifies if the material uses metallic roughness workflow.
  47335. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47336. */
  47337. isMetallicWorkflow(): boolean;
  47338. private _prepareEffect;
  47339. private _prepareDefines;
  47340. /**
  47341. * Force shader compilation
  47342. */
  47343. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47344. clipPlane: boolean;
  47345. }>): void;
  47346. /**
  47347. * Initializes the uniform buffer layout for the shader.
  47348. */
  47349. buildUniformLayout(): void;
  47350. /**
  47351. * Unbinds the material from the mesh
  47352. */
  47353. unbind(): void;
  47354. /**
  47355. * Binds the submesh data.
  47356. * @param world - The world matrix.
  47357. * @param mesh - The BJS mesh.
  47358. * @param subMesh - A submesh of the BJS mesh.
  47359. */
  47360. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47361. /**
  47362. * Returns the animatable textures.
  47363. * @returns - Array of animatable textures.
  47364. */
  47365. getAnimatables(): IAnimatable[];
  47366. /**
  47367. * Returns the texture used for reflections.
  47368. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47369. */
  47370. private _getReflectionTexture;
  47371. /**
  47372. * Returns an array of the actively used textures.
  47373. * @returns - Array of BaseTextures
  47374. */
  47375. getActiveTextures(): BaseTexture[];
  47376. /**
  47377. * Checks to see if a texture is used in the material.
  47378. * @param texture - Base texture to use.
  47379. * @returns - Boolean specifying if a texture is used in the material.
  47380. */
  47381. hasTexture(texture: BaseTexture): boolean;
  47382. /**
  47383. * Disposes the resources of the material.
  47384. * @param forceDisposeEffect - Forces the disposal of effects.
  47385. * @param forceDisposeTextures - Forces the disposal of all textures.
  47386. */
  47387. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47388. }
  47389. }
  47390. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47391. import { Nullable } from "babylonjs/types";
  47392. import { Scene } from "babylonjs/scene";
  47393. import { Color3 } from "babylonjs/Maths/math";
  47394. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47395. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47397. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47398. /**
  47399. * The Physically based material of BJS.
  47400. *
  47401. * This offers the main features of a standard PBR material.
  47402. * For more information, please refer to the documentation :
  47403. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47404. */
  47405. export class PBRMaterial extends PBRBaseMaterial {
  47406. /**
  47407. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47408. */
  47409. static readonly PBRMATERIAL_OPAQUE: number;
  47410. /**
  47411. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47412. */
  47413. static readonly PBRMATERIAL_ALPHATEST: number;
  47414. /**
  47415. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47416. */
  47417. static readonly PBRMATERIAL_ALPHABLEND: number;
  47418. /**
  47419. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47420. * They are also discarded below the alpha cutoff threshold to improve performances.
  47421. */
  47422. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47423. /**
  47424. * Defines the default value of how much AO map is occluding the analytical lights
  47425. * (point spot...).
  47426. */
  47427. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47428. /**
  47429. * Intensity of the direct lights e.g. the four lights available in your scene.
  47430. * This impacts both the direct diffuse and specular highlights.
  47431. */
  47432. directIntensity: number;
  47433. /**
  47434. * Intensity of the emissive part of the material.
  47435. * This helps controlling the emissive effect without modifying the emissive color.
  47436. */
  47437. emissiveIntensity: number;
  47438. /**
  47439. * Intensity of the environment e.g. how much the environment will light the object
  47440. * either through harmonics for rough material or through the refelction for shiny ones.
  47441. */
  47442. environmentIntensity: number;
  47443. /**
  47444. * This is a special control allowing the reduction of the specular highlights coming from the
  47445. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47446. */
  47447. specularIntensity: number;
  47448. /**
  47449. * Debug Control allowing disabling the bump map on this material.
  47450. */
  47451. disableBumpMap: boolean;
  47452. /**
  47453. * AKA Diffuse Texture in standard nomenclature.
  47454. */
  47455. albedoTexture: BaseTexture;
  47456. /**
  47457. * AKA Occlusion Texture in other nomenclature.
  47458. */
  47459. ambientTexture: BaseTexture;
  47460. /**
  47461. * AKA Occlusion Texture Intensity in other nomenclature.
  47462. */
  47463. ambientTextureStrength: number;
  47464. /**
  47465. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47466. * 1 means it completely occludes it
  47467. * 0 mean it has no impact
  47468. */
  47469. ambientTextureImpactOnAnalyticalLights: number;
  47470. /**
  47471. * Stores the alpha values in a texture.
  47472. */
  47473. opacityTexture: BaseTexture;
  47474. /**
  47475. * Stores the reflection values in a texture.
  47476. */
  47477. reflectionTexture: Nullable<BaseTexture>;
  47478. /**
  47479. * Stores the emissive values in a texture.
  47480. */
  47481. emissiveTexture: BaseTexture;
  47482. /**
  47483. * AKA Specular texture in other nomenclature.
  47484. */
  47485. reflectivityTexture: BaseTexture;
  47486. /**
  47487. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47488. */
  47489. metallicTexture: BaseTexture;
  47490. /**
  47491. * Specifies the metallic scalar of the metallic/roughness workflow.
  47492. * Can also be used to scale the metalness values of the metallic texture.
  47493. */
  47494. metallic: Nullable<number>;
  47495. /**
  47496. * Specifies the roughness scalar of the metallic/roughness workflow.
  47497. * Can also be used to scale the roughness values of the metallic texture.
  47498. */
  47499. roughness: Nullable<number>;
  47500. /**
  47501. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47502. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47503. */
  47504. microSurfaceTexture: BaseTexture;
  47505. /**
  47506. * Stores surface normal data used to displace a mesh in a texture.
  47507. */
  47508. bumpTexture: BaseTexture;
  47509. /**
  47510. * Stores the pre-calculated light information of a mesh in a texture.
  47511. */
  47512. lightmapTexture: BaseTexture;
  47513. /**
  47514. * Stores the refracted light information in a texture.
  47515. */
  47516. refractionTexture: Nullable<BaseTexture>;
  47517. /**
  47518. * The color of a material in ambient lighting.
  47519. */
  47520. ambientColor: Color3;
  47521. /**
  47522. * AKA Diffuse Color in other nomenclature.
  47523. */
  47524. albedoColor: Color3;
  47525. /**
  47526. * AKA Specular Color in other nomenclature.
  47527. */
  47528. reflectivityColor: Color3;
  47529. /**
  47530. * The color reflected from the material.
  47531. */
  47532. reflectionColor: Color3;
  47533. /**
  47534. * The color emitted from the material.
  47535. */
  47536. emissiveColor: Color3;
  47537. /**
  47538. * AKA Glossiness in other nomenclature.
  47539. */
  47540. microSurface: number;
  47541. /**
  47542. * source material index of refraction (IOR)' / 'destination material IOR.
  47543. */
  47544. indexOfRefraction: number;
  47545. /**
  47546. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47547. */
  47548. invertRefractionY: boolean;
  47549. /**
  47550. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47551. * Materials half opaque for instance using refraction could benefit from this control.
  47552. */
  47553. linkRefractionWithTransparency: boolean;
  47554. /**
  47555. * If true, the light map contains occlusion information instead of lighting info.
  47556. */
  47557. useLightmapAsShadowmap: boolean;
  47558. /**
  47559. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47560. */
  47561. useAlphaFromAlbedoTexture: boolean;
  47562. /**
  47563. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47564. */
  47565. forceAlphaTest: boolean;
  47566. /**
  47567. * Defines the alpha limits in alpha test mode.
  47568. */
  47569. alphaCutOff: number;
  47570. /**
  47571. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47572. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47573. */
  47574. useSpecularOverAlpha: boolean;
  47575. /**
  47576. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47577. */
  47578. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47579. /**
  47580. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47581. */
  47582. useRoughnessFromMetallicTextureAlpha: boolean;
  47583. /**
  47584. * Specifies if the metallic texture contains the roughness information in its green channel.
  47585. */
  47586. useRoughnessFromMetallicTextureGreen: boolean;
  47587. /**
  47588. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47589. */
  47590. useMetallnessFromMetallicTextureBlue: boolean;
  47591. /**
  47592. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47593. */
  47594. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47595. /**
  47596. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47597. */
  47598. useAmbientInGrayScale: boolean;
  47599. /**
  47600. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47601. * The material will try to infer what glossiness each pixel should be.
  47602. */
  47603. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47604. /**
  47605. * BJS is using an harcoded light falloff based on a manually sets up range.
  47606. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47607. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47608. */
  47609. /**
  47610. * BJS is using an harcoded light falloff based on a manually sets up range.
  47611. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47612. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47613. */
  47614. usePhysicalLightFalloff: boolean;
  47615. /**
  47616. * In order to support the falloff compatibility with gltf, a special mode has been added
  47617. * to reproduce the gltf light falloff.
  47618. */
  47619. /**
  47620. * In order to support the falloff compatibility with gltf, a special mode has been added
  47621. * to reproduce the gltf light falloff.
  47622. */
  47623. useGLTFLightFalloff: boolean;
  47624. /**
  47625. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47626. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47627. */
  47628. useRadianceOverAlpha: boolean;
  47629. /**
  47630. * Allows using an object space normal map (instead of tangent space).
  47631. */
  47632. useObjectSpaceNormalMap: boolean;
  47633. /**
  47634. * Allows using the bump map in parallax mode.
  47635. */
  47636. useParallax: boolean;
  47637. /**
  47638. * Allows using the bump map in parallax occlusion mode.
  47639. */
  47640. useParallaxOcclusion: boolean;
  47641. /**
  47642. * Controls the scale bias of the parallax mode.
  47643. */
  47644. parallaxScaleBias: number;
  47645. /**
  47646. * If sets to true, disables all the lights affecting the material.
  47647. */
  47648. disableLighting: boolean;
  47649. /**
  47650. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47651. */
  47652. forceIrradianceInFragment: boolean;
  47653. /**
  47654. * Number of Simultaneous lights allowed on the material.
  47655. */
  47656. maxSimultaneousLights: number;
  47657. /**
  47658. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47659. */
  47660. invertNormalMapX: boolean;
  47661. /**
  47662. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47663. */
  47664. invertNormalMapY: boolean;
  47665. /**
  47666. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47667. */
  47668. twoSidedLighting: boolean;
  47669. /**
  47670. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47671. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47672. */
  47673. useAlphaFresnel: boolean;
  47674. /**
  47675. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47676. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47677. */
  47678. useLinearAlphaFresnel: boolean;
  47679. /**
  47680. * Let user defines the brdf lookup texture used for IBL.
  47681. * A default 8bit version is embedded but you could point at :
  47682. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47683. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47684. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47685. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47686. */
  47687. environmentBRDFTexture: Nullable<BaseTexture>;
  47688. /**
  47689. * Force normal to face away from face.
  47690. */
  47691. forceNormalForward: boolean;
  47692. /**
  47693. * Enables specular anti aliasing in the PBR shader.
  47694. * It will both interacts on the Geometry for analytical and IBL lighting.
  47695. * It also prefilter the roughness map based on the bump values.
  47696. */
  47697. enableSpecularAntiAliasing: boolean;
  47698. /**
  47699. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47700. * makes the reflect vector face the model (under horizon).
  47701. */
  47702. useHorizonOcclusion: boolean;
  47703. /**
  47704. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47705. * too much the area relying on ambient texture to define their ambient occlusion.
  47706. */
  47707. useRadianceOcclusion: boolean;
  47708. /**
  47709. * If set to true, no lighting calculations will be applied.
  47710. */
  47711. unlit: boolean;
  47712. /**
  47713. * Gets the image processing configuration used either in this material.
  47714. */
  47715. /**
  47716. * Sets the Default image processing configuration used either in the this material.
  47717. *
  47718. * If sets to null, the scene one is in use.
  47719. */
  47720. imageProcessingConfiguration: ImageProcessingConfiguration;
  47721. /**
  47722. * Gets wether the color curves effect is enabled.
  47723. */
  47724. /**
  47725. * Sets wether the color curves effect is enabled.
  47726. */
  47727. cameraColorCurvesEnabled: boolean;
  47728. /**
  47729. * Gets wether the color grading effect is enabled.
  47730. */
  47731. /**
  47732. * Gets wether the color grading effect is enabled.
  47733. */
  47734. cameraColorGradingEnabled: boolean;
  47735. /**
  47736. * Gets wether tonemapping is enabled or not.
  47737. */
  47738. /**
  47739. * Sets wether tonemapping is enabled or not
  47740. */
  47741. cameraToneMappingEnabled: boolean;
  47742. /**
  47743. * The camera exposure used on this material.
  47744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47745. * This corresponds to a photographic exposure.
  47746. */
  47747. /**
  47748. * The camera exposure used on this material.
  47749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47750. * This corresponds to a photographic exposure.
  47751. */
  47752. cameraExposure: number;
  47753. /**
  47754. * Gets The camera contrast used on this material.
  47755. */
  47756. /**
  47757. * Sets The camera contrast used on this material.
  47758. */
  47759. cameraContrast: number;
  47760. /**
  47761. * Gets the Color Grading 2D Lookup Texture.
  47762. */
  47763. /**
  47764. * Sets the Color Grading 2D Lookup Texture.
  47765. */
  47766. cameraColorGradingTexture: Nullable<BaseTexture>;
  47767. /**
  47768. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47769. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47770. * 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;
  47771. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47772. */
  47773. /**
  47774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47776. * 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;
  47777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47778. */
  47779. cameraColorCurves: Nullable<ColorCurves>;
  47780. /**
  47781. * Instantiates a new PBRMaterial instance.
  47782. *
  47783. * @param name The material name
  47784. * @param scene The scene the material will be use in.
  47785. */
  47786. constructor(name: string, scene: Scene);
  47787. /**
  47788. * Returns the name of this material class.
  47789. */
  47790. getClassName(): string;
  47791. /**
  47792. * Makes a duplicate of the current material.
  47793. * @param name - name to use for the new material.
  47794. */
  47795. clone(name: string): PBRMaterial;
  47796. /**
  47797. * Serializes this PBR Material.
  47798. * @returns - An object with the serialized material.
  47799. */
  47800. serialize(): any;
  47801. /**
  47802. * Parses a PBR Material from a serialized object.
  47803. * @param source - Serialized object.
  47804. * @param scene - BJS scene instance.
  47805. * @param rootUrl - url for the scene object
  47806. * @returns - PBRMaterial
  47807. */
  47808. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47809. }
  47810. }
  47811. declare module "babylonjs/Misc/dds" {
  47812. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47813. import { Engine } from "babylonjs/Engines/engine";
  47814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47815. import { Nullable } from "babylonjs/types";
  47816. import { Scene } from "babylonjs/scene";
  47817. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47818. /**
  47819. * Direct draw surface info
  47820. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47821. */
  47822. export interface DDSInfo {
  47823. /**
  47824. * Width of the texture
  47825. */
  47826. width: number;
  47827. /**
  47828. * Width of the texture
  47829. */
  47830. height: number;
  47831. /**
  47832. * Number of Mipmaps for the texture
  47833. * @see https://en.wikipedia.org/wiki/Mipmap
  47834. */
  47835. mipmapCount: number;
  47836. /**
  47837. * If the textures format is a known fourCC format
  47838. * @see https://www.fourcc.org/
  47839. */
  47840. isFourCC: boolean;
  47841. /**
  47842. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47843. */
  47844. isRGB: boolean;
  47845. /**
  47846. * If the texture is a lumincance format
  47847. */
  47848. isLuminance: boolean;
  47849. /**
  47850. * If this is a cube texture
  47851. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47852. */
  47853. isCube: boolean;
  47854. /**
  47855. * If the texture is a compressed format eg. FOURCC_DXT1
  47856. */
  47857. isCompressed: boolean;
  47858. /**
  47859. * The dxgiFormat of the texture
  47860. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47861. */
  47862. dxgiFormat: number;
  47863. /**
  47864. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47865. */
  47866. textureType: number;
  47867. /**
  47868. * Sphericle polynomial created for the dds texture
  47869. */
  47870. sphericalPolynomial?: SphericalPolynomial;
  47871. }
  47872. /**
  47873. * Class used to provide DDS decompression tools
  47874. */
  47875. export class DDSTools {
  47876. /**
  47877. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47878. */
  47879. static StoreLODInAlphaChannel: boolean;
  47880. /**
  47881. * Gets DDS information from an array buffer
  47882. * @param arrayBuffer defines the array buffer to read data from
  47883. * @returns the DDS information
  47884. */
  47885. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47886. private static _FloatView;
  47887. private static _Int32View;
  47888. private static _ToHalfFloat;
  47889. private static _FromHalfFloat;
  47890. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47891. private static _GetHalfFloatRGBAArrayBuffer;
  47892. private static _GetFloatRGBAArrayBuffer;
  47893. private static _GetFloatAsUIntRGBAArrayBuffer;
  47894. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47895. private static _GetRGBAArrayBuffer;
  47896. private static _ExtractLongWordOrder;
  47897. private static _GetRGBArrayBuffer;
  47898. private static _GetLuminanceArrayBuffer;
  47899. /**
  47900. * Uploads DDS Levels to a Babylon Texture
  47901. * @hidden
  47902. */
  47903. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47904. }
  47905. module "babylonjs/Engines/engine" {
  47906. interface Engine {
  47907. /**
  47908. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47909. * @param rootUrl defines the url where the file to load is located
  47910. * @param scene defines the current scene
  47911. * @param lodScale defines scale to apply to the mip map selection
  47912. * @param lodOffset defines offset to apply to the mip map selection
  47913. * @param onLoad defines an optional callback raised when the texture is loaded
  47914. * @param onError defines an optional callback raised if there is an issue to load the texture
  47915. * @param format defines the format of the data
  47916. * @param forcedExtension defines the extension to use to pick the right loader
  47917. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47918. * @returns the cube texture as an InternalTexture
  47919. */
  47920. 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;
  47921. }
  47922. }
  47923. }
  47924. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47925. import { Nullable } from "babylonjs/types";
  47926. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47927. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47928. /**
  47929. * Implementation of the DDS Texture Loader.
  47930. * @hidden
  47931. */
  47932. export class _DDSTextureLoader implements IInternalTextureLoader {
  47933. /**
  47934. * Defines wether the loader supports cascade loading the different faces.
  47935. */
  47936. readonly supportCascades: boolean;
  47937. /**
  47938. * This returns if the loader support the current file information.
  47939. * @param extension defines the file extension of the file being loaded
  47940. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47941. * @param fallback defines the fallback internal texture if any
  47942. * @param isBase64 defines whether the texture is encoded as a base64
  47943. * @param isBuffer defines whether the texture data are stored as a buffer
  47944. * @returns true if the loader can load the specified file
  47945. */
  47946. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47947. /**
  47948. * Transform the url before loading if required.
  47949. * @param rootUrl the url of the texture
  47950. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47951. * @returns the transformed texture
  47952. */
  47953. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47954. /**
  47955. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47956. * @param rootUrl the url of the texture
  47957. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47958. * @returns the fallback texture
  47959. */
  47960. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47961. /**
  47962. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47963. * @param data contains the texture data
  47964. * @param texture defines the BabylonJS internal texture
  47965. * @param createPolynomials will be true if polynomials have been requested
  47966. * @param onLoad defines the callback to trigger once the texture is ready
  47967. * @param onError defines the callback to trigger in case of error
  47968. */
  47969. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47970. /**
  47971. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47972. * @param data contains the texture data
  47973. * @param texture defines the BabylonJS internal texture
  47974. * @param callback defines the method to call once ready to upload
  47975. */
  47976. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47977. }
  47978. }
  47979. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47980. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47981. /** @hidden */
  47982. export var rgbdEncodePixelShader: {
  47983. name: string;
  47984. shader: string;
  47985. };
  47986. }
  47987. declare module "babylonjs/Misc/environmentTextureTools" {
  47988. import { Nullable } from "babylonjs/types";
  47989. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47990. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47991. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47992. import "babylonjs/Engines/Extensions/engine.renderTarget";
  47993. import "babylonjs/Shaders/rgbdEncode.fragment";
  47994. import "babylonjs/Shaders/rgbdDecode.fragment";
  47995. /**
  47996. * Raw texture data and descriptor sufficient for WebGL texture upload
  47997. */
  47998. export interface EnvironmentTextureInfo {
  47999. /**
  48000. * Version of the environment map
  48001. */
  48002. version: number;
  48003. /**
  48004. * Width of image
  48005. */
  48006. width: number;
  48007. /**
  48008. * Irradiance information stored in the file.
  48009. */
  48010. irradiance: any;
  48011. /**
  48012. * Specular information stored in the file.
  48013. */
  48014. specular: any;
  48015. }
  48016. /**
  48017. * Sets of helpers addressing the serialization and deserialization of environment texture
  48018. * stored in a BabylonJS env file.
  48019. * Those files are usually stored as .env files.
  48020. */
  48021. export class EnvironmentTextureTools {
  48022. /**
  48023. * Magic number identifying the env file.
  48024. */
  48025. private static _MagicBytes;
  48026. /**
  48027. * Gets the environment info from an env file.
  48028. * @param data The array buffer containing the .env bytes.
  48029. * @returns the environment file info (the json header) if successfully parsed.
  48030. */
  48031. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48032. /**
  48033. * Creates an environment texture from a loaded cube texture.
  48034. * @param texture defines the cube texture to convert in env file
  48035. * @return a promise containing the environment data if succesfull.
  48036. */
  48037. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48038. /**
  48039. * Creates a JSON representation of the spherical data.
  48040. * @param texture defines the texture containing the polynomials
  48041. * @return the JSON representation of the spherical info
  48042. */
  48043. private static _CreateEnvTextureIrradiance;
  48044. /**
  48045. * Uploads the texture info contained in the env file to the GPU.
  48046. * @param texture defines the internal texture to upload to
  48047. * @param arrayBuffer defines the buffer cotaining the data to load
  48048. * @param info defines the texture info retrieved through the GetEnvInfo method
  48049. * @returns a promise
  48050. */
  48051. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48052. /**
  48053. * Uploads the levels of image data to the GPU.
  48054. * @param texture defines the internal texture to upload to
  48055. * @param imageData defines the array buffer views of image data [mipmap][face]
  48056. * @returns a promise
  48057. */
  48058. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48059. /**
  48060. * Uploads spherical polynomials information to the texture.
  48061. * @param texture defines the texture we are trying to upload the information to
  48062. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48063. */
  48064. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48065. /** @hidden */
  48066. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48067. }
  48068. }
  48069. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48070. import { Nullable } from "babylonjs/types";
  48071. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48072. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48073. /**
  48074. * Implementation of the ENV Texture Loader.
  48075. * @hidden
  48076. */
  48077. export class _ENVTextureLoader implements IInternalTextureLoader {
  48078. /**
  48079. * Defines wether the loader supports cascade loading the different faces.
  48080. */
  48081. readonly supportCascades: boolean;
  48082. /**
  48083. * This returns if the loader support the current file information.
  48084. * @param extension defines the file extension of the file being loaded
  48085. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48086. * @param fallback defines the fallback internal texture if any
  48087. * @param isBase64 defines whether the texture is encoded as a base64
  48088. * @param isBuffer defines whether the texture data are stored as a buffer
  48089. * @returns true if the loader can load the specified file
  48090. */
  48091. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48092. /**
  48093. * Transform the url before loading if required.
  48094. * @param rootUrl the url of the texture
  48095. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48096. * @returns the transformed texture
  48097. */
  48098. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48099. /**
  48100. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48101. * @param rootUrl the url of the texture
  48102. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48103. * @returns the fallback texture
  48104. */
  48105. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48106. /**
  48107. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48108. * @param data contains the texture data
  48109. * @param texture defines the BabylonJS internal texture
  48110. * @param createPolynomials will be true if polynomials have been requested
  48111. * @param onLoad defines the callback to trigger once the texture is ready
  48112. * @param onError defines the callback to trigger in case of error
  48113. */
  48114. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48115. /**
  48116. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48117. * @param data contains the texture data
  48118. * @param texture defines the BabylonJS internal texture
  48119. * @param callback defines the method to call once ready to upload
  48120. */
  48121. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48122. }
  48123. }
  48124. declare module "babylonjs/Misc/khronosTextureContainer" {
  48125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48126. /**
  48127. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48128. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48129. */
  48130. export class KhronosTextureContainer {
  48131. /** contents of the KTX container file */
  48132. arrayBuffer: any;
  48133. private static HEADER_LEN;
  48134. private static COMPRESSED_2D;
  48135. private static COMPRESSED_3D;
  48136. private static TEX_2D;
  48137. private static TEX_3D;
  48138. /**
  48139. * Gets the openGL type
  48140. */
  48141. glType: number;
  48142. /**
  48143. * Gets the openGL type size
  48144. */
  48145. glTypeSize: number;
  48146. /**
  48147. * Gets the openGL format
  48148. */
  48149. glFormat: number;
  48150. /**
  48151. * Gets the openGL internal format
  48152. */
  48153. glInternalFormat: number;
  48154. /**
  48155. * Gets the base internal format
  48156. */
  48157. glBaseInternalFormat: number;
  48158. /**
  48159. * Gets image width in pixel
  48160. */
  48161. pixelWidth: number;
  48162. /**
  48163. * Gets image height in pixel
  48164. */
  48165. pixelHeight: number;
  48166. /**
  48167. * Gets image depth in pixels
  48168. */
  48169. pixelDepth: number;
  48170. /**
  48171. * Gets the number of array elements
  48172. */
  48173. numberOfArrayElements: number;
  48174. /**
  48175. * Gets the number of faces
  48176. */
  48177. numberOfFaces: number;
  48178. /**
  48179. * Gets the number of mipmap levels
  48180. */
  48181. numberOfMipmapLevels: number;
  48182. /**
  48183. * Gets the bytes of key value data
  48184. */
  48185. bytesOfKeyValueData: number;
  48186. /**
  48187. * Gets the load type
  48188. */
  48189. loadType: number;
  48190. /**
  48191. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48192. */
  48193. isInvalid: boolean;
  48194. /**
  48195. * Creates a new KhronosTextureContainer
  48196. * @param arrayBuffer contents of the KTX container file
  48197. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48198. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48199. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48200. */
  48201. constructor(
  48202. /** contents of the KTX container file */
  48203. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48204. /**
  48205. * Uploads KTX content to a Babylon Texture.
  48206. * It is assumed that the texture has already been created & is currently bound
  48207. * @hidden
  48208. */
  48209. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48210. private _upload2DCompressedLevels;
  48211. }
  48212. }
  48213. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48214. import { Nullable } from "babylonjs/types";
  48215. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48216. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48217. /**
  48218. * Implementation of the KTX Texture Loader.
  48219. * @hidden
  48220. */
  48221. export class _KTXTextureLoader implements IInternalTextureLoader {
  48222. /**
  48223. * Defines wether the loader supports cascade loading the different faces.
  48224. */
  48225. readonly supportCascades: boolean;
  48226. /**
  48227. * This returns if the loader support the current file information.
  48228. * @param extension defines the file extension of the file being loaded
  48229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48230. * @param fallback defines the fallback internal texture if any
  48231. * @param isBase64 defines whether the texture is encoded as a base64
  48232. * @param isBuffer defines whether the texture data are stored as a buffer
  48233. * @returns true if the loader can load the specified file
  48234. */
  48235. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48236. /**
  48237. * Transform the url before loading if required.
  48238. * @param rootUrl the url of the texture
  48239. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48240. * @returns the transformed texture
  48241. */
  48242. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48243. /**
  48244. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48245. * @param rootUrl the url of the texture
  48246. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48247. * @returns the fallback texture
  48248. */
  48249. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48250. /**
  48251. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48252. * @param data contains the texture data
  48253. * @param texture defines the BabylonJS internal texture
  48254. * @param createPolynomials will be true if polynomials have been requested
  48255. * @param onLoad defines the callback to trigger once the texture is ready
  48256. * @param onError defines the callback to trigger in case of error
  48257. */
  48258. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48259. /**
  48260. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48261. * @param data contains the texture data
  48262. * @param texture defines the BabylonJS internal texture
  48263. * @param callback defines the method to call once ready to upload
  48264. */
  48265. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48266. }
  48267. }
  48268. declare module "babylonjs/Helpers/sceneHelpers" {
  48269. import { Nullable } from "babylonjs/types";
  48270. import { Mesh } from "babylonjs/Meshes/mesh";
  48271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48272. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48273. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48274. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48275. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48276. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48277. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48278. import "babylonjs/Meshes/Builders/boxBuilder";
  48279. /** @hidden */
  48280. export var _forceSceneHelpersToBundle: boolean;
  48281. module "babylonjs/scene" {
  48282. interface Scene {
  48283. /**
  48284. * Creates a default light for the scene.
  48285. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48286. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48287. */
  48288. createDefaultLight(replace?: boolean): void;
  48289. /**
  48290. * Creates a default camera for the scene.
  48291. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48292. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48293. * @param replace has default false, when true replaces the active camera in the scene
  48294. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48295. */
  48296. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48297. /**
  48298. * Creates a default camera and a default light.
  48299. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48300. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48301. * @param replace has the default false, when true replaces the active camera/light in the scene
  48302. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48303. */
  48304. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48305. /**
  48306. * Creates a new sky box
  48307. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48308. * @param environmentTexture defines the texture to use as environment texture
  48309. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48310. * @param scale defines the overall scale of the skybox
  48311. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48312. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48313. * @returns a new mesh holding the sky box
  48314. */
  48315. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48316. /**
  48317. * Creates a new environment
  48318. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48319. * @param options defines the options you can use to configure the environment
  48320. * @returns the new EnvironmentHelper
  48321. */
  48322. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48323. /**
  48324. * Creates a new VREXperienceHelper
  48325. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48326. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48327. * @returns a new VREXperienceHelper
  48328. */
  48329. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48330. /**
  48331. * Creates a new XREXperienceHelper
  48332. * @see http://doc.babylonjs.com/how_to/webxr
  48333. * @returns a promise for a new XREXperienceHelper
  48334. */
  48335. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48336. }
  48337. }
  48338. }
  48339. declare module "babylonjs/Helpers/videoDome" {
  48340. import { Scene } from "babylonjs/scene";
  48341. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48342. import { Mesh } from "babylonjs/Meshes/mesh";
  48343. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48344. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48345. import "babylonjs/Meshes/Builders/sphereBuilder";
  48346. /**
  48347. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48348. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48349. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48350. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48351. */
  48352. export class VideoDome extends TransformNode {
  48353. /**
  48354. * Define the video source as a Monoscopic panoramic 360 video.
  48355. */
  48356. static readonly MODE_MONOSCOPIC: number;
  48357. /**
  48358. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48359. */
  48360. static readonly MODE_TOPBOTTOM: number;
  48361. /**
  48362. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48363. */
  48364. static readonly MODE_SIDEBYSIDE: number;
  48365. private _useDirectMapping;
  48366. /**
  48367. * The video texture being displayed on the sphere
  48368. */
  48369. protected _videoTexture: VideoTexture;
  48370. /**
  48371. * Gets the video texture being displayed on the sphere
  48372. */
  48373. readonly videoTexture: VideoTexture;
  48374. /**
  48375. * The skybox material
  48376. */
  48377. protected _material: BackgroundMaterial;
  48378. /**
  48379. * The surface used for the skybox
  48380. */
  48381. protected _mesh: Mesh;
  48382. /**
  48383. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48384. * Also see the options.resolution property.
  48385. */
  48386. fovMultiplier: number;
  48387. private _videoMode;
  48388. /**
  48389. * Gets or set the current video mode for the video. It can be:
  48390. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48391. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48392. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48393. */
  48394. videoMode: number;
  48395. /**
  48396. * Oberserver used in Stereoscopic VR Mode.
  48397. */
  48398. private _onBeforeCameraRenderObserver;
  48399. /**
  48400. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48401. * @param name Element's name, child elements will append suffixes for their own names.
  48402. * @param urlsOrVideo defines the url(s) or the video element to use
  48403. * @param options An object containing optional or exposed sub element properties
  48404. */
  48405. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48406. resolution?: number;
  48407. clickToPlay?: boolean;
  48408. autoPlay?: boolean;
  48409. loop?: boolean;
  48410. size?: number;
  48411. poster?: string;
  48412. faceForward?: boolean;
  48413. useDirectMapping?: boolean;
  48414. }, scene: Scene);
  48415. private _changeVideoMode;
  48416. /**
  48417. * Releases resources associated with this node.
  48418. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48419. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48420. */
  48421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48422. }
  48423. }
  48424. declare module "babylonjs/Helpers/index" {
  48425. export * from "babylonjs/Helpers/environmentHelper";
  48426. export * from "babylonjs/Helpers/photoDome";
  48427. export * from "babylonjs/Helpers/sceneHelpers";
  48428. export * from "babylonjs/Helpers/videoDome";
  48429. }
  48430. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48431. import { PerfCounter } from "babylonjs/Misc/tools";
  48432. import { IDisposable } from "babylonjs/scene";
  48433. import { Engine } from "babylonjs/Engines/engine";
  48434. /**
  48435. * This class can be used to get instrumentation data from a Babylon engine
  48436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48437. */
  48438. export class EngineInstrumentation implements IDisposable {
  48439. /**
  48440. * Define the instrumented engine.
  48441. */
  48442. engine: Engine;
  48443. private _captureGPUFrameTime;
  48444. private _gpuFrameTimeToken;
  48445. private _gpuFrameTime;
  48446. private _captureShaderCompilationTime;
  48447. private _shaderCompilationTime;
  48448. private _onBeginFrameObserver;
  48449. private _onEndFrameObserver;
  48450. private _onBeforeShaderCompilationObserver;
  48451. private _onAfterShaderCompilationObserver;
  48452. /**
  48453. * Gets the perf counter used for GPU frame time
  48454. */
  48455. readonly gpuFrameTimeCounter: PerfCounter;
  48456. /**
  48457. * Gets the GPU frame time capture status
  48458. */
  48459. /**
  48460. * Enable or disable the GPU frame time capture
  48461. */
  48462. captureGPUFrameTime: boolean;
  48463. /**
  48464. * Gets the perf counter used for shader compilation time
  48465. */
  48466. readonly shaderCompilationTimeCounter: PerfCounter;
  48467. /**
  48468. * Gets the shader compilation time capture status
  48469. */
  48470. /**
  48471. * Enable or disable the shader compilation time capture
  48472. */
  48473. captureShaderCompilationTime: boolean;
  48474. /**
  48475. * Instantiates a new engine instrumentation.
  48476. * This class can be used to get instrumentation data from a Babylon engine
  48477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48478. * @param engine Defines the engine to instrument
  48479. */
  48480. constructor(
  48481. /**
  48482. * Define the instrumented engine.
  48483. */
  48484. engine: Engine);
  48485. /**
  48486. * Dispose and release associated resources.
  48487. */
  48488. dispose(): void;
  48489. }
  48490. }
  48491. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48492. import { PerfCounter } from "babylonjs/Misc/tools";
  48493. import { Scene, IDisposable } from "babylonjs/scene";
  48494. /**
  48495. * This class can be used to get instrumentation data from a Babylon engine
  48496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48497. */
  48498. export class SceneInstrumentation implements IDisposable {
  48499. /**
  48500. * Defines the scene to instrument
  48501. */
  48502. scene: Scene;
  48503. private _captureActiveMeshesEvaluationTime;
  48504. private _activeMeshesEvaluationTime;
  48505. private _captureRenderTargetsRenderTime;
  48506. private _renderTargetsRenderTime;
  48507. private _captureFrameTime;
  48508. private _frameTime;
  48509. private _captureRenderTime;
  48510. private _renderTime;
  48511. private _captureInterFrameTime;
  48512. private _interFrameTime;
  48513. private _captureParticlesRenderTime;
  48514. private _particlesRenderTime;
  48515. private _captureSpritesRenderTime;
  48516. private _spritesRenderTime;
  48517. private _capturePhysicsTime;
  48518. private _physicsTime;
  48519. private _captureAnimationsTime;
  48520. private _animationsTime;
  48521. private _captureCameraRenderTime;
  48522. private _cameraRenderTime;
  48523. private _onBeforeActiveMeshesEvaluationObserver;
  48524. private _onAfterActiveMeshesEvaluationObserver;
  48525. private _onBeforeRenderTargetsRenderObserver;
  48526. private _onAfterRenderTargetsRenderObserver;
  48527. private _onAfterRenderObserver;
  48528. private _onBeforeDrawPhaseObserver;
  48529. private _onAfterDrawPhaseObserver;
  48530. private _onBeforeAnimationsObserver;
  48531. private _onBeforeParticlesRenderingObserver;
  48532. private _onAfterParticlesRenderingObserver;
  48533. private _onBeforeSpritesRenderingObserver;
  48534. private _onAfterSpritesRenderingObserver;
  48535. private _onBeforePhysicsObserver;
  48536. private _onAfterPhysicsObserver;
  48537. private _onAfterAnimationsObserver;
  48538. private _onBeforeCameraRenderObserver;
  48539. private _onAfterCameraRenderObserver;
  48540. /**
  48541. * Gets the perf counter used for active meshes evaluation time
  48542. */
  48543. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48544. /**
  48545. * Gets the active meshes evaluation time capture status
  48546. */
  48547. /**
  48548. * Enable or disable the active meshes evaluation time capture
  48549. */
  48550. captureActiveMeshesEvaluationTime: boolean;
  48551. /**
  48552. * Gets the perf counter used for render targets render time
  48553. */
  48554. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48555. /**
  48556. * Gets the render targets render time capture status
  48557. */
  48558. /**
  48559. * Enable or disable the render targets render time capture
  48560. */
  48561. captureRenderTargetsRenderTime: boolean;
  48562. /**
  48563. * Gets the perf counter used for particles render time
  48564. */
  48565. readonly particlesRenderTimeCounter: PerfCounter;
  48566. /**
  48567. * Gets the particles render time capture status
  48568. */
  48569. /**
  48570. * Enable or disable the particles render time capture
  48571. */
  48572. captureParticlesRenderTime: boolean;
  48573. /**
  48574. * Gets the perf counter used for sprites render time
  48575. */
  48576. readonly spritesRenderTimeCounter: PerfCounter;
  48577. /**
  48578. * Gets the sprites render time capture status
  48579. */
  48580. /**
  48581. * Enable or disable the sprites render time capture
  48582. */
  48583. captureSpritesRenderTime: boolean;
  48584. /**
  48585. * Gets the perf counter used for physics time
  48586. */
  48587. readonly physicsTimeCounter: PerfCounter;
  48588. /**
  48589. * Gets the physics time capture status
  48590. */
  48591. /**
  48592. * Enable or disable the physics time capture
  48593. */
  48594. capturePhysicsTime: boolean;
  48595. /**
  48596. * Gets the perf counter used for animations time
  48597. */
  48598. readonly animationsTimeCounter: PerfCounter;
  48599. /**
  48600. * Gets the animations time capture status
  48601. */
  48602. /**
  48603. * Enable or disable the animations time capture
  48604. */
  48605. captureAnimationsTime: boolean;
  48606. /**
  48607. * Gets the perf counter used for frame time capture
  48608. */
  48609. readonly frameTimeCounter: PerfCounter;
  48610. /**
  48611. * Gets the frame time capture status
  48612. */
  48613. /**
  48614. * Enable or disable the frame time capture
  48615. */
  48616. captureFrameTime: boolean;
  48617. /**
  48618. * Gets the perf counter used for inter-frames time capture
  48619. */
  48620. readonly interFrameTimeCounter: PerfCounter;
  48621. /**
  48622. * Gets the inter-frames time capture status
  48623. */
  48624. /**
  48625. * Enable or disable the inter-frames time capture
  48626. */
  48627. captureInterFrameTime: boolean;
  48628. /**
  48629. * Gets the perf counter used for render time capture
  48630. */
  48631. readonly renderTimeCounter: PerfCounter;
  48632. /**
  48633. * Gets the render time capture status
  48634. */
  48635. /**
  48636. * Enable or disable the render time capture
  48637. */
  48638. captureRenderTime: boolean;
  48639. /**
  48640. * Gets the perf counter used for camera render time capture
  48641. */
  48642. readonly cameraRenderTimeCounter: PerfCounter;
  48643. /**
  48644. * Gets the camera render time capture status
  48645. */
  48646. /**
  48647. * Enable or disable the camera render time capture
  48648. */
  48649. captureCameraRenderTime: boolean;
  48650. /**
  48651. * Gets the perf counter used for draw calls
  48652. */
  48653. readonly drawCallsCounter: PerfCounter;
  48654. /**
  48655. * Instantiates a new scene instrumentation.
  48656. * This class can be used to get instrumentation data from a Babylon engine
  48657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48658. * @param scene Defines the scene to instrument
  48659. */
  48660. constructor(
  48661. /**
  48662. * Defines the scene to instrument
  48663. */
  48664. scene: Scene);
  48665. /**
  48666. * Dispose and release associated resources.
  48667. */
  48668. dispose(): void;
  48669. }
  48670. }
  48671. declare module "babylonjs/Instrumentation/index" {
  48672. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48673. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48674. export * from "babylonjs/Instrumentation/timeToken";
  48675. }
  48676. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48677. /** @hidden */
  48678. export var glowMapGenerationPixelShader: {
  48679. name: string;
  48680. shader: string;
  48681. };
  48682. }
  48683. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48684. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48685. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48686. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48687. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48688. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48689. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48690. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48691. /** @hidden */
  48692. export var glowMapGenerationVertexShader: {
  48693. name: string;
  48694. shader: string;
  48695. };
  48696. }
  48697. declare module "babylonjs/Layers/effectLayer" {
  48698. import { Observable } from "babylonjs/Misc/observable";
  48699. import { Nullable } from "babylonjs/types";
  48700. import { Camera } from "babylonjs/Cameras/camera";
  48701. import { Scene } from "babylonjs/scene";
  48702. import { Color4, ISize } from "babylonjs/Maths/math";
  48703. import { Engine } from "babylonjs/Engines/engine";
  48704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48706. import { Mesh } from "babylonjs/Meshes/mesh";
  48707. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48710. import { Effect } from "babylonjs/Materials/effect";
  48711. import { Material } from "babylonjs/Materials/material";
  48712. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48713. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48714. /**
  48715. * Effect layer options. This helps customizing the behaviour
  48716. * of the effect layer.
  48717. */
  48718. export interface IEffectLayerOptions {
  48719. /**
  48720. * Multiplication factor apply to the canvas size to compute the render target size
  48721. * used to generated the objects (the smaller the faster).
  48722. */
  48723. mainTextureRatio: number;
  48724. /**
  48725. * Enforces a fixed size texture to ensure effect stability across devices.
  48726. */
  48727. mainTextureFixedSize?: number;
  48728. /**
  48729. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48730. */
  48731. alphaBlendingMode: number;
  48732. /**
  48733. * The camera attached to the layer.
  48734. */
  48735. camera: Nullable<Camera>;
  48736. /**
  48737. * The rendering group to draw the layer in.
  48738. */
  48739. renderingGroupId: number;
  48740. }
  48741. /**
  48742. * The effect layer Helps adding post process effect blended with the main pass.
  48743. *
  48744. * This can be for instance use to generate glow or higlight effects on the scene.
  48745. *
  48746. * The effect layer class can not be used directly and is intented to inherited from to be
  48747. * customized per effects.
  48748. */
  48749. export abstract class EffectLayer {
  48750. private _vertexBuffers;
  48751. private _indexBuffer;
  48752. private _cachedDefines;
  48753. private _effectLayerMapGenerationEffect;
  48754. private _effectLayerOptions;
  48755. private _mergeEffect;
  48756. protected _scene: Scene;
  48757. protected _engine: Engine;
  48758. protected _maxSize: number;
  48759. protected _mainTextureDesiredSize: ISize;
  48760. protected _mainTexture: RenderTargetTexture;
  48761. protected _shouldRender: boolean;
  48762. protected _postProcesses: PostProcess[];
  48763. protected _textures: BaseTexture[];
  48764. protected _emissiveTextureAndColor: {
  48765. texture: Nullable<BaseTexture>;
  48766. color: Color4;
  48767. };
  48768. /**
  48769. * The name of the layer
  48770. */
  48771. name: string;
  48772. /**
  48773. * The clear color of the texture used to generate the glow map.
  48774. */
  48775. neutralColor: Color4;
  48776. /**
  48777. * Specifies wether the highlight layer is enabled or not.
  48778. */
  48779. isEnabled: boolean;
  48780. /**
  48781. * Gets the camera attached to the layer.
  48782. */
  48783. readonly camera: Nullable<Camera>;
  48784. /**
  48785. * Gets the rendering group id the layer should render in.
  48786. */
  48787. readonly renderingGroupId: number;
  48788. /**
  48789. * An event triggered when the effect layer has been disposed.
  48790. */
  48791. onDisposeObservable: Observable<EffectLayer>;
  48792. /**
  48793. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48794. */
  48795. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48796. /**
  48797. * An event triggered when the generated texture is being merged in the scene.
  48798. */
  48799. onBeforeComposeObservable: Observable<EffectLayer>;
  48800. /**
  48801. * An event triggered when the generated texture has been merged in the scene.
  48802. */
  48803. onAfterComposeObservable: Observable<EffectLayer>;
  48804. /**
  48805. * An event triggered when the efffect layer changes its size.
  48806. */
  48807. onSizeChangedObservable: Observable<EffectLayer>;
  48808. /** @hidden */
  48809. static _SceneComponentInitialization: (scene: Scene) => void;
  48810. /**
  48811. * Instantiates a new effect Layer and references it in the scene.
  48812. * @param name The name of the layer
  48813. * @param scene The scene to use the layer in
  48814. */
  48815. constructor(
  48816. /** The Friendly of the effect in the scene */
  48817. name: string, scene: Scene);
  48818. /**
  48819. * Get the effect name of the layer.
  48820. * @return The effect name
  48821. */
  48822. abstract getEffectName(): string;
  48823. /**
  48824. * Checks for the readiness of the element composing the layer.
  48825. * @param subMesh the mesh to check for
  48826. * @param useInstances specify wether or not to use instances to render the mesh
  48827. * @return true if ready otherwise, false
  48828. */
  48829. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48830. /**
  48831. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48832. * @returns true if the effect requires stencil during the main canvas render pass.
  48833. */
  48834. abstract needStencil(): boolean;
  48835. /**
  48836. * Create the merge effect. This is the shader use to blit the information back
  48837. * to the main canvas at the end of the scene rendering.
  48838. * @returns The effect containing the shader used to merge the effect on the main canvas
  48839. */
  48840. protected abstract _createMergeEffect(): Effect;
  48841. /**
  48842. * Creates the render target textures and post processes used in the effect layer.
  48843. */
  48844. protected abstract _createTextureAndPostProcesses(): void;
  48845. /**
  48846. * Implementation specific of rendering the generating effect on the main canvas.
  48847. * @param effect The effect used to render through
  48848. */
  48849. protected abstract _internalRender(effect: Effect): void;
  48850. /**
  48851. * Sets the required values for both the emissive texture and and the main color.
  48852. */
  48853. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48854. /**
  48855. * Free any resources and references associated to a mesh.
  48856. * Internal use
  48857. * @param mesh The mesh to free.
  48858. */
  48859. abstract _disposeMesh(mesh: Mesh): void;
  48860. /**
  48861. * Serializes this layer (Glow or Highlight for example)
  48862. * @returns a serialized layer object
  48863. */
  48864. abstract serialize?(): any;
  48865. /**
  48866. * Initializes the effect layer with the required options.
  48867. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48868. */
  48869. protected _init(options: Partial<IEffectLayerOptions>): void;
  48870. /**
  48871. * Generates the index buffer of the full screen quad blending to the main canvas.
  48872. */
  48873. private _generateIndexBuffer;
  48874. /**
  48875. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48876. */
  48877. private _generateVertexBuffer;
  48878. /**
  48879. * Sets the main texture desired size which is the closest power of two
  48880. * of the engine canvas size.
  48881. */
  48882. private _setMainTextureSize;
  48883. /**
  48884. * Creates the main texture for the effect layer.
  48885. */
  48886. protected _createMainTexture(): void;
  48887. /**
  48888. * Adds specific effects defines.
  48889. * @param defines The defines to add specifics to.
  48890. */
  48891. protected _addCustomEffectDefines(defines: string[]): void;
  48892. /**
  48893. * Checks for the readiness of the element composing the layer.
  48894. * @param subMesh the mesh to check for
  48895. * @param useInstances specify wether or not to use instances to render the mesh
  48896. * @param emissiveTexture the associated emissive texture used to generate the glow
  48897. * @return true if ready otherwise, false
  48898. */
  48899. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48900. /**
  48901. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48902. */
  48903. render(): void;
  48904. /**
  48905. * Determine if a given mesh will be used in the current effect.
  48906. * @param mesh mesh to test
  48907. * @returns true if the mesh will be used
  48908. */
  48909. hasMesh(mesh: AbstractMesh): boolean;
  48910. /**
  48911. * Returns true if the layer contains information to display, otherwise false.
  48912. * @returns true if the glow layer should be rendered
  48913. */
  48914. shouldRender(): boolean;
  48915. /**
  48916. * Returns true if the mesh should render, otherwise false.
  48917. * @param mesh The mesh to render
  48918. * @returns true if it should render otherwise false
  48919. */
  48920. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48921. /**
  48922. * Returns true if the mesh can be rendered, otherwise false.
  48923. * @param mesh The mesh to render
  48924. * @param material The material used on the mesh
  48925. * @returns true if it can be rendered otherwise false
  48926. */
  48927. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48928. /**
  48929. * Returns true if the mesh should render, otherwise false.
  48930. * @param mesh The mesh to render
  48931. * @returns true if it should render otherwise false
  48932. */
  48933. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48934. /**
  48935. * Renders the submesh passed in parameter to the generation map.
  48936. */
  48937. protected _renderSubMesh(subMesh: SubMesh): void;
  48938. /**
  48939. * Rebuild the required buffers.
  48940. * @hidden Internal use only.
  48941. */
  48942. _rebuild(): void;
  48943. /**
  48944. * Dispose only the render target textures and post process.
  48945. */
  48946. private _disposeTextureAndPostProcesses;
  48947. /**
  48948. * Dispose the highlight layer and free resources.
  48949. */
  48950. dispose(): void;
  48951. /**
  48952. * Gets the class name of the effect layer
  48953. * @returns the string with the class name of the effect layer
  48954. */
  48955. getClassName(): string;
  48956. /**
  48957. * Creates an effect layer from parsed effect layer data
  48958. * @param parsedEffectLayer defines effect layer data
  48959. * @param scene defines the current scene
  48960. * @param rootUrl defines the root URL containing the effect layer information
  48961. * @returns a parsed effect Layer
  48962. */
  48963. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48964. }
  48965. }
  48966. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48967. import { Scene } from "babylonjs/scene";
  48968. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48969. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48970. import { AbstractScene } from "babylonjs/abstractScene";
  48971. module "babylonjs/abstractScene" {
  48972. interface AbstractScene {
  48973. /**
  48974. * The list of effect layers (highlights/glow) added to the scene
  48975. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48976. * @see http://doc.babylonjs.com/how_to/glow_layer
  48977. */
  48978. effectLayers: Array<EffectLayer>;
  48979. /**
  48980. * Removes the given effect layer from this scene.
  48981. * @param toRemove defines the effect layer to remove
  48982. * @returns the index of the removed effect layer
  48983. */
  48984. removeEffectLayer(toRemove: EffectLayer): number;
  48985. /**
  48986. * Adds the given effect layer to this scene
  48987. * @param newEffectLayer defines the effect layer to add
  48988. */
  48989. addEffectLayer(newEffectLayer: EffectLayer): void;
  48990. }
  48991. }
  48992. /**
  48993. * Defines the layer scene component responsible to manage any effect layers
  48994. * in a given scene.
  48995. */
  48996. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48997. /**
  48998. * The component name helpfull to identify the component in the list of scene components.
  48999. */
  49000. readonly name: string;
  49001. /**
  49002. * The scene the component belongs to.
  49003. */
  49004. scene: Scene;
  49005. private _engine;
  49006. private _renderEffects;
  49007. private _needStencil;
  49008. private _previousStencilState;
  49009. /**
  49010. * Creates a new instance of the component for the given scene
  49011. * @param scene Defines the scene to register the component in
  49012. */
  49013. constructor(scene: Scene);
  49014. /**
  49015. * Registers the component in a given scene
  49016. */
  49017. register(): void;
  49018. /**
  49019. * Rebuilds the elements related to this component in case of
  49020. * context lost for instance.
  49021. */
  49022. rebuild(): void;
  49023. /**
  49024. * Serializes the component data to the specified json object
  49025. * @param serializationObject The object to serialize to
  49026. */
  49027. serialize(serializationObject: any): void;
  49028. /**
  49029. * Adds all the element from the container to the scene
  49030. * @param container the container holding the elements
  49031. */
  49032. addFromContainer(container: AbstractScene): void;
  49033. /**
  49034. * Removes all the elements in the container from the scene
  49035. * @param container contains the elements to remove
  49036. * @param dispose if the removed element should be disposed (default: false)
  49037. */
  49038. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49039. /**
  49040. * Disposes the component and the associated ressources.
  49041. */
  49042. dispose(): void;
  49043. private _isReadyForMesh;
  49044. private _renderMainTexture;
  49045. private _setStencil;
  49046. private _setStencilBack;
  49047. private _draw;
  49048. private _drawCamera;
  49049. private _drawRenderingGroup;
  49050. }
  49051. }
  49052. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49053. /** @hidden */
  49054. export var glowMapMergePixelShader: {
  49055. name: string;
  49056. shader: string;
  49057. };
  49058. }
  49059. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49060. /** @hidden */
  49061. export var glowMapMergeVertexShader: {
  49062. name: string;
  49063. shader: string;
  49064. };
  49065. }
  49066. declare module "babylonjs/Layers/glowLayer" {
  49067. import { Nullable } from "babylonjs/types";
  49068. import { Camera } from "babylonjs/Cameras/camera";
  49069. import { Scene } from "babylonjs/scene";
  49070. import { Color4 } from "babylonjs/Maths/math";
  49071. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49073. import { Mesh } from "babylonjs/Meshes/mesh";
  49074. import { Texture } from "babylonjs/Materials/Textures/texture";
  49075. import { Effect } from "babylonjs/Materials/effect";
  49076. import { Material } from "babylonjs/Materials/material";
  49077. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49078. import "babylonjs/Shaders/glowMapMerge.fragment";
  49079. import "babylonjs/Shaders/glowMapMerge.vertex";
  49080. import "babylonjs/Layers/effectLayerSceneComponent";
  49081. module "babylonjs/abstractScene" {
  49082. interface AbstractScene {
  49083. /**
  49084. * Return a the first highlight layer of the scene with a given name.
  49085. * @param name The name of the highlight layer to look for.
  49086. * @return The highlight layer if found otherwise null.
  49087. */
  49088. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49089. }
  49090. }
  49091. /**
  49092. * Glow layer options. This helps customizing the behaviour
  49093. * of the glow layer.
  49094. */
  49095. export interface IGlowLayerOptions {
  49096. /**
  49097. * Multiplication factor apply to the canvas size to compute the render target size
  49098. * used to generated the glowing objects (the smaller the faster).
  49099. */
  49100. mainTextureRatio: number;
  49101. /**
  49102. * Enforces a fixed size texture to ensure resize independant blur.
  49103. */
  49104. mainTextureFixedSize?: number;
  49105. /**
  49106. * How big is the kernel of the blur texture.
  49107. */
  49108. blurKernelSize: number;
  49109. /**
  49110. * The camera attached to the layer.
  49111. */
  49112. camera: Nullable<Camera>;
  49113. /**
  49114. * Enable MSAA by chosing the number of samples.
  49115. */
  49116. mainTextureSamples?: number;
  49117. /**
  49118. * The rendering group to draw the layer in.
  49119. */
  49120. renderingGroupId: number;
  49121. }
  49122. /**
  49123. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49124. *
  49125. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49126. * glowy meshes to your scene.
  49127. *
  49128. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49129. */
  49130. export class GlowLayer extends EffectLayer {
  49131. /**
  49132. * Effect Name of the layer.
  49133. */
  49134. static readonly EffectName: string;
  49135. /**
  49136. * The default blur kernel size used for the glow.
  49137. */
  49138. static DefaultBlurKernelSize: number;
  49139. /**
  49140. * The default texture size ratio used for the glow.
  49141. */
  49142. static DefaultTextureRatio: number;
  49143. /**
  49144. * Sets the kernel size of the blur.
  49145. */
  49146. /**
  49147. * Gets the kernel size of the blur.
  49148. */
  49149. blurKernelSize: number;
  49150. /**
  49151. * Sets the glow intensity.
  49152. */
  49153. /**
  49154. * Gets the glow intensity.
  49155. */
  49156. intensity: number;
  49157. private _options;
  49158. private _intensity;
  49159. private _horizontalBlurPostprocess1;
  49160. private _verticalBlurPostprocess1;
  49161. private _horizontalBlurPostprocess2;
  49162. private _verticalBlurPostprocess2;
  49163. private _blurTexture1;
  49164. private _blurTexture2;
  49165. private _postProcesses1;
  49166. private _postProcesses2;
  49167. private _includedOnlyMeshes;
  49168. private _excludedMeshes;
  49169. /**
  49170. * Callback used to let the user override the color selection on a per mesh basis
  49171. */
  49172. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49173. /**
  49174. * Callback used to let the user override the texture selection on a per mesh basis
  49175. */
  49176. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49177. /**
  49178. * Instantiates a new glow Layer and references it to the scene.
  49179. * @param name The name of the layer
  49180. * @param scene The scene to use the layer in
  49181. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49182. */
  49183. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49184. /**
  49185. * Get the effect name of the layer.
  49186. * @return The effect name
  49187. */
  49188. getEffectName(): string;
  49189. /**
  49190. * Create the merge effect. This is the shader use to blit the information back
  49191. * to the main canvas at the end of the scene rendering.
  49192. */
  49193. protected _createMergeEffect(): Effect;
  49194. /**
  49195. * Creates the render target textures and post processes used in the glow layer.
  49196. */
  49197. protected _createTextureAndPostProcesses(): void;
  49198. /**
  49199. * Checks for the readiness of the element composing the layer.
  49200. * @param subMesh the mesh to check for
  49201. * @param useInstances specify wether or not to use instances to render the mesh
  49202. * @param emissiveTexture the associated emissive texture used to generate the glow
  49203. * @return true if ready otherwise, false
  49204. */
  49205. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49206. /**
  49207. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49208. */
  49209. needStencil(): boolean;
  49210. /**
  49211. * Returns true if the mesh can be rendered, otherwise false.
  49212. * @param mesh The mesh to render
  49213. * @param material The material used on the mesh
  49214. * @returns true if it can be rendered otherwise false
  49215. */
  49216. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49217. /**
  49218. * Implementation specific of rendering the generating effect on the main canvas.
  49219. * @param effect The effect used to render through
  49220. */
  49221. protected _internalRender(effect: Effect): void;
  49222. /**
  49223. * Sets the required values for both the emissive texture and and the main color.
  49224. */
  49225. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49226. /**
  49227. * Returns true if the mesh should render, otherwise false.
  49228. * @param mesh The mesh to render
  49229. * @returns true if it should render otherwise false
  49230. */
  49231. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49232. /**
  49233. * Adds specific effects defines.
  49234. * @param defines The defines to add specifics to.
  49235. */
  49236. protected _addCustomEffectDefines(defines: string[]): void;
  49237. /**
  49238. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49239. * @param mesh The mesh to exclude from the glow layer
  49240. */
  49241. addExcludedMesh(mesh: Mesh): void;
  49242. /**
  49243. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49244. * @param mesh The mesh to remove
  49245. */
  49246. removeExcludedMesh(mesh: Mesh): void;
  49247. /**
  49248. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49249. * @param mesh The mesh to include in the glow layer
  49250. */
  49251. addIncludedOnlyMesh(mesh: Mesh): void;
  49252. /**
  49253. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49254. * @param mesh The mesh to remove
  49255. */
  49256. removeIncludedOnlyMesh(mesh: Mesh): void;
  49257. /**
  49258. * Determine if a given mesh will be used in the glow layer
  49259. * @param mesh The mesh to test
  49260. * @returns true if the mesh will be highlighted by the current glow layer
  49261. */
  49262. hasMesh(mesh: AbstractMesh): boolean;
  49263. /**
  49264. * Free any resources and references associated to a mesh.
  49265. * Internal use
  49266. * @param mesh The mesh to free.
  49267. * @hidden
  49268. */
  49269. _disposeMesh(mesh: Mesh): void;
  49270. /**
  49271. * Gets the class name of the effect layer
  49272. * @returns the string with the class name of the effect layer
  49273. */
  49274. getClassName(): string;
  49275. /**
  49276. * Serializes this glow layer
  49277. * @returns a serialized glow layer object
  49278. */
  49279. serialize(): any;
  49280. /**
  49281. * Creates a Glow Layer from parsed glow layer data
  49282. * @param parsedGlowLayer defines glow layer data
  49283. * @param scene defines the current scene
  49284. * @param rootUrl defines the root URL containing the glow layer information
  49285. * @returns a parsed Glow Layer
  49286. */
  49287. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49288. }
  49289. }
  49290. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49291. /** @hidden */
  49292. export var glowBlurPostProcessPixelShader: {
  49293. name: string;
  49294. shader: string;
  49295. };
  49296. }
  49297. declare module "babylonjs/Layers/highlightLayer" {
  49298. import { Observable } from "babylonjs/Misc/observable";
  49299. import { Nullable } from "babylonjs/types";
  49300. import { Camera } from "babylonjs/Cameras/camera";
  49301. import { Scene } from "babylonjs/scene";
  49302. import { Color3, Color4 } from "babylonjs/Maths/math";
  49303. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49305. import { Mesh } from "babylonjs/Meshes/mesh";
  49306. import { Effect } from "babylonjs/Materials/effect";
  49307. import { Material } from "babylonjs/Materials/material";
  49308. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49309. import "babylonjs/Shaders/glowMapMerge.fragment";
  49310. import "babylonjs/Shaders/glowMapMerge.vertex";
  49311. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49312. module "babylonjs/abstractScene" {
  49313. interface AbstractScene {
  49314. /**
  49315. * Return a the first highlight layer of the scene with a given name.
  49316. * @param name The name of the highlight layer to look for.
  49317. * @return The highlight layer if found otherwise null.
  49318. */
  49319. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49320. }
  49321. }
  49322. /**
  49323. * Highlight layer options. This helps customizing the behaviour
  49324. * of the highlight layer.
  49325. */
  49326. export interface IHighlightLayerOptions {
  49327. /**
  49328. * Multiplication factor apply to the canvas size to compute the render target size
  49329. * used to generated the glowing objects (the smaller the faster).
  49330. */
  49331. mainTextureRatio: number;
  49332. /**
  49333. * Enforces a fixed size texture to ensure resize independant blur.
  49334. */
  49335. mainTextureFixedSize?: number;
  49336. /**
  49337. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49338. * of the picture to blur (the smaller the faster).
  49339. */
  49340. blurTextureSizeRatio: number;
  49341. /**
  49342. * How big in texel of the blur texture is the vertical blur.
  49343. */
  49344. blurVerticalSize: number;
  49345. /**
  49346. * How big in texel of the blur texture is the horizontal blur.
  49347. */
  49348. blurHorizontalSize: number;
  49349. /**
  49350. * Alpha blending mode used to apply the blur. Default is combine.
  49351. */
  49352. alphaBlendingMode: number;
  49353. /**
  49354. * The camera attached to the layer.
  49355. */
  49356. camera: Nullable<Camera>;
  49357. /**
  49358. * Should we display highlight as a solid stroke?
  49359. */
  49360. isStroke?: boolean;
  49361. /**
  49362. * The rendering group to draw the layer in.
  49363. */
  49364. renderingGroupId: number;
  49365. }
  49366. /**
  49367. * The highlight layer Helps adding a glow effect around a mesh.
  49368. *
  49369. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49370. * glowy meshes to your scene.
  49371. *
  49372. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49373. */
  49374. export class HighlightLayer extends EffectLayer {
  49375. name: string;
  49376. /**
  49377. * Effect Name of the highlight layer.
  49378. */
  49379. static readonly EffectName: string;
  49380. /**
  49381. * The neutral color used during the preparation of the glow effect.
  49382. * This is black by default as the blend operation is a blend operation.
  49383. */
  49384. static NeutralColor: Color4;
  49385. /**
  49386. * Stencil value used for glowing meshes.
  49387. */
  49388. static GlowingMeshStencilReference: number;
  49389. /**
  49390. * Stencil value used for the other meshes in the scene.
  49391. */
  49392. static NormalMeshStencilReference: number;
  49393. /**
  49394. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49395. */
  49396. innerGlow: boolean;
  49397. /**
  49398. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49399. */
  49400. outerGlow: boolean;
  49401. /**
  49402. * Specifies the horizontal size of the blur.
  49403. */
  49404. /**
  49405. * Gets the horizontal size of the blur.
  49406. */
  49407. blurHorizontalSize: number;
  49408. /**
  49409. * Specifies the vertical size of the blur.
  49410. */
  49411. /**
  49412. * Gets the vertical size of the blur.
  49413. */
  49414. blurVerticalSize: number;
  49415. /**
  49416. * An event triggered when the highlight layer is being blurred.
  49417. */
  49418. onBeforeBlurObservable: Observable<HighlightLayer>;
  49419. /**
  49420. * An event triggered when the highlight layer has been blurred.
  49421. */
  49422. onAfterBlurObservable: Observable<HighlightLayer>;
  49423. private _instanceGlowingMeshStencilReference;
  49424. private _options;
  49425. private _downSamplePostprocess;
  49426. private _horizontalBlurPostprocess;
  49427. private _verticalBlurPostprocess;
  49428. private _blurTexture;
  49429. private _meshes;
  49430. private _excludedMeshes;
  49431. /**
  49432. * Instantiates a new highlight Layer and references it to the scene..
  49433. * @param name The name of the layer
  49434. * @param scene The scene to use the layer in
  49435. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49436. */
  49437. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49438. /**
  49439. * Get the effect name of the layer.
  49440. * @return The effect name
  49441. */
  49442. getEffectName(): string;
  49443. /**
  49444. * Create the merge effect. This is the shader use to blit the information back
  49445. * to the main canvas at the end of the scene rendering.
  49446. */
  49447. protected _createMergeEffect(): Effect;
  49448. /**
  49449. * Creates the render target textures and post processes used in the highlight layer.
  49450. */
  49451. protected _createTextureAndPostProcesses(): void;
  49452. /**
  49453. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49454. */
  49455. needStencil(): boolean;
  49456. /**
  49457. * Checks for the readiness of the element composing the layer.
  49458. * @param subMesh the mesh to check for
  49459. * @param useInstances specify wether or not to use instances to render the mesh
  49460. * @param emissiveTexture the associated emissive texture used to generate the glow
  49461. * @return true if ready otherwise, false
  49462. */
  49463. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49464. /**
  49465. * Implementation specific of rendering the generating effect on the main canvas.
  49466. * @param effect The effect used to render through
  49467. */
  49468. protected _internalRender(effect: Effect): void;
  49469. /**
  49470. * Returns true if the layer contains information to display, otherwise false.
  49471. */
  49472. shouldRender(): boolean;
  49473. /**
  49474. * Returns true if the mesh should render, otherwise false.
  49475. * @param mesh The mesh to render
  49476. * @returns true if it should render otherwise false
  49477. */
  49478. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49479. /**
  49480. * Sets the required values for both the emissive texture and and the main color.
  49481. */
  49482. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49483. /**
  49484. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49485. * @param mesh The mesh to exclude from the highlight layer
  49486. */
  49487. addExcludedMesh(mesh: Mesh): void;
  49488. /**
  49489. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49490. * @param mesh The mesh to highlight
  49491. */
  49492. removeExcludedMesh(mesh: Mesh): void;
  49493. /**
  49494. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49495. * @param mesh mesh to test
  49496. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49497. */
  49498. hasMesh(mesh: AbstractMesh): boolean;
  49499. /**
  49500. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49501. * @param mesh The mesh to highlight
  49502. * @param color The color of the highlight
  49503. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49504. */
  49505. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49506. /**
  49507. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49508. * @param mesh The mesh to highlight
  49509. */
  49510. removeMesh(mesh: Mesh): void;
  49511. /**
  49512. * Force the stencil to the normal expected value for none glowing parts
  49513. */
  49514. private _defaultStencilReference;
  49515. /**
  49516. * Free any resources and references associated to a mesh.
  49517. * Internal use
  49518. * @param mesh The mesh to free.
  49519. * @hidden
  49520. */
  49521. _disposeMesh(mesh: Mesh): void;
  49522. /**
  49523. * Dispose the highlight layer and free resources.
  49524. */
  49525. dispose(): void;
  49526. /**
  49527. * Gets the class name of the effect layer
  49528. * @returns the string with the class name of the effect layer
  49529. */
  49530. getClassName(): string;
  49531. /**
  49532. * Serializes this Highlight layer
  49533. * @returns a serialized Highlight layer object
  49534. */
  49535. serialize(): any;
  49536. /**
  49537. * Creates a Highlight layer from parsed Highlight layer data
  49538. * @param parsedHightlightLayer defines the Highlight layer data
  49539. * @param scene defines the current scene
  49540. * @param rootUrl defines the root URL containing the Highlight layer information
  49541. * @returns a parsed Highlight layer
  49542. */
  49543. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49544. }
  49545. }
  49546. declare module "babylonjs/Layers/index" {
  49547. export * from "babylonjs/Layers/effectLayer";
  49548. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49549. export * from "babylonjs/Layers/glowLayer";
  49550. export * from "babylonjs/Layers/highlightLayer";
  49551. export * from "babylonjs/Layers/layer";
  49552. export * from "babylonjs/Layers/layerSceneComponent";
  49553. }
  49554. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49555. /** @hidden */
  49556. export var lensFlarePixelShader: {
  49557. name: string;
  49558. shader: string;
  49559. };
  49560. }
  49561. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49562. /** @hidden */
  49563. export var lensFlareVertexShader: {
  49564. name: string;
  49565. shader: string;
  49566. };
  49567. }
  49568. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49569. import { Scene } from "babylonjs/scene";
  49570. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49572. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49573. import "babylonjs/Shaders/lensFlare.fragment";
  49574. import "babylonjs/Shaders/lensFlare.vertex";
  49575. /**
  49576. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49577. * It is usually composed of several `lensFlare`.
  49578. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49579. */
  49580. export class LensFlareSystem {
  49581. /**
  49582. * Define the name of the lens flare system
  49583. */
  49584. name: string;
  49585. /**
  49586. * List of lens flares used in this system.
  49587. */
  49588. lensFlares: LensFlare[];
  49589. /**
  49590. * Define a limit from the border the lens flare can be visible.
  49591. */
  49592. borderLimit: number;
  49593. /**
  49594. * Define a viewport border we do not want to see the lens flare in.
  49595. */
  49596. viewportBorder: number;
  49597. /**
  49598. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49599. */
  49600. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49601. /**
  49602. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49603. */
  49604. layerMask: number;
  49605. /**
  49606. * Define the id of the lens flare system in the scene.
  49607. * (equal to name by default)
  49608. */
  49609. id: string;
  49610. private _scene;
  49611. private _emitter;
  49612. private _vertexBuffers;
  49613. private _indexBuffer;
  49614. private _effect;
  49615. private _positionX;
  49616. private _positionY;
  49617. private _isEnabled;
  49618. /** @hidden */
  49619. static _SceneComponentInitialization: (scene: Scene) => void;
  49620. /**
  49621. * Instantiates a lens flare system.
  49622. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49623. * It is usually composed of several `lensFlare`.
  49624. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49625. * @param name Define the name of the lens flare system in the scene
  49626. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49627. * @param scene Define the scene the lens flare system belongs to
  49628. */
  49629. constructor(
  49630. /**
  49631. * Define the name of the lens flare system
  49632. */
  49633. name: string, emitter: any, scene: Scene);
  49634. /**
  49635. * Define if the lens flare system is enabled.
  49636. */
  49637. isEnabled: boolean;
  49638. /**
  49639. * Get the scene the effects belongs to.
  49640. * @returns the scene holding the lens flare system
  49641. */
  49642. getScene(): Scene;
  49643. /**
  49644. * Get the emitter of the lens flare system.
  49645. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49646. * @returns the emitter of the lens flare system
  49647. */
  49648. getEmitter(): any;
  49649. /**
  49650. * Set the emitter of the lens flare system.
  49651. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49652. * @param newEmitter Define the new emitter of the system
  49653. */
  49654. setEmitter(newEmitter: any): void;
  49655. /**
  49656. * Get the lens flare system emitter position.
  49657. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49658. * @returns the position
  49659. */
  49660. getEmitterPosition(): Vector3;
  49661. /**
  49662. * @hidden
  49663. */
  49664. computeEffectivePosition(globalViewport: Viewport): boolean;
  49665. /** @hidden */
  49666. _isVisible(): boolean;
  49667. /**
  49668. * @hidden
  49669. */
  49670. render(): boolean;
  49671. /**
  49672. * Dispose and release the lens flare with its associated resources.
  49673. */
  49674. dispose(): void;
  49675. /**
  49676. * Parse a lens flare system from a JSON repressentation
  49677. * @param parsedLensFlareSystem Define the JSON to parse
  49678. * @param scene Define the scene the parsed system should be instantiated in
  49679. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49680. * @returns the parsed system
  49681. */
  49682. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49683. /**
  49684. * Serialize the current Lens Flare System into a JSON representation.
  49685. * @returns the serialized JSON
  49686. */
  49687. serialize(): any;
  49688. }
  49689. }
  49690. declare module "babylonjs/LensFlares/lensFlare" {
  49691. import { Nullable } from "babylonjs/types";
  49692. import { Color3 } from "babylonjs/Maths/math";
  49693. import { Texture } from "babylonjs/Materials/Textures/texture";
  49694. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49695. /**
  49696. * This represents one of the lens effect in a `lensFlareSystem`.
  49697. * It controls one of the indiviual texture used in the effect.
  49698. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49699. */
  49700. export class LensFlare {
  49701. /**
  49702. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49703. */
  49704. size: number;
  49705. /**
  49706. * 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.
  49707. */
  49708. position: number;
  49709. /**
  49710. * Define the lens color.
  49711. */
  49712. color: Color3;
  49713. /**
  49714. * Define the lens texture.
  49715. */
  49716. texture: Nullable<Texture>;
  49717. /**
  49718. * Define the alpha mode to render this particular lens.
  49719. */
  49720. alphaMode: number;
  49721. private _system;
  49722. /**
  49723. * Creates a new Lens Flare.
  49724. * This represents one of the lens effect in a `lensFlareSystem`.
  49725. * It controls one of the indiviual texture used in the effect.
  49726. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49727. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49728. * @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.
  49729. * @param color Define the lens color
  49730. * @param imgUrl Define the lens texture url
  49731. * @param system Define the `lensFlareSystem` this flare is part of
  49732. * @returns The newly created Lens Flare
  49733. */
  49734. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49735. /**
  49736. * Instantiates a new Lens Flare.
  49737. * This represents one of the lens effect in a `lensFlareSystem`.
  49738. * It controls one of the indiviual texture used in the effect.
  49739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49740. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49741. * @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.
  49742. * @param color Define the lens color
  49743. * @param imgUrl Define the lens texture url
  49744. * @param system Define the `lensFlareSystem` this flare is part of
  49745. */
  49746. constructor(
  49747. /**
  49748. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49749. */
  49750. size: number,
  49751. /**
  49752. * 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.
  49753. */
  49754. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49755. /**
  49756. * Dispose and release the lens flare with its associated resources.
  49757. */
  49758. dispose(): void;
  49759. }
  49760. }
  49761. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49762. import { Nullable } from "babylonjs/types";
  49763. import { Scene } from "babylonjs/scene";
  49764. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49765. import { AbstractScene } from "babylonjs/abstractScene";
  49766. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49767. module "babylonjs/abstractScene" {
  49768. interface AbstractScene {
  49769. /**
  49770. * The list of lens flare system added to the scene
  49771. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49772. */
  49773. lensFlareSystems: Array<LensFlareSystem>;
  49774. /**
  49775. * Removes the given lens flare system from this scene.
  49776. * @param toRemove The lens flare system to remove
  49777. * @returns The index of the removed lens flare system
  49778. */
  49779. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49780. /**
  49781. * Adds the given lens flare system to this scene
  49782. * @param newLensFlareSystem The lens flare system to add
  49783. */
  49784. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49785. /**
  49786. * Gets a lens flare system using its name
  49787. * @param name defines the name to look for
  49788. * @returns the lens flare system or null if not found
  49789. */
  49790. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49791. /**
  49792. * Gets a lens flare system using its id
  49793. * @param id defines the id to look for
  49794. * @returns the lens flare system or null if not found
  49795. */
  49796. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49797. }
  49798. }
  49799. /**
  49800. * Defines the lens flare scene component responsible to manage any lens flares
  49801. * in a given scene.
  49802. */
  49803. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49804. /**
  49805. * The component name helpfull to identify the component in the list of scene components.
  49806. */
  49807. readonly name: string;
  49808. /**
  49809. * The scene the component belongs to.
  49810. */
  49811. scene: Scene;
  49812. /**
  49813. * Creates a new instance of the component for the given scene
  49814. * @param scene Defines the scene to register the component in
  49815. */
  49816. constructor(scene: Scene);
  49817. /**
  49818. * Registers the component in a given scene
  49819. */
  49820. register(): void;
  49821. /**
  49822. * Rebuilds the elements related to this component in case of
  49823. * context lost for instance.
  49824. */
  49825. rebuild(): void;
  49826. /**
  49827. * Adds all the element from the container to the scene
  49828. * @param container the container holding the elements
  49829. */
  49830. addFromContainer(container: AbstractScene): void;
  49831. /**
  49832. * Removes all the elements in the container from the scene
  49833. * @param container contains the elements to remove
  49834. * @param dispose if the removed element should be disposed (default: false)
  49835. */
  49836. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49837. /**
  49838. * Serializes the component data to the specified json object
  49839. * @param serializationObject The object to serialize to
  49840. */
  49841. serialize(serializationObject: any): void;
  49842. /**
  49843. * Disposes the component and the associated ressources.
  49844. */
  49845. dispose(): void;
  49846. private _draw;
  49847. }
  49848. }
  49849. declare module "babylonjs/LensFlares/index" {
  49850. export * from "babylonjs/LensFlares/lensFlare";
  49851. export * from "babylonjs/LensFlares/lensFlareSystem";
  49852. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49853. }
  49854. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49855. import { Scene } from "babylonjs/scene";
  49856. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49857. import { AbstractScene } from "babylonjs/abstractScene";
  49858. /**
  49859. * Defines the shadow generator component responsible to manage any shadow generators
  49860. * in a given scene.
  49861. */
  49862. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49863. /**
  49864. * The component name helpfull to identify the component in the list of scene components.
  49865. */
  49866. readonly name: string;
  49867. /**
  49868. * The scene the component belongs to.
  49869. */
  49870. scene: Scene;
  49871. /**
  49872. * Creates a new instance of the component for the given scene
  49873. * @param scene Defines the scene to register the component in
  49874. */
  49875. constructor(scene: Scene);
  49876. /**
  49877. * Registers the component in a given scene
  49878. */
  49879. register(): void;
  49880. /**
  49881. * Rebuilds the elements related to this component in case of
  49882. * context lost for instance.
  49883. */
  49884. rebuild(): void;
  49885. /**
  49886. * Serializes the component data to the specified json object
  49887. * @param serializationObject The object to serialize to
  49888. */
  49889. serialize(serializationObject: any): void;
  49890. /**
  49891. * Adds all the element from the container to the scene
  49892. * @param container the container holding the elements
  49893. */
  49894. addFromContainer(container: AbstractScene): void;
  49895. /**
  49896. * Removes all the elements in the container from the scene
  49897. * @param container contains the elements to remove
  49898. * @param dispose if the removed element should be disposed (default: false)
  49899. */
  49900. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49901. /**
  49902. * Rebuilds the elements related to this component in case of
  49903. * context lost for instance.
  49904. */
  49905. dispose(): void;
  49906. private _gatherRenderTargets;
  49907. }
  49908. }
  49909. declare module "babylonjs/Lights/Shadows/index" {
  49910. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49911. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49912. }
  49913. declare module "babylonjs/Lights/pointLight" {
  49914. import { Scene } from "babylonjs/scene";
  49915. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49917. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49918. import { Effect } from "babylonjs/Materials/effect";
  49919. /**
  49920. * A point light is a light defined by an unique point in world space.
  49921. * The light is emitted in every direction from this point.
  49922. * A good example of a point light is a standard light bulb.
  49923. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49924. */
  49925. export class PointLight extends ShadowLight {
  49926. private _shadowAngle;
  49927. /**
  49928. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49929. * This specifies what angle the shadow will use to be created.
  49930. *
  49931. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49932. */
  49933. /**
  49934. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49935. * This specifies what angle the shadow will use to be created.
  49936. *
  49937. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49938. */
  49939. shadowAngle: number;
  49940. /**
  49941. * Gets the direction if it has been set.
  49942. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49943. */
  49944. /**
  49945. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49946. */
  49947. direction: Vector3;
  49948. /**
  49949. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49950. * A PointLight emits the light in every direction.
  49951. * It can cast shadows.
  49952. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49953. * ```javascript
  49954. * var pointLight = new PointLight("pl", camera.position, scene);
  49955. * ```
  49956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49957. * @param name The light friendly name
  49958. * @param position The position of the point light in the scene
  49959. * @param scene The scene the lights belongs to
  49960. */
  49961. constructor(name: string, position: Vector3, scene: Scene);
  49962. /**
  49963. * Returns the string "PointLight"
  49964. * @returns the class name
  49965. */
  49966. getClassName(): string;
  49967. /**
  49968. * Returns the integer 0.
  49969. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49970. */
  49971. getTypeID(): number;
  49972. /**
  49973. * Specifies wether or not the shadowmap should be a cube texture.
  49974. * @returns true if the shadowmap needs to be a cube texture.
  49975. */
  49976. needCube(): boolean;
  49977. /**
  49978. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49979. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49980. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49981. */
  49982. getShadowDirection(faceIndex?: number): Vector3;
  49983. /**
  49984. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49985. * - fov = PI / 2
  49986. * - aspect ratio : 1.0
  49987. * - z-near and far equal to the active camera minZ and maxZ.
  49988. * Returns the PointLight.
  49989. */
  49990. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49991. protected _buildUniformLayout(): void;
  49992. /**
  49993. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49994. * @param effect The effect to update
  49995. * @param lightIndex The index of the light in the effect to update
  49996. * @returns The point light
  49997. */
  49998. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49999. /**
  50000. * Prepares the list of defines specific to the light type.
  50001. * @param defines the list of defines
  50002. * @param lightIndex defines the index of the light for the effect
  50003. */
  50004. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50005. }
  50006. }
  50007. declare module "babylonjs/Lights/index" {
  50008. export * from "babylonjs/Lights/light";
  50009. export * from "babylonjs/Lights/shadowLight";
  50010. export * from "babylonjs/Lights/Shadows/index";
  50011. export * from "babylonjs/Lights/directionalLight";
  50012. export * from "babylonjs/Lights/hemisphericLight";
  50013. export * from "babylonjs/Lights/pointLight";
  50014. export * from "babylonjs/Lights/spotLight";
  50015. }
  50016. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50017. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50018. /**
  50019. * Header information of HDR texture files.
  50020. */
  50021. export interface HDRInfo {
  50022. /**
  50023. * The height of the texture in pixels.
  50024. */
  50025. height: number;
  50026. /**
  50027. * The width of the texture in pixels.
  50028. */
  50029. width: number;
  50030. /**
  50031. * The index of the beginning of the data in the binary file.
  50032. */
  50033. dataPosition: number;
  50034. }
  50035. /**
  50036. * This groups tools to convert HDR texture to native colors array.
  50037. */
  50038. export class HDRTools {
  50039. private static Ldexp;
  50040. private static Rgbe2float;
  50041. private static readStringLine;
  50042. /**
  50043. * Reads header information from an RGBE texture stored in a native array.
  50044. * More information on this format are available here:
  50045. * https://en.wikipedia.org/wiki/RGBE_image_format
  50046. *
  50047. * @param uint8array The binary file stored in native array.
  50048. * @return The header information.
  50049. */
  50050. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50051. /**
  50052. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50053. * This RGBE texture needs to store the information as a panorama.
  50054. *
  50055. * More information on this format are available here:
  50056. * https://en.wikipedia.org/wiki/RGBE_image_format
  50057. *
  50058. * @param buffer The binary file stored in an array buffer.
  50059. * @param size The expected size of the extracted cubemap.
  50060. * @return The Cube Map information.
  50061. */
  50062. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50063. /**
  50064. * Returns the pixels data extracted from an RGBE texture.
  50065. * This pixels will be stored left to right up to down in the R G B order in one array.
  50066. *
  50067. * More information on this format are available here:
  50068. * https://en.wikipedia.org/wiki/RGBE_image_format
  50069. *
  50070. * @param uint8array The binary file stored in an array buffer.
  50071. * @param hdrInfo The header information of the file.
  50072. * @return The pixels data in RGB right to left up to down order.
  50073. */
  50074. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50075. private static RGBE_ReadPixels_RLE;
  50076. }
  50077. }
  50078. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50079. import { Nullable } from "babylonjs/types";
  50080. import { Scene } from "babylonjs/scene";
  50081. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50083. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50084. /**
  50085. * This represents a texture coming from an HDR input.
  50086. *
  50087. * The only supported format is currently panorama picture stored in RGBE format.
  50088. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50089. */
  50090. export class HDRCubeTexture extends BaseTexture {
  50091. private static _facesMapping;
  50092. private _generateHarmonics;
  50093. private _noMipmap;
  50094. private _textureMatrix;
  50095. private _size;
  50096. private _onLoad;
  50097. private _onError;
  50098. /**
  50099. * The texture URL.
  50100. */
  50101. url: string;
  50102. /**
  50103. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50104. */
  50105. coordinatesMode: number;
  50106. protected _isBlocking: boolean;
  50107. /**
  50108. * Sets wether or not the texture is blocking during loading.
  50109. */
  50110. /**
  50111. * Gets wether or not the texture is blocking during loading.
  50112. */
  50113. isBlocking: boolean;
  50114. protected _rotationY: number;
  50115. /**
  50116. * Sets texture matrix rotation angle around Y axis in radians.
  50117. */
  50118. /**
  50119. * Gets texture matrix rotation angle around Y axis radians.
  50120. */
  50121. rotationY: number;
  50122. /**
  50123. * Gets or sets the center of the bounding box associated with the cube texture
  50124. * It must define where the camera used to render the texture was set
  50125. */
  50126. boundingBoxPosition: Vector3;
  50127. private _boundingBoxSize;
  50128. /**
  50129. * Gets or sets the size of the bounding box associated with the cube texture
  50130. * When defined, the cubemap will switch to local mode
  50131. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50132. * @example https://www.babylonjs-playground.com/#RNASML
  50133. */
  50134. boundingBoxSize: Vector3;
  50135. /**
  50136. * Instantiates an HDRTexture from the following parameters.
  50137. *
  50138. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50139. * @param scene The scene the texture will be used in
  50140. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50141. * @param noMipmap Forces to not generate the mipmap if true
  50142. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50143. * @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)
  50144. * @param reserved Reserved flag for internal use.
  50145. */
  50146. 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>);
  50147. /**
  50148. * Get the current class name of the texture useful for serialization or dynamic coding.
  50149. * @returns "HDRCubeTexture"
  50150. */
  50151. getClassName(): string;
  50152. /**
  50153. * Occurs when the file is raw .hdr file.
  50154. */
  50155. private loadTexture;
  50156. clone(): HDRCubeTexture;
  50157. delayLoad(): void;
  50158. /**
  50159. * Get the texture reflection matrix used to rotate/transform the reflection.
  50160. * @returns the reflection matrix
  50161. */
  50162. getReflectionTextureMatrix(): Matrix;
  50163. /**
  50164. * Set the texture reflection matrix used to rotate/transform the reflection.
  50165. * @param value Define the reflection matrix to set
  50166. */
  50167. setReflectionTextureMatrix(value: Matrix): void;
  50168. /**
  50169. * Parses a JSON representation of an HDR Texture in order to create the texture
  50170. * @param parsedTexture Define the JSON representation
  50171. * @param scene Define the scene the texture should be created in
  50172. * @param rootUrl Define the root url in case we need to load relative dependencies
  50173. * @returns the newly created texture after parsing
  50174. */
  50175. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50176. serialize(): any;
  50177. }
  50178. }
  50179. declare module "babylonjs/Physics/physicsEngine" {
  50180. import { Nullable } from "babylonjs/types";
  50181. import { Vector3 } from "babylonjs/Maths/math";
  50182. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50183. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50184. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50185. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50186. /**
  50187. * Class used to control physics engine
  50188. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50189. */
  50190. export class PhysicsEngine implements IPhysicsEngine {
  50191. private _physicsPlugin;
  50192. /**
  50193. * Global value used to control the smallest number supported by the simulation
  50194. */
  50195. static Epsilon: number;
  50196. private _impostors;
  50197. private _joints;
  50198. /**
  50199. * Gets the gravity vector used by the simulation
  50200. */
  50201. gravity: Vector3;
  50202. /**
  50203. * Factory used to create the default physics plugin.
  50204. * @returns The default physics plugin
  50205. */
  50206. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50207. /**
  50208. * Creates a new Physics Engine
  50209. * @param gravity defines the gravity vector used by the simulation
  50210. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50211. */
  50212. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50213. /**
  50214. * Sets the gravity vector used by the simulation
  50215. * @param gravity defines the gravity vector to use
  50216. */
  50217. setGravity(gravity: Vector3): void;
  50218. /**
  50219. * Set the time step of the physics engine.
  50220. * Default is 1/60.
  50221. * To slow it down, enter 1/600 for example.
  50222. * To speed it up, 1/30
  50223. * @param newTimeStep defines the new timestep to apply to this world.
  50224. */
  50225. setTimeStep(newTimeStep?: number): void;
  50226. /**
  50227. * Get the time step of the physics engine.
  50228. * @returns the current time step
  50229. */
  50230. getTimeStep(): number;
  50231. /**
  50232. * Release all resources
  50233. */
  50234. dispose(): void;
  50235. /**
  50236. * Gets the name of the current physics plugin
  50237. * @returns the name of the plugin
  50238. */
  50239. getPhysicsPluginName(): string;
  50240. /**
  50241. * Adding a new impostor for the impostor tracking.
  50242. * This will be done by the impostor itself.
  50243. * @param impostor the impostor to add
  50244. */
  50245. addImpostor(impostor: PhysicsImpostor): void;
  50246. /**
  50247. * Remove an impostor from the engine.
  50248. * This impostor and its mesh will not longer be updated by the physics engine.
  50249. * @param impostor the impostor to remove
  50250. */
  50251. removeImpostor(impostor: PhysicsImpostor): void;
  50252. /**
  50253. * Add a joint to the physics engine
  50254. * @param mainImpostor defines the main impostor to which the joint is added.
  50255. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50256. * @param joint defines the joint that will connect both impostors.
  50257. */
  50258. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50259. /**
  50260. * Removes a joint from the simulation
  50261. * @param mainImpostor defines the impostor used with the joint
  50262. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50263. * @param joint defines the joint to remove
  50264. */
  50265. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50266. /**
  50267. * Called by the scene. No need to call it.
  50268. * @param delta defines the timespam between frames
  50269. */
  50270. _step(delta: number): void;
  50271. /**
  50272. * Gets the current plugin used to run the simulation
  50273. * @returns current plugin
  50274. */
  50275. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50276. /**
  50277. * Gets the list of physic impostors
  50278. * @returns an array of PhysicsImpostor
  50279. */
  50280. getImpostors(): Array<PhysicsImpostor>;
  50281. /**
  50282. * Gets the impostor for a physics enabled object
  50283. * @param object defines the object impersonated by the impostor
  50284. * @returns the PhysicsImpostor or null if not found
  50285. */
  50286. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50287. /**
  50288. * Gets the impostor for a physics body object
  50289. * @param body defines physics body used by the impostor
  50290. * @returns the PhysicsImpostor or null if not found
  50291. */
  50292. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50293. /**
  50294. * Does a raycast in the physics world
  50295. * @param from when should the ray start?
  50296. * @param to when should the ray end?
  50297. * @returns PhysicsRaycastResult
  50298. */
  50299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50300. }
  50301. }
  50302. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50303. import { Nullable } from "babylonjs/types";
  50304. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50306. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50307. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50308. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50309. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50310. /** @hidden */
  50311. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50312. private _useDeltaForWorldStep;
  50313. world: any;
  50314. name: string;
  50315. private _physicsMaterials;
  50316. private _fixedTimeStep;
  50317. private _cannonRaycastResult;
  50318. private _raycastResult;
  50319. private _removeAfterStep;
  50320. BJSCANNON: any;
  50321. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50322. setGravity(gravity: Vector3): void;
  50323. setTimeStep(timeStep: number): void;
  50324. getTimeStep(): number;
  50325. executeStep(delta: number): void;
  50326. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50327. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50328. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50329. private _processChildMeshes;
  50330. removePhysicsBody(impostor: PhysicsImpostor): void;
  50331. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50332. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50333. private _addMaterial;
  50334. private _checkWithEpsilon;
  50335. private _createShape;
  50336. private _createHeightmap;
  50337. private _minus90X;
  50338. private _plus90X;
  50339. private _tmpPosition;
  50340. private _tmpDeltaPosition;
  50341. private _tmpUnityRotation;
  50342. private _updatePhysicsBodyTransformation;
  50343. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50344. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50345. isSupported(): boolean;
  50346. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50349. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50350. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50351. getBodyMass(impostor: PhysicsImpostor): number;
  50352. getBodyFriction(impostor: PhysicsImpostor): number;
  50353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50354. getBodyRestitution(impostor: PhysicsImpostor): number;
  50355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50356. sleepBody(impostor: PhysicsImpostor): void;
  50357. wakeUpBody(impostor: PhysicsImpostor): void;
  50358. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50359. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50360. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50361. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50362. getRadius(impostor: PhysicsImpostor): number;
  50363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50364. dispose(): void;
  50365. private _extendNamespace;
  50366. /**
  50367. * Does a raycast in the physics world
  50368. * @param from when should the ray start?
  50369. * @param to when should the ray end?
  50370. * @returns PhysicsRaycastResult
  50371. */
  50372. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50373. }
  50374. }
  50375. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50376. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50377. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50378. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50380. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50381. import { Nullable } from "babylonjs/types";
  50382. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50383. /** @hidden */
  50384. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50385. world: any;
  50386. name: string;
  50387. BJSOIMO: any;
  50388. private _raycastResult;
  50389. constructor(iterations?: number, oimoInjection?: any);
  50390. setGravity(gravity: Vector3): void;
  50391. setTimeStep(timeStep: number): void;
  50392. getTimeStep(): number;
  50393. private _tmpImpostorsArray;
  50394. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50395. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50396. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50397. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50398. private _tmpPositionVector;
  50399. removePhysicsBody(impostor: PhysicsImpostor): void;
  50400. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50401. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50402. isSupported(): boolean;
  50403. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50404. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50405. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50406. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50407. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50408. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50409. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50410. getBodyMass(impostor: PhysicsImpostor): number;
  50411. getBodyFriction(impostor: PhysicsImpostor): number;
  50412. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50413. getBodyRestitution(impostor: PhysicsImpostor): number;
  50414. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50415. sleepBody(impostor: PhysicsImpostor): void;
  50416. wakeUpBody(impostor: PhysicsImpostor): void;
  50417. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50418. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50419. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50420. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50421. getRadius(impostor: PhysicsImpostor): number;
  50422. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50423. dispose(): void;
  50424. /**
  50425. * Does a raycast in the physics world
  50426. * @param from when should the ray start?
  50427. * @param to when should the ray end?
  50428. * @returns PhysicsRaycastResult
  50429. */
  50430. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50431. }
  50432. }
  50433. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50434. import { Nullable } from "babylonjs/types";
  50435. import { Scene } from "babylonjs/scene";
  50436. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50437. import { Mesh } from "babylonjs/Meshes/mesh";
  50438. /**
  50439. * Class containing static functions to help procedurally build meshes
  50440. */
  50441. export class RibbonBuilder {
  50442. /**
  50443. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50444. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50445. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50446. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50447. * * 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
  50448. * * 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
  50449. * * 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
  50450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50453. * * 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
  50454. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50455. * * 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
  50456. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50458. * @param name defines the name of the mesh
  50459. * @param options defines the options used to create the mesh
  50460. * @param scene defines the hosting scene
  50461. * @returns the ribbon mesh
  50462. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50463. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50464. */
  50465. static CreateRibbon(name: string, options: {
  50466. pathArray: Vector3[][];
  50467. closeArray?: boolean;
  50468. closePath?: boolean;
  50469. offset?: number;
  50470. updatable?: boolean;
  50471. sideOrientation?: number;
  50472. frontUVs?: Vector4;
  50473. backUVs?: Vector4;
  50474. instance?: Mesh;
  50475. invertUV?: boolean;
  50476. uvs?: Vector2[];
  50477. colors?: Color4[];
  50478. }, scene?: Nullable<Scene>): Mesh;
  50479. }
  50480. }
  50481. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50482. import { Nullable } from "babylonjs/types";
  50483. import { Scene } from "babylonjs/scene";
  50484. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50485. import { Mesh } from "babylonjs/Meshes/mesh";
  50486. /**
  50487. * Class containing static functions to help procedurally build meshes
  50488. */
  50489. export class ShapeBuilder {
  50490. /**
  50491. * 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.
  50492. * * 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.
  50493. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50494. * * 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.
  50495. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50496. * * 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
  50497. * * 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
  50498. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50503. * @param name defines the name of the mesh
  50504. * @param options defines the options used to create the mesh
  50505. * @param scene defines the hosting scene
  50506. * @returns the extruded shape mesh
  50507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50509. */
  50510. static ExtrudeShape(name: string, options: {
  50511. shape: Vector3[];
  50512. path: Vector3[];
  50513. scale?: number;
  50514. rotation?: number;
  50515. cap?: number;
  50516. updatable?: boolean;
  50517. sideOrientation?: number;
  50518. frontUVs?: Vector4;
  50519. backUVs?: Vector4;
  50520. instance?: Mesh;
  50521. invertUV?: boolean;
  50522. }, scene?: Nullable<Scene>): Mesh;
  50523. /**
  50524. * Creates an custom extruded shape mesh.
  50525. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50526. * * 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.
  50527. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50528. * * 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
  50529. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50530. * * 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
  50531. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50532. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50533. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50534. * * 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
  50535. * * 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
  50536. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50541. * @param name defines the name of the mesh
  50542. * @param options defines the options used to create the mesh
  50543. * @param scene defines the hosting scene
  50544. * @returns the custom extruded shape mesh
  50545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50548. */
  50549. static ExtrudeShapeCustom(name: string, options: {
  50550. shape: Vector3[];
  50551. path: Vector3[];
  50552. scaleFunction?: any;
  50553. rotationFunction?: any;
  50554. ribbonCloseArray?: boolean;
  50555. ribbonClosePath?: boolean;
  50556. cap?: number;
  50557. updatable?: boolean;
  50558. sideOrientation?: number;
  50559. frontUVs?: Vector4;
  50560. backUVs?: Vector4;
  50561. instance?: Mesh;
  50562. invertUV?: boolean;
  50563. }, scene?: Nullable<Scene>): Mesh;
  50564. private static _ExtrudeShapeGeneric;
  50565. }
  50566. }
  50567. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50568. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50569. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50570. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50571. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50572. import { Nullable } from "babylonjs/types";
  50573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50574. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50575. /**
  50576. * AmmoJS Physics plugin
  50577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50578. * @see https://github.com/kripken/ammo.js/
  50579. */
  50580. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50581. private _useDeltaForWorldStep;
  50582. /**
  50583. * Reference to the Ammo library
  50584. */
  50585. bjsAMMO: any;
  50586. /**
  50587. * Created ammoJS world which physics bodies are added to
  50588. */
  50589. world: any;
  50590. /**
  50591. * Name of the plugin
  50592. */
  50593. name: string;
  50594. private _timeStep;
  50595. private _fixedTimeStep;
  50596. private _maxSteps;
  50597. private _tmpQuaternion;
  50598. private _tmpAmmoTransform;
  50599. private _tmpAmmoQuaternion;
  50600. private _tmpAmmoConcreteContactResultCallback;
  50601. private _collisionConfiguration;
  50602. private _dispatcher;
  50603. private _overlappingPairCache;
  50604. private _solver;
  50605. private _softBodySolver;
  50606. private _tmpAmmoVectorA;
  50607. private _tmpAmmoVectorB;
  50608. private _tmpAmmoVectorC;
  50609. private _tmpAmmoVectorD;
  50610. private _tmpContactCallbackResult;
  50611. private _tmpAmmoVectorRCA;
  50612. private _tmpAmmoVectorRCB;
  50613. private _raycastResult;
  50614. private static readonly DISABLE_COLLISION_FLAG;
  50615. private static readonly KINEMATIC_FLAG;
  50616. private static readonly DISABLE_DEACTIVATION_FLAG;
  50617. /**
  50618. * Initializes the ammoJS plugin
  50619. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50620. * @param ammoInjection can be used to inject your own ammo reference
  50621. */
  50622. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50623. /**
  50624. * Sets the gravity of the physics world (m/(s^2))
  50625. * @param gravity Gravity to set
  50626. */
  50627. setGravity(gravity: Vector3): void;
  50628. /**
  50629. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50630. * @param timeStep timestep to use in seconds
  50631. */
  50632. setTimeStep(timeStep: number): void;
  50633. /**
  50634. * 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)
  50635. * @param fixedTimeStep fixedTimeStep to use in seconds
  50636. */
  50637. setFixedTimeStep(fixedTimeStep: number): void;
  50638. /**
  50639. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50640. * @param maxSteps the maximum number of steps by the physics engine per frame
  50641. */
  50642. setMaxSteps(maxSteps: number): void;
  50643. /**
  50644. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50645. * @returns the current timestep in seconds
  50646. */
  50647. getTimeStep(): number;
  50648. private _isImpostorInContact;
  50649. private _isImpostorPairInContact;
  50650. private _stepSimulation;
  50651. /**
  50652. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50653. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50654. * After the step the babylon meshes are set to the position of the physics imposters
  50655. * @param delta amount of time to step forward
  50656. * @param impostors array of imposters to update before/after the step
  50657. */
  50658. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50659. /**
  50660. * Update babylon mesh to match physics world object
  50661. * @param impostor imposter to match
  50662. */
  50663. private _afterSoftStep;
  50664. /**
  50665. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50666. * @param impostor imposter to match
  50667. */
  50668. private _ropeStep;
  50669. /**
  50670. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50671. * @param impostor imposter to match
  50672. */
  50673. private _softbodyOrClothStep;
  50674. private _tmpVector;
  50675. private _tmpMatrix;
  50676. /**
  50677. * Applies an impulse on the imposter
  50678. * @param impostor imposter to apply impulse to
  50679. * @param force amount of force to be applied to the imposter
  50680. * @param contactPoint the location to apply the impulse on the imposter
  50681. */
  50682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50683. /**
  50684. * Applies a force on the imposter
  50685. * @param impostor imposter to apply force
  50686. * @param force amount of force to be applied to the imposter
  50687. * @param contactPoint the location to apply the force on the imposter
  50688. */
  50689. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50690. /**
  50691. * Creates a physics body using the plugin
  50692. * @param impostor the imposter to create the physics body on
  50693. */
  50694. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50695. /**
  50696. * Removes the physics body from the imposter and disposes of the body's memory
  50697. * @param impostor imposter to remove the physics body from
  50698. */
  50699. removePhysicsBody(impostor: PhysicsImpostor): void;
  50700. /**
  50701. * Generates a joint
  50702. * @param impostorJoint the imposter joint to create the joint with
  50703. */
  50704. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50705. /**
  50706. * Removes a joint
  50707. * @param impostorJoint the imposter joint to remove the joint from
  50708. */
  50709. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50710. private _addMeshVerts;
  50711. /**
  50712. * Initialise the soft body vertices to match its object's (mesh) vertices
  50713. * Softbody vertices (nodes) are in world space and to match this
  50714. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50715. * @param impostor to create the softbody for
  50716. */
  50717. private _softVertexData;
  50718. /**
  50719. * Create an impostor's soft body
  50720. * @param impostor to create the softbody for
  50721. */
  50722. private _createSoftbody;
  50723. /**
  50724. * Create cloth for an impostor
  50725. * @param impostor to create the softbody for
  50726. */
  50727. private _createCloth;
  50728. /**
  50729. * Create rope for an impostor
  50730. * @param impostor to create the softbody for
  50731. */
  50732. private _createRope;
  50733. private _addHullVerts;
  50734. private _createShape;
  50735. /**
  50736. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50737. * @param impostor imposter containing the physics body and babylon object
  50738. */
  50739. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50740. /**
  50741. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50742. * @param impostor imposter containing the physics body and babylon object
  50743. * @param newPosition new position
  50744. * @param newRotation new rotation
  50745. */
  50746. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50747. /**
  50748. * If this plugin is supported
  50749. * @returns true if its supported
  50750. */
  50751. isSupported(): boolean;
  50752. /**
  50753. * Sets the linear velocity of the physics body
  50754. * @param impostor imposter to set the velocity on
  50755. * @param velocity velocity to set
  50756. */
  50757. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50758. /**
  50759. * Sets the angular velocity of the physics body
  50760. * @param impostor imposter to set the velocity on
  50761. * @param velocity velocity to set
  50762. */
  50763. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50764. /**
  50765. * gets the linear velocity
  50766. * @param impostor imposter to get linear velocity from
  50767. * @returns linear velocity
  50768. */
  50769. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50770. /**
  50771. * gets the angular velocity
  50772. * @param impostor imposter to get angular velocity from
  50773. * @returns angular velocity
  50774. */
  50775. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50776. /**
  50777. * Sets the mass of physics body
  50778. * @param impostor imposter to set the mass on
  50779. * @param mass mass to set
  50780. */
  50781. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50782. /**
  50783. * Gets the mass of the physics body
  50784. * @param impostor imposter to get the mass from
  50785. * @returns mass
  50786. */
  50787. getBodyMass(impostor: PhysicsImpostor): number;
  50788. /**
  50789. * Gets friction of the impostor
  50790. * @param impostor impostor to get friction from
  50791. * @returns friction value
  50792. */
  50793. getBodyFriction(impostor: PhysicsImpostor): number;
  50794. /**
  50795. * Sets friction of the impostor
  50796. * @param impostor impostor to set friction on
  50797. * @param friction friction value
  50798. */
  50799. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50800. /**
  50801. * Gets restitution of the impostor
  50802. * @param impostor impostor to get restitution from
  50803. * @returns restitution value
  50804. */
  50805. getBodyRestitution(impostor: PhysicsImpostor): number;
  50806. /**
  50807. * Sets resitution of the impostor
  50808. * @param impostor impostor to set resitution on
  50809. * @param restitution resitution value
  50810. */
  50811. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50812. /**
  50813. * Gets pressure inside the impostor
  50814. * @param impostor impostor to get pressure from
  50815. * @returns pressure value
  50816. */
  50817. getBodyPressure(impostor: PhysicsImpostor): number;
  50818. /**
  50819. * Sets pressure inside a soft body impostor
  50820. * Cloth and rope must remain 0 pressure
  50821. * @param impostor impostor to set pressure on
  50822. * @param pressure pressure value
  50823. */
  50824. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50825. /**
  50826. * Gets stiffness of the impostor
  50827. * @param impostor impostor to get stiffness from
  50828. * @returns pressure value
  50829. */
  50830. getBodyStiffness(impostor: PhysicsImpostor): number;
  50831. /**
  50832. * Sets stiffness of the impostor
  50833. * @param impostor impostor to set stiffness on
  50834. * @param stiffness stiffness value from 0 to 1
  50835. */
  50836. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50837. /**
  50838. * Gets velocityIterations of the impostor
  50839. * @param impostor impostor to get velocity iterations from
  50840. * @returns velocityIterations value
  50841. */
  50842. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50843. /**
  50844. * Sets velocityIterations of the impostor
  50845. * @param impostor impostor to set velocity iterations on
  50846. * @param velocityIterations velocityIterations value
  50847. */
  50848. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50849. /**
  50850. * Gets positionIterations of the impostor
  50851. * @param impostor impostor to get position iterations from
  50852. * @returns positionIterations value
  50853. */
  50854. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50855. /**
  50856. * Sets positionIterations of the impostor
  50857. * @param impostor impostor to set position on
  50858. * @param positionIterations positionIterations value
  50859. */
  50860. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50861. /**
  50862. * Append an anchor to a cloth object
  50863. * @param impostor is the cloth impostor to add anchor to
  50864. * @param otherImpostor is the rigid impostor to anchor to
  50865. * @param width ratio across width from 0 to 1
  50866. * @param height ratio up height from 0 to 1
  50867. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50868. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50869. */
  50870. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50871. /**
  50872. * Append an hook to a rope object
  50873. * @param impostor is the rope impostor to add hook to
  50874. * @param otherImpostor is the rigid impostor to hook to
  50875. * @param length ratio along the rope from 0 to 1
  50876. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50877. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50878. */
  50879. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50880. /**
  50881. * Sleeps the physics body and stops it from being active
  50882. * @param impostor impostor to sleep
  50883. */
  50884. sleepBody(impostor: PhysicsImpostor): void;
  50885. /**
  50886. * Activates the physics body
  50887. * @param impostor impostor to activate
  50888. */
  50889. wakeUpBody(impostor: PhysicsImpostor): void;
  50890. /**
  50891. * Updates the distance parameters of the joint
  50892. * @param joint joint to update
  50893. * @param maxDistance maximum distance of the joint
  50894. * @param minDistance minimum distance of the joint
  50895. */
  50896. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50897. /**
  50898. * Sets a motor on the joint
  50899. * @param joint joint to set motor on
  50900. * @param speed speed of the motor
  50901. * @param maxForce maximum force of the motor
  50902. * @param motorIndex index of the motor
  50903. */
  50904. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50905. /**
  50906. * Sets the motors limit
  50907. * @param joint joint to set limit on
  50908. * @param upperLimit upper limit
  50909. * @param lowerLimit lower limit
  50910. */
  50911. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50912. /**
  50913. * Syncs the position and rotation of a mesh with the impostor
  50914. * @param mesh mesh to sync
  50915. * @param impostor impostor to update the mesh with
  50916. */
  50917. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50918. /**
  50919. * Gets the radius of the impostor
  50920. * @param impostor impostor to get radius from
  50921. * @returns the radius
  50922. */
  50923. getRadius(impostor: PhysicsImpostor): number;
  50924. /**
  50925. * Gets the box size of the impostor
  50926. * @param impostor impostor to get box size from
  50927. * @param result the resulting box size
  50928. */
  50929. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50930. /**
  50931. * Disposes of the impostor
  50932. */
  50933. dispose(): void;
  50934. /**
  50935. * Does a raycast in the physics world
  50936. * @param from when should the ray start?
  50937. * @param to when should the ray end?
  50938. * @returns PhysicsRaycastResult
  50939. */
  50940. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50941. }
  50942. }
  50943. declare module "babylonjs/Probes/reflectionProbe" {
  50944. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50945. import { Vector3 } from "babylonjs/Maths/math";
  50946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50947. import { Nullable } from "babylonjs/types";
  50948. import { Scene } from "babylonjs/scene";
  50949. module "babylonjs/abstractScene" {
  50950. interface AbstractScene {
  50951. /**
  50952. * The list of reflection probes added to the scene
  50953. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50954. */
  50955. reflectionProbes: Array<ReflectionProbe>;
  50956. /**
  50957. * Removes the given reflection probe from this scene.
  50958. * @param toRemove The reflection probe to remove
  50959. * @returns The index of the removed reflection probe
  50960. */
  50961. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50962. /**
  50963. * Adds the given reflection probe to this scene.
  50964. * @param newReflectionProbe The reflection probe to add
  50965. */
  50966. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50967. }
  50968. }
  50969. /**
  50970. * Class used to generate realtime reflection / refraction cube textures
  50971. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50972. */
  50973. export class ReflectionProbe {
  50974. /** defines the name of the probe */
  50975. name: string;
  50976. private _scene;
  50977. private _renderTargetTexture;
  50978. private _projectionMatrix;
  50979. private _viewMatrix;
  50980. private _target;
  50981. private _add;
  50982. private _attachedMesh;
  50983. private _invertYAxis;
  50984. /** Gets or sets probe position (center of the cube map) */
  50985. position: Vector3;
  50986. /**
  50987. * Creates a new reflection probe
  50988. * @param name defines the name of the probe
  50989. * @param size defines the texture resolution (for each face)
  50990. * @param scene defines the hosting scene
  50991. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50992. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50993. */
  50994. constructor(
  50995. /** defines the name of the probe */
  50996. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50997. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50998. samples: number;
  50999. /** Gets or sets the refresh rate to use (on every frame by default) */
  51000. refreshRate: number;
  51001. /**
  51002. * Gets the hosting scene
  51003. * @returns a Scene
  51004. */
  51005. getScene(): Scene;
  51006. /** Gets the internal CubeTexture used to render to */
  51007. readonly cubeTexture: RenderTargetTexture;
  51008. /** Gets the list of meshes to render */
  51009. readonly renderList: Nullable<AbstractMesh[]>;
  51010. /**
  51011. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51012. * @param mesh defines the mesh to attach to
  51013. */
  51014. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51015. /**
  51016. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51017. * @param renderingGroupId The rendering group id corresponding to its index
  51018. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51019. */
  51020. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51021. /**
  51022. * Clean all associated resources
  51023. */
  51024. dispose(): void;
  51025. /**
  51026. * Converts the reflection probe information to a readable string for debug purpose.
  51027. * @param fullDetails Supports for multiple levels of logging within scene loading
  51028. * @returns the human readable reflection probe info
  51029. */
  51030. toString(fullDetails?: boolean): string;
  51031. /**
  51032. * Get the class name of the relfection probe.
  51033. * @returns "ReflectionProbe"
  51034. */
  51035. getClassName(): string;
  51036. /**
  51037. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51038. * @returns The JSON representation of the texture
  51039. */
  51040. serialize(): any;
  51041. /**
  51042. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51043. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51044. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51045. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51046. * @returns The parsed reflection probe if successful
  51047. */
  51048. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51049. }
  51050. }
  51051. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51052. /** @hidden */
  51053. export var _BabylonLoaderRegistered: boolean;
  51054. }
  51055. declare module "babylonjs/Loading/Plugins/index" {
  51056. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51057. }
  51058. declare module "babylonjs/Loading/index" {
  51059. export * from "babylonjs/Loading/loadingScreen";
  51060. export * from "babylonjs/Loading/Plugins/index";
  51061. export * from "babylonjs/Loading/sceneLoader";
  51062. export * from "babylonjs/Loading/sceneLoaderFlags";
  51063. }
  51064. declare module "babylonjs/Materials/Background/index" {
  51065. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51066. }
  51067. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51068. import { Scene } from "babylonjs/scene";
  51069. import { Color3 } from "babylonjs/Maths/math";
  51070. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51072. /**
  51073. * The Physically based simple base material of BJS.
  51074. *
  51075. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51076. * It is used as the base class for both the specGloss and metalRough conventions.
  51077. */
  51078. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51079. /**
  51080. * Number of Simultaneous lights allowed on the material.
  51081. */
  51082. maxSimultaneousLights: number;
  51083. /**
  51084. * If sets to true, disables all the lights affecting the material.
  51085. */
  51086. disableLighting: boolean;
  51087. /**
  51088. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51089. */
  51090. environmentTexture: BaseTexture;
  51091. /**
  51092. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51093. */
  51094. invertNormalMapX: boolean;
  51095. /**
  51096. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51097. */
  51098. invertNormalMapY: boolean;
  51099. /**
  51100. * Normal map used in the model.
  51101. */
  51102. normalTexture: BaseTexture;
  51103. /**
  51104. * Emissivie color used to self-illuminate the model.
  51105. */
  51106. emissiveColor: Color3;
  51107. /**
  51108. * Emissivie texture used to self-illuminate the model.
  51109. */
  51110. emissiveTexture: BaseTexture;
  51111. /**
  51112. * Occlusion Channel Strenght.
  51113. */
  51114. occlusionStrength: number;
  51115. /**
  51116. * Occlusion Texture of the material (adding extra occlusion effects).
  51117. */
  51118. occlusionTexture: BaseTexture;
  51119. /**
  51120. * Defines the alpha limits in alpha test mode.
  51121. */
  51122. alphaCutOff: number;
  51123. /**
  51124. * Gets the current double sided mode.
  51125. */
  51126. /**
  51127. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51128. */
  51129. doubleSided: boolean;
  51130. /**
  51131. * Stores the pre-calculated light information of a mesh in a texture.
  51132. */
  51133. lightmapTexture: BaseTexture;
  51134. /**
  51135. * If true, the light map contains occlusion information instead of lighting info.
  51136. */
  51137. useLightmapAsShadowmap: boolean;
  51138. /**
  51139. * Instantiates a new PBRMaterial instance.
  51140. *
  51141. * @param name The material name
  51142. * @param scene The scene the material will be use in.
  51143. */
  51144. constructor(name: string, scene: Scene);
  51145. getClassName(): string;
  51146. }
  51147. }
  51148. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51149. import { Scene } from "babylonjs/scene";
  51150. import { Color3 } from "babylonjs/Maths/math";
  51151. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51152. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51153. /**
  51154. * The PBR material of BJS following the metal roughness convention.
  51155. *
  51156. * This fits to the PBR convention in the GLTF definition:
  51157. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51158. */
  51159. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51160. /**
  51161. * The base color has two different interpretations depending on the value of metalness.
  51162. * When the material is a metal, the base color is the specific measured reflectance value
  51163. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51164. * of the material.
  51165. */
  51166. baseColor: Color3;
  51167. /**
  51168. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51169. * well as opacity information in the alpha channel.
  51170. */
  51171. baseTexture: BaseTexture;
  51172. /**
  51173. * Specifies the metallic scalar value of the material.
  51174. * Can also be used to scale the metalness values of the metallic texture.
  51175. */
  51176. metallic: number;
  51177. /**
  51178. * Specifies the roughness scalar value of the material.
  51179. * Can also be used to scale the roughness values of the metallic texture.
  51180. */
  51181. roughness: number;
  51182. /**
  51183. * Texture containing both the metallic value in the B channel and the
  51184. * roughness value in the G channel to keep better precision.
  51185. */
  51186. metallicRoughnessTexture: BaseTexture;
  51187. /**
  51188. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51189. *
  51190. * @param name The material name
  51191. * @param scene The scene the material will be use in.
  51192. */
  51193. constructor(name: string, scene: Scene);
  51194. /**
  51195. * Return the currrent class name of the material.
  51196. */
  51197. getClassName(): string;
  51198. /**
  51199. * Makes a duplicate of the current material.
  51200. * @param name - name to use for the new material.
  51201. */
  51202. clone(name: string): PBRMetallicRoughnessMaterial;
  51203. /**
  51204. * Serialize the material to a parsable JSON object.
  51205. */
  51206. serialize(): any;
  51207. /**
  51208. * Parses a JSON object correponding to the serialize function.
  51209. */
  51210. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51211. }
  51212. }
  51213. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51214. import { Scene } from "babylonjs/scene";
  51215. import { Color3 } from "babylonjs/Maths/math";
  51216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51217. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51218. /**
  51219. * The PBR material of BJS following the specular glossiness convention.
  51220. *
  51221. * This fits to the PBR convention in the GLTF definition:
  51222. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51223. */
  51224. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51225. /**
  51226. * Specifies the diffuse color of the material.
  51227. */
  51228. diffuseColor: Color3;
  51229. /**
  51230. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51231. * channel.
  51232. */
  51233. diffuseTexture: BaseTexture;
  51234. /**
  51235. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51236. */
  51237. specularColor: Color3;
  51238. /**
  51239. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51240. */
  51241. glossiness: number;
  51242. /**
  51243. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51244. */
  51245. specularGlossinessTexture: BaseTexture;
  51246. /**
  51247. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51248. *
  51249. * @param name The material name
  51250. * @param scene The scene the material will be use in.
  51251. */
  51252. constructor(name: string, scene: Scene);
  51253. /**
  51254. * Return the currrent class name of the material.
  51255. */
  51256. getClassName(): string;
  51257. /**
  51258. * Makes a duplicate of the current material.
  51259. * @param name - name to use for the new material.
  51260. */
  51261. clone(name: string): PBRSpecularGlossinessMaterial;
  51262. /**
  51263. * Serialize the material to a parsable JSON object.
  51264. */
  51265. serialize(): any;
  51266. /**
  51267. * Parses a JSON object correponding to the serialize function.
  51268. */
  51269. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51270. }
  51271. }
  51272. declare module "babylonjs/Materials/PBR/index" {
  51273. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51274. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51275. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51276. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51277. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51278. }
  51279. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51280. import { Nullable } from "babylonjs/types";
  51281. import { Scene } from "babylonjs/scene";
  51282. import { Matrix } from "babylonjs/Maths/math";
  51283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51284. /**
  51285. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51286. * It can help converting any input color in a desired output one. This can then be used to create effects
  51287. * from sepia, black and white to sixties or futuristic rendering...
  51288. *
  51289. * The only supported format is currently 3dl.
  51290. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51291. */
  51292. export class ColorGradingTexture extends BaseTexture {
  51293. /**
  51294. * The current texture matrix. (will always be identity in color grading texture)
  51295. */
  51296. private _textureMatrix;
  51297. /**
  51298. * The texture URL.
  51299. */
  51300. url: string;
  51301. /**
  51302. * Empty line regex stored for GC.
  51303. */
  51304. private static _noneEmptyLineRegex;
  51305. private _engine;
  51306. /**
  51307. * Instantiates a ColorGradingTexture from the following parameters.
  51308. *
  51309. * @param url The location of the color gradind data (currently only supporting 3dl)
  51310. * @param scene The scene the texture will be used in
  51311. */
  51312. constructor(url: string, scene: Scene);
  51313. /**
  51314. * Returns the texture matrix used in most of the material.
  51315. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51316. */
  51317. getTextureMatrix(): Matrix;
  51318. /**
  51319. * Occurs when the file being loaded is a .3dl LUT file.
  51320. */
  51321. private load3dlTexture;
  51322. /**
  51323. * Starts the loading process of the texture.
  51324. */
  51325. private loadTexture;
  51326. /**
  51327. * Clones the color gradind texture.
  51328. */
  51329. clone(): ColorGradingTexture;
  51330. /**
  51331. * Called during delayed load for textures.
  51332. */
  51333. delayLoad(): void;
  51334. /**
  51335. * Parses a color grading texture serialized by Babylon.
  51336. * @param parsedTexture The texture information being parsedTexture
  51337. * @param scene The scene to load the texture in
  51338. * @param rootUrl The root url of the data assets to load
  51339. * @return A color gradind texture
  51340. */
  51341. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51342. /**
  51343. * Serializes the LUT texture to json format.
  51344. */
  51345. serialize(): any;
  51346. }
  51347. }
  51348. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51350. import { Scene } from "babylonjs/scene";
  51351. import { Nullable } from "babylonjs/types";
  51352. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51353. /**
  51354. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51355. */
  51356. export class EquiRectangularCubeTexture extends BaseTexture {
  51357. /** The six faces of the cube. */
  51358. private static _FacesMapping;
  51359. private _noMipmap;
  51360. private _onLoad;
  51361. private _onError;
  51362. /** The size of the cubemap. */
  51363. private _size;
  51364. /** The buffer of the image. */
  51365. private _buffer;
  51366. /** The width of the input image. */
  51367. private _width;
  51368. /** The height of the input image. */
  51369. private _height;
  51370. /** The URL to the image. */
  51371. url: string;
  51372. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51373. coordinatesMode: number;
  51374. /**
  51375. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51376. * @param url The location of the image
  51377. * @param scene The scene the texture will be used in
  51378. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51379. * @param noMipmap Forces to not generate the mipmap if true
  51380. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51381. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51382. * @param onLoad — defines a callback called when texture is loaded
  51383. * @param onError — defines a callback called if there is an error
  51384. */
  51385. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51386. /**
  51387. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51388. */
  51389. private loadImage;
  51390. /**
  51391. * Convert the image buffer into a cubemap and create a CubeTexture.
  51392. */
  51393. private loadTexture;
  51394. /**
  51395. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51396. * @param buffer The ArrayBuffer that should be converted.
  51397. * @returns The buffer as Float32Array.
  51398. */
  51399. private getFloat32ArrayFromArrayBuffer;
  51400. /**
  51401. * Get the current class name of the texture useful for serialization or dynamic coding.
  51402. * @returns "EquiRectangularCubeTexture"
  51403. */
  51404. getClassName(): string;
  51405. /**
  51406. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51407. * @returns A clone of the current EquiRectangularCubeTexture.
  51408. */
  51409. clone(): EquiRectangularCubeTexture;
  51410. }
  51411. }
  51412. declare module "babylonjs/Misc/tga" {
  51413. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51414. /**
  51415. * Based on jsTGALoader - Javascript loader for TGA file
  51416. * By Vincent Thibault
  51417. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51418. */
  51419. export class TGATools {
  51420. private static _TYPE_INDEXED;
  51421. private static _TYPE_RGB;
  51422. private static _TYPE_GREY;
  51423. private static _TYPE_RLE_INDEXED;
  51424. private static _TYPE_RLE_RGB;
  51425. private static _TYPE_RLE_GREY;
  51426. private static _ORIGIN_MASK;
  51427. private static _ORIGIN_SHIFT;
  51428. private static _ORIGIN_BL;
  51429. private static _ORIGIN_BR;
  51430. private static _ORIGIN_UL;
  51431. private static _ORIGIN_UR;
  51432. /**
  51433. * Gets the header of a TGA file
  51434. * @param data defines the TGA data
  51435. * @returns the header
  51436. */
  51437. static GetTGAHeader(data: Uint8Array): any;
  51438. /**
  51439. * Uploads TGA content to a Babylon Texture
  51440. * @hidden
  51441. */
  51442. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51443. /** @hidden */
  51444. 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;
  51445. /** @hidden */
  51446. 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;
  51447. /** @hidden */
  51448. 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;
  51449. /** @hidden */
  51450. 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;
  51451. /** @hidden */
  51452. 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;
  51453. /** @hidden */
  51454. 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;
  51455. }
  51456. }
  51457. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51458. import { Nullable } from "babylonjs/types";
  51459. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51460. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51461. /**
  51462. * Implementation of the TGA Texture Loader.
  51463. * @hidden
  51464. */
  51465. export class _TGATextureLoader implements IInternalTextureLoader {
  51466. /**
  51467. * Defines wether the loader supports cascade loading the different faces.
  51468. */
  51469. readonly supportCascades: boolean;
  51470. /**
  51471. * This returns if the loader support the current file information.
  51472. * @param extension defines the file extension of the file being loaded
  51473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51474. * @param fallback defines the fallback internal texture if any
  51475. * @param isBase64 defines whether the texture is encoded as a base64
  51476. * @param isBuffer defines whether the texture data are stored as a buffer
  51477. * @returns true if the loader can load the specified file
  51478. */
  51479. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51480. /**
  51481. * Transform the url before loading if required.
  51482. * @param rootUrl the url of the texture
  51483. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51484. * @returns the transformed texture
  51485. */
  51486. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51487. /**
  51488. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51489. * @param rootUrl the url of the texture
  51490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51491. * @returns the fallback texture
  51492. */
  51493. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51494. /**
  51495. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51496. * @param data contains the texture data
  51497. * @param texture defines the BabylonJS internal texture
  51498. * @param createPolynomials will be true if polynomials have been requested
  51499. * @param onLoad defines the callback to trigger once the texture is ready
  51500. * @param onError defines the callback to trigger in case of error
  51501. */
  51502. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51503. /**
  51504. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51505. * @param data contains the texture data
  51506. * @param texture defines the BabylonJS internal texture
  51507. * @param callback defines the method to call once ready to upload
  51508. */
  51509. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51510. }
  51511. }
  51512. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51513. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51514. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51515. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51516. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51517. }
  51518. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51519. import { Scene } from "babylonjs/scene";
  51520. import { Texture } from "babylonjs/Materials/Textures/texture";
  51521. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51522. /**
  51523. * 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.
  51524. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51525. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51526. */
  51527. export class CustomProceduralTexture extends ProceduralTexture {
  51528. private _animate;
  51529. private _time;
  51530. private _config;
  51531. private _texturePath;
  51532. /**
  51533. * Instantiates a new Custom Procedural Texture.
  51534. * 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.
  51535. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51536. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51537. * @param name Define the name of the texture
  51538. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51539. * @param size Define the size of the texture to create
  51540. * @param scene Define the scene the texture belongs to
  51541. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51542. * @param generateMipMaps Define if the texture should creates mip maps or not
  51543. */
  51544. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51545. private _loadJson;
  51546. /**
  51547. * Is the texture ready to be used ? (rendered at least once)
  51548. * @returns true if ready, otherwise, false.
  51549. */
  51550. isReady(): boolean;
  51551. /**
  51552. * Render the texture to its associated render target.
  51553. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51554. */
  51555. render(useCameraPostProcess?: boolean): void;
  51556. /**
  51557. * Update the list of dependant textures samplers in the shader.
  51558. */
  51559. updateTextures(): void;
  51560. /**
  51561. * Update the uniform values of the procedural texture in the shader.
  51562. */
  51563. updateShaderUniforms(): void;
  51564. /**
  51565. * Define if the texture animates or not.
  51566. */
  51567. animate: boolean;
  51568. }
  51569. }
  51570. declare module "babylonjs/Shaders/noise.fragment" {
  51571. /** @hidden */
  51572. export var noisePixelShader: {
  51573. name: string;
  51574. shader: string;
  51575. };
  51576. }
  51577. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51578. import { Nullable } from "babylonjs/types";
  51579. import { Scene } from "babylonjs/scene";
  51580. import { Texture } from "babylonjs/Materials/Textures/texture";
  51581. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51582. import "babylonjs/Shaders/noise.fragment";
  51583. /**
  51584. * Class used to generate noise procedural textures
  51585. */
  51586. export class NoiseProceduralTexture extends ProceduralTexture {
  51587. private _time;
  51588. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51589. brightness: number;
  51590. /** Defines the number of octaves to process */
  51591. octaves: number;
  51592. /** Defines the level of persistence (0.8 by default) */
  51593. persistence: number;
  51594. /** Gets or sets animation speed factor (default is 1) */
  51595. animationSpeedFactor: number;
  51596. /**
  51597. * Creates a new NoiseProceduralTexture
  51598. * @param name defines the name fo the texture
  51599. * @param size defines the size of the texture (default is 256)
  51600. * @param scene defines the hosting scene
  51601. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51602. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51603. */
  51604. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51605. private _updateShaderUniforms;
  51606. protected _getDefines(): string;
  51607. /** Generate the current state of the procedural texture */
  51608. render(useCameraPostProcess?: boolean): void;
  51609. /**
  51610. * Serializes this noise procedural texture
  51611. * @returns a serialized noise procedural texture object
  51612. */
  51613. serialize(): any;
  51614. /**
  51615. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51616. * @param parsedTexture defines parsed texture data
  51617. * @param scene defines the current scene
  51618. * @param rootUrl defines the root URL containing noise procedural texture information
  51619. * @returns a parsed NoiseProceduralTexture
  51620. */
  51621. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51622. }
  51623. }
  51624. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51625. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51626. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51627. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51628. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51629. }
  51630. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51631. import { Nullable } from "babylonjs/types";
  51632. import { Scene } from "babylonjs/scene";
  51633. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51635. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51636. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51637. /**
  51638. * Raw cube texture where the raw buffers are passed in
  51639. */
  51640. export class RawCubeTexture extends CubeTexture {
  51641. /**
  51642. * Creates a cube texture where the raw buffers are passed in.
  51643. * @param scene defines the scene the texture is attached to
  51644. * @param data defines the array of data to use to create each face
  51645. * @param size defines the size of the textures
  51646. * @param format defines the format of the data
  51647. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51648. * @param generateMipMaps defines if the engine should generate the mip levels
  51649. * @param invertY defines if data must be stored with Y axis inverted
  51650. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51651. * @param compression defines the compression used (null by default)
  51652. */
  51653. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51654. /**
  51655. * Updates the raw cube texture.
  51656. * @param data defines the data to store
  51657. * @param format defines the data format
  51658. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51659. * @param invertY defines if data must be stored with Y axis inverted
  51660. * @param compression defines the compression used (null by default)
  51661. * @param level defines which level of the texture to update
  51662. */
  51663. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51664. /**
  51665. * Updates a raw cube texture with RGBD encoded data.
  51666. * @param data defines the array of data [mipmap][face] to use to create each face
  51667. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51668. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51669. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51670. * @returns a promsie that resolves when the operation is complete
  51671. */
  51672. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51673. /**
  51674. * Clones the raw cube texture.
  51675. * @return a new cube texture
  51676. */
  51677. clone(): CubeTexture;
  51678. /** @hidden */
  51679. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51680. }
  51681. }
  51682. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51683. import { Scene } from "babylonjs/scene";
  51684. import { Texture } from "babylonjs/Materials/Textures/texture";
  51685. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51686. /**
  51687. * Class used to store 3D textures containing user data
  51688. */
  51689. export class RawTexture3D extends Texture {
  51690. /** Gets or sets the texture format to use */
  51691. format: number;
  51692. private _engine;
  51693. /**
  51694. * Create a new RawTexture3D
  51695. * @param data defines the data of the texture
  51696. * @param width defines the width of the texture
  51697. * @param height defines the height of the texture
  51698. * @param depth defines the depth of the texture
  51699. * @param format defines the texture format to use
  51700. * @param scene defines the hosting scene
  51701. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51702. * @param invertY defines if texture must be stored with Y axis inverted
  51703. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51704. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51705. */
  51706. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51707. /** Gets or sets the texture format to use */
  51708. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51709. /**
  51710. * Update the texture with new data
  51711. * @param data defines the data to store in the texture
  51712. */
  51713. update(data: ArrayBufferView): void;
  51714. }
  51715. }
  51716. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51717. import { Scene } from "babylonjs/scene";
  51718. import { Plane } from "babylonjs/Maths/math";
  51719. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51720. /**
  51721. * Creates a refraction texture used by refraction channel of the standard material.
  51722. * It is like a mirror but to see through a material.
  51723. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51724. */
  51725. export class RefractionTexture extends RenderTargetTexture {
  51726. /**
  51727. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51728. * 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.
  51729. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51730. */
  51731. refractionPlane: Plane;
  51732. /**
  51733. * Define how deep under the surface we should see.
  51734. */
  51735. depth: number;
  51736. /**
  51737. * Creates a refraction texture used by refraction channel of the standard material.
  51738. * It is like a mirror but to see through a material.
  51739. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51740. * @param name Define the texture name
  51741. * @param size Define the size of the underlying texture
  51742. * @param scene Define the scene the refraction belongs to
  51743. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51744. */
  51745. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51746. /**
  51747. * Clone the refraction texture.
  51748. * @returns the cloned texture
  51749. */
  51750. clone(): RefractionTexture;
  51751. /**
  51752. * Serialize the texture to a JSON representation you could use in Parse later on
  51753. * @returns the serialized JSON representation
  51754. */
  51755. serialize(): any;
  51756. }
  51757. }
  51758. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51759. import { Nullable } from "babylonjs/types";
  51760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51761. import { Matrix } from "babylonjs/Maths/math";
  51762. import { Engine } from "babylonjs/Engines/engine";
  51763. import { Scene } from "babylonjs/scene";
  51764. /**
  51765. * Defines the options related to the creation of an HtmlElementTexture
  51766. */
  51767. export interface IHtmlElementTextureOptions {
  51768. /**
  51769. * Defines wether mip maps should be created or not.
  51770. */
  51771. generateMipMaps?: boolean;
  51772. /**
  51773. * Defines the sampling mode of the texture.
  51774. */
  51775. samplingMode?: number;
  51776. /**
  51777. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51778. */
  51779. engine: Nullable<Engine>;
  51780. /**
  51781. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51782. */
  51783. scene: Nullable<Scene>;
  51784. }
  51785. /**
  51786. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51787. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51788. * is automatically managed.
  51789. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51790. * in your application.
  51791. *
  51792. * As the update is not automatic, you need to call them manually.
  51793. */
  51794. export class HtmlElementTexture extends BaseTexture {
  51795. /**
  51796. * The texture URL.
  51797. */
  51798. element: HTMLVideoElement | HTMLCanvasElement;
  51799. private static readonly DefaultOptions;
  51800. private _textureMatrix;
  51801. private _engine;
  51802. private _isVideo;
  51803. private _generateMipMaps;
  51804. private _samplingMode;
  51805. /**
  51806. * Instantiates a HtmlElementTexture from the following parameters.
  51807. *
  51808. * @param name Defines the name of the texture
  51809. * @param element Defines the video or canvas the texture is filled with
  51810. * @param options Defines the other none mandatory texture creation options
  51811. */
  51812. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51813. private _createInternalTexture;
  51814. /**
  51815. * Returns the texture matrix used in most of the material.
  51816. */
  51817. getTextureMatrix(): Matrix;
  51818. /**
  51819. * Updates the content of the texture.
  51820. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51821. */
  51822. update(invertY?: Nullable<boolean>): void;
  51823. }
  51824. }
  51825. declare module "babylonjs/Materials/Textures/index" {
  51826. export * from "babylonjs/Materials/Textures/baseTexture";
  51827. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51828. export * from "babylonjs/Materials/Textures/cubeTexture";
  51829. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51830. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51831. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51832. export * from "babylonjs/Materials/Textures/internalTexture";
  51833. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51834. export * from "babylonjs/Materials/Textures/Loaders/index";
  51835. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51836. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51837. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51838. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51839. export * from "babylonjs/Materials/Textures/rawTexture";
  51840. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51841. export * from "babylonjs/Materials/Textures/refractionTexture";
  51842. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51843. export * from "babylonjs/Materials/Textures/texture";
  51844. export * from "babylonjs/Materials/Textures/videoTexture";
  51845. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51846. }
  51847. declare module "babylonjs/Materials/index" {
  51848. export * from "babylonjs/Materials/Background/index";
  51849. export * from "babylonjs/Materials/colorCurves";
  51850. export * from "babylonjs/Materials/effect";
  51851. export * from "babylonjs/Materials/fresnelParameters";
  51852. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51853. export * from "babylonjs/Materials/material";
  51854. export * from "babylonjs/Materials/materialDefines";
  51855. export * from "babylonjs/Materials/materialHelper";
  51856. export * from "babylonjs/Materials/multiMaterial";
  51857. export * from "babylonjs/Materials/PBR/index";
  51858. export * from "babylonjs/Materials/pushMaterial";
  51859. export * from "babylonjs/Materials/shaderMaterial";
  51860. export * from "babylonjs/Materials/standardMaterial";
  51861. export * from "babylonjs/Materials/Textures/index";
  51862. export * from "babylonjs/Materials/uniformBuffer";
  51863. export * from "babylonjs/Materials/materialFlags";
  51864. }
  51865. declare module "babylonjs/Maths/index" {
  51866. export * from "babylonjs/Maths/math.scalar";
  51867. export * from "babylonjs/Maths/math";
  51868. export * from "babylonjs/Maths/sphericalPolynomial";
  51869. }
  51870. declare module "babylonjs/Misc/workerPool" {
  51871. import { IDisposable } from "babylonjs/scene";
  51872. /**
  51873. * Helper class to push actions to a pool of workers.
  51874. */
  51875. export class WorkerPool implements IDisposable {
  51876. private _workerInfos;
  51877. private _pendingActions;
  51878. /**
  51879. * Constructor
  51880. * @param workers Array of workers to use for actions
  51881. */
  51882. constructor(workers: Array<Worker>);
  51883. /**
  51884. * Terminates all workers and clears any pending actions.
  51885. */
  51886. dispose(): void;
  51887. /**
  51888. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51889. * pended until a worker has completed its action.
  51890. * @param action The action to perform. Call onComplete when the action is complete.
  51891. */
  51892. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51893. private _execute;
  51894. }
  51895. }
  51896. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51897. import { IDisposable } from "babylonjs/scene";
  51898. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51899. /**
  51900. * Configuration for Draco compression
  51901. */
  51902. export interface IDracoCompressionConfiguration {
  51903. /**
  51904. * Configuration for the decoder.
  51905. */
  51906. decoder?: {
  51907. /**
  51908. * The url to the WebAssembly module.
  51909. */
  51910. wasmUrl?: string;
  51911. /**
  51912. * The url to the WebAssembly binary.
  51913. */
  51914. wasmBinaryUrl?: string;
  51915. /**
  51916. * The url to the fallback JavaScript module.
  51917. */
  51918. fallbackUrl?: string;
  51919. };
  51920. }
  51921. /**
  51922. * Draco compression (https://google.github.io/draco/)
  51923. *
  51924. * This class wraps the Draco module.
  51925. *
  51926. * **Encoder**
  51927. *
  51928. * The encoder is not currently implemented.
  51929. *
  51930. * **Decoder**
  51931. *
  51932. * 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.
  51933. *
  51934. * To update the configuration, use the following code:
  51935. * ```javascript
  51936. * DracoCompression.Configuration = {
  51937. * decoder: {
  51938. * wasmUrl: "<url to the WebAssembly library>",
  51939. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51940. * fallbackUrl: "<url to the fallback JavaScript library>",
  51941. * }
  51942. * };
  51943. * ```
  51944. *
  51945. * 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.
  51946. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51947. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51948. *
  51949. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51950. * ```javascript
  51951. * var dracoCompression = new DracoCompression();
  51952. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51953. * [VertexBuffer.PositionKind]: 0
  51954. * });
  51955. * ```
  51956. *
  51957. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51958. */
  51959. export class DracoCompression implements IDisposable {
  51960. private _workerPoolPromise;
  51961. /**
  51962. * The configuration. Defaults to the following urls:
  51963. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51964. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51965. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51966. */
  51967. static Configuration: IDracoCompressionConfiguration;
  51968. /**
  51969. * Returns true if the decoder is available.
  51970. */
  51971. static readonly DecoderAvailable: boolean;
  51972. /**
  51973. * Default number of workers to create when creating the draco compression object.
  51974. */
  51975. static DefaultNumWorkers: number;
  51976. private static GetDefaultNumWorkers;
  51977. /**
  51978. * Constructor
  51979. * @param numWorkers The number of workers for async operations
  51980. */
  51981. constructor(numWorkers?: number);
  51982. /**
  51983. * Stop all async operations and release resources.
  51984. */
  51985. dispose(): void;
  51986. /**
  51987. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51988. * @returns a promise that resolves when ready
  51989. */
  51990. whenReadyAsync(): Promise<void>;
  51991. /**
  51992. * Decode Draco compressed mesh data to vertex data.
  51993. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51994. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51995. * @returns A promise that resolves with the decoded vertex data
  51996. */
  51997. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51998. [kind: string]: number;
  51999. }): Promise<VertexData>;
  52000. /**
  52001. * The worker function that gets converted to a blob url to pass into a worker.
  52002. */
  52003. private static _Worker;
  52004. private _loadDecoderWasmBinaryAsync;
  52005. }
  52006. }
  52007. declare module "babylonjs/Meshes/Compression/index" {
  52008. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52009. }
  52010. declare module "babylonjs/Meshes/csg" {
  52011. import { Nullable } from "babylonjs/types";
  52012. import { Scene } from "babylonjs/scene";
  52013. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52014. import { Mesh } from "babylonjs/Meshes/mesh";
  52015. import { Material } from "babylonjs/Materials/material";
  52016. /**
  52017. * Class for building Constructive Solid Geometry
  52018. */
  52019. export class CSG {
  52020. private polygons;
  52021. /**
  52022. * The world matrix
  52023. */
  52024. matrix: Matrix;
  52025. /**
  52026. * Stores the position
  52027. */
  52028. position: Vector3;
  52029. /**
  52030. * Stores the rotation
  52031. */
  52032. rotation: Vector3;
  52033. /**
  52034. * Stores the rotation quaternion
  52035. */
  52036. rotationQuaternion: Nullable<Quaternion>;
  52037. /**
  52038. * Stores the scaling vector
  52039. */
  52040. scaling: Vector3;
  52041. /**
  52042. * Convert the Mesh to CSG
  52043. * @param mesh The Mesh to convert to CSG
  52044. * @returns A new CSG from the Mesh
  52045. */
  52046. static FromMesh(mesh: Mesh): CSG;
  52047. /**
  52048. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52049. * @param polygons Polygons used to construct a CSG solid
  52050. */
  52051. private static FromPolygons;
  52052. /**
  52053. * Clones, or makes a deep copy, of the CSG
  52054. * @returns A new CSG
  52055. */
  52056. clone(): CSG;
  52057. /**
  52058. * Unions this CSG with another CSG
  52059. * @param csg The CSG to union against this CSG
  52060. * @returns The unioned CSG
  52061. */
  52062. union(csg: CSG): CSG;
  52063. /**
  52064. * Unions this CSG with another CSG in place
  52065. * @param csg The CSG to union against this CSG
  52066. */
  52067. unionInPlace(csg: CSG): void;
  52068. /**
  52069. * Subtracts this CSG with another CSG
  52070. * @param csg The CSG to subtract against this CSG
  52071. * @returns A new CSG
  52072. */
  52073. subtract(csg: CSG): CSG;
  52074. /**
  52075. * Subtracts this CSG with another CSG in place
  52076. * @param csg The CSG to subtact against this CSG
  52077. */
  52078. subtractInPlace(csg: CSG): void;
  52079. /**
  52080. * Intersect this CSG with another CSG
  52081. * @param csg The CSG to intersect against this CSG
  52082. * @returns A new CSG
  52083. */
  52084. intersect(csg: CSG): CSG;
  52085. /**
  52086. * Intersects this CSG with another CSG in place
  52087. * @param csg The CSG to intersect against this CSG
  52088. */
  52089. intersectInPlace(csg: CSG): void;
  52090. /**
  52091. * Return a new CSG solid with solid and empty space switched. This solid is
  52092. * not modified.
  52093. * @returns A new CSG solid with solid and empty space switched
  52094. */
  52095. inverse(): CSG;
  52096. /**
  52097. * Inverses the CSG in place
  52098. */
  52099. inverseInPlace(): void;
  52100. /**
  52101. * This is used to keep meshes transformations so they can be restored
  52102. * when we build back a Babylon Mesh
  52103. * NB : All CSG operations are performed in world coordinates
  52104. * @param csg The CSG to copy the transform attributes from
  52105. * @returns This CSG
  52106. */
  52107. copyTransformAttributes(csg: CSG): CSG;
  52108. /**
  52109. * Build Raw mesh from CSG
  52110. * Coordinates here are in world space
  52111. * @param name The name of the mesh geometry
  52112. * @param scene The Scene
  52113. * @param keepSubMeshes Specifies if the submeshes should be kept
  52114. * @returns A new Mesh
  52115. */
  52116. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52117. /**
  52118. * Build Mesh from CSG taking material and transforms into account
  52119. * @param name The name of the Mesh
  52120. * @param material The material of the Mesh
  52121. * @param scene The Scene
  52122. * @param keepSubMeshes Specifies if submeshes should be kept
  52123. * @returns The new Mesh
  52124. */
  52125. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52126. }
  52127. }
  52128. declare module "babylonjs/Meshes/trailMesh" {
  52129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52130. import { Mesh } from "babylonjs/Meshes/mesh";
  52131. import { Scene } from "babylonjs/scene";
  52132. /**
  52133. * Class used to create a trail following a mesh
  52134. */
  52135. export class TrailMesh extends Mesh {
  52136. private _generator;
  52137. private _autoStart;
  52138. private _running;
  52139. private _diameter;
  52140. private _length;
  52141. private _sectionPolygonPointsCount;
  52142. private _sectionVectors;
  52143. private _sectionNormalVectors;
  52144. private _beforeRenderObserver;
  52145. /**
  52146. * @constructor
  52147. * @param name The value used by scene.getMeshByName() to do a lookup.
  52148. * @param generator The mesh to generate a trail.
  52149. * @param scene The scene to add this mesh to.
  52150. * @param diameter Diameter of trailing mesh. Default is 1.
  52151. * @param length Length of trailing mesh. Default is 60.
  52152. * @param autoStart Automatically start trailing mesh. Default true.
  52153. */
  52154. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52155. /**
  52156. * "TrailMesh"
  52157. * @returns "TrailMesh"
  52158. */
  52159. getClassName(): string;
  52160. private _createMesh;
  52161. /**
  52162. * Start trailing mesh.
  52163. */
  52164. start(): void;
  52165. /**
  52166. * Stop trailing mesh.
  52167. */
  52168. stop(): void;
  52169. /**
  52170. * Update trailing mesh geometry.
  52171. */
  52172. update(): void;
  52173. /**
  52174. * Returns a new TrailMesh object.
  52175. * @param name is a string, the name given to the new mesh
  52176. * @param newGenerator use new generator object for cloned trail mesh
  52177. * @returns a new mesh
  52178. */
  52179. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52180. /**
  52181. * Serializes this trail mesh
  52182. * @param serializationObject object to write serialization to
  52183. */
  52184. serialize(serializationObject: any): void;
  52185. /**
  52186. * Parses a serialized trail mesh
  52187. * @param parsedMesh the serialized mesh
  52188. * @param scene the scene to create the trail mesh in
  52189. * @returns the created trail mesh
  52190. */
  52191. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52192. }
  52193. }
  52194. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52195. import { Vector4 } from "babylonjs/Maths/math";
  52196. import { Mesh } from "babylonjs/Meshes/mesh";
  52197. /**
  52198. * Class containing static functions to help procedurally build meshes
  52199. */
  52200. export class TorusKnotBuilder {
  52201. /**
  52202. * Creates a torus knot mesh
  52203. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52204. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52205. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52206. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52210. * @param name defines the name of the mesh
  52211. * @param options defines the options used to create the mesh
  52212. * @param scene defines the hosting scene
  52213. * @returns the torus knot mesh
  52214. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52215. */
  52216. static CreateTorusKnot(name: string, options: {
  52217. radius?: number;
  52218. tube?: number;
  52219. radialSegments?: number;
  52220. tubularSegments?: number;
  52221. p?: number;
  52222. q?: number;
  52223. updatable?: boolean;
  52224. sideOrientation?: number;
  52225. frontUVs?: Vector4;
  52226. backUVs?: Vector4;
  52227. }, scene: any): Mesh;
  52228. }
  52229. }
  52230. declare module "babylonjs/Meshes/polygonMesh" {
  52231. import { Scene } from "babylonjs/scene";
  52232. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52233. import { Mesh } from "babylonjs/Meshes/mesh";
  52234. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52235. /**
  52236. * Polygon
  52237. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52238. */
  52239. export class Polygon {
  52240. /**
  52241. * Creates a rectangle
  52242. * @param xmin bottom X coord
  52243. * @param ymin bottom Y coord
  52244. * @param xmax top X coord
  52245. * @param ymax top Y coord
  52246. * @returns points that make the resulting rectation
  52247. */
  52248. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52249. /**
  52250. * Creates a circle
  52251. * @param radius radius of circle
  52252. * @param cx scale in x
  52253. * @param cy scale in y
  52254. * @param numberOfSides number of sides that make up the circle
  52255. * @returns points that make the resulting circle
  52256. */
  52257. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52258. /**
  52259. * Creates a polygon from input string
  52260. * @param input Input polygon data
  52261. * @returns the parsed points
  52262. */
  52263. static Parse(input: string): Vector2[];
  52264. /**
  52265. * Starts building a polygon from x and y coordinates
  52266. * @param x x coordinate
  52267. * @param y y coordinate
  52268. * @returns the started path2
  52269. */
  52270. static StartingAt(x: number, y: number): Path2;
  52271. }
  52272. /**
  52273. * Builds a polygon
  52274. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52275. */
  52276. export class PolygonMeshBuilder {
  52277. private _points;
  52278. private _outlinepoints;
  52279. private _holes;
  52280. private _name;
  52281. private _scene;
  52282. private _epoints;
  52283. private _eholes;
  52284. private _addToepoint;
  52285. /**
  52286. * Babylon reference to the earcut plugin.
  52287. */
  52288. bjsEarcut: any;
  52289. /**
  52290. * Creates a PolygonMeshBuilder
  52291. * @param name name of the builder
  52292. * @param contours Path of the polygon
  52293. * @param scene scene to add to when creating the mesh
  52294. * @param earcutInjection can be used to inject your own earcut reference
  52295. */
  52296. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52297. /**
  52298. * Adds a whole within the polygon
  52299. * @param hole Array of points defining the hole
  52300. * @returns this
  52301. */
  52302. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52303. /**
  52304. * Creates the polygon
  52305. * @param updatable If the mesh should be updatable
  52306. * @param depth The depth of the mesh created
  52307. * @returns the created mesh
  52308. */
  52309. build(updatable?: boolean, depth?: number): Mesh;
  52310. /**
  52311. * Creates the polygon
  52312. * @param depth The depth of the mesh created
  52313. * @returns the created VertexData
  52314. */
  52315. buildVertexData(depth?: number): VertexData;
  52316. /**
  52317. * Adds a side to the polygon
  52318. * @param positions points that make the polygon
  52319. * @param normals normals of the polygon
  52320. * @param uvs uvs of the polygon
  52321. * @param indices indices of the polygon
  52322. * @param bounds bounds of the polygon
  52323. * @param points points of the polygon
  52324. * @param depth depth of the polygon
  52325. * @param flip flip of the polygon
  52326. */
  52327. private addSide;
  52328. }
  52329. }
  52330. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52331. import { Scene } from "babylonjs/scene";
  52332. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52333. import { Mesh } from "babylonjs/Meshes/mesh";
  52334. import { Nullable } from "babylonjs/types";
  52335. /**
  52336. * Class containing static functions to help procedurally build meshes
  52337. */
  52338. export class PolygonBuilder {
  52339. /**
  52340. * Creates a polygon mesh
  52341. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52342. * * 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
  52343. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52346. * * Remember you can only change the shape positions, not their number when updating a polygon
  52347. * @param name defines the name of the mesh
  52348. * @param options defines the options used to create the mesh
  52349. * @param scene defines the hosting scene
  52350. * @param earcutInjection can be used to inject your own earcut reference
  52351. * @returns the polygon mesh
  52352. */
  52353. static CreatePolygon(name: string, options: {
  52354. shape: Vector3[];
  52355. holes?: Vector3[][];
  52356. depth?: number;
  52357. faceUV?: Vector4[];
  52358. faceColors?: Color4[];
  52359. updatable?: boolean;
  52360. sideOrientation?: number;
  52361. frontUVs?: Vector4;
  52362. backUVs?: Vector4;
  52363. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52364. /**
  52365. * Creates an extruded polygon mesh, with depth in the Y direction.
  52366. * * 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)
  52367. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52368. * @param name defines the name of the mesh
  52369. * @param options defines the options used to create the mesh
  52370. * @param scene defines the hosting scene
  52371. * @param earcutInjection can be used to inject your own earcut reference
  52372. * @returns the polygon mesh
  52373. */
  52374. static ExtrudePolygon(name: string, options: {
  52375. shape: Vector3[];
  52376. holes?: Vector3[][];
  52377. depth?: number;
  52378. faceUV?: Vector4[];
  52379. faceColors?: Color4[];
  52380. updatable?: boolean;
  52381. sideOrientation?: number;
  52382. frontUVs?: Vector4;
  52383. backUVs?: Vector4;
  52384. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52385. }
  52386. }
  52387. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52388. import { Scene } from "babylonjs/scene";
  52389. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52390. import { Mesh } from "babylonjs/Meshes/mesh";
  52391. import { Nullable } from "babylonjs/types";
  52392. /**
  52393. * Class containing static functions to help procedurally build meshes
  52394. */
  52395. export class LatheBuilder {
  52396. /**
  52397. * Creates lathe mesh.
  52398. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52399. * * 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
  52400. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52401. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52402. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52403. * * 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
  52404. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52405. * * 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
  52406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52408. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the lathe mesh
  52414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52415. */
  52416. static CreateLathe(name: string, options: {
  52417. shape: Vector3[];
  52418. radius?: number;
  52419. tessellation?: number;
  52420. clip?: number;
  52421. arc?: number;
  52422. closed?: boolean;
  52423. updatable?: boolean;
  52424. sideOrientation?: number;
  52425. frontUVs?: Vector4;
  52426. backUVs?: Vector4;
  52427. cap?: number;
  52428. invertUV?: boolean;
  52429. }, scene?: Nullable<Scene>): Mesh;
  52430. }
  52431. }
  52432. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52433. import { Nullable } from "babylonjs/types";
  52434. import { Scene } from "babylonjs/scene";
  52435. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52436. import { Mesh } from "babylonjs/Meshes/mesh";
  52437. /**
  52438. * Class containing static functions to help procedurally build meshes
  52439. */
  52440. export class TubeBuilder {
  52441. /**
  52442. * Creates a tube mesh.
  52443. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52444. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52445. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52446. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52447. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52448. * * 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)
  52449. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52450. * * 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
  52451. * * 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
  52452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52454. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52456. * @param name defines the name of the mesh
  52457. * @param options defines the options used to create the mesh
  52458. * @param scene defines the hosting scene
  52459. * @returns the tube mesh
  52460. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52461. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52462. */
  52463. static CreateTube(name: string, options: {
  52464. path: Vector3[];
  52465. radius?: number;
  52466. tessellation?: number;
  52467. radiusFunction?: {
  52468. (i: number, distance: number): number;
  52469. };
  52470. cap?: number;
  52471. arc?: number;
  52472. updatable?: boolean;
  52473. sideOrientation?: number;
  52474. frontUVs?: Vector4;
  52475. backUVs?: Vector4;
  52476. instance?: Mesh;
  52477. invertUV?: boolean;
  52478. }, scene?: Nullable<Scene>): Mesh;
  52479. }
  52480. }
  52481. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52482. import { Scene } from "babylonjs/scene";
  52483. import { Vector4 } from "babylonjs/Maths/math";
  52484. import { Mesh } from "babylonjs/Meshes/mesh";
  52485. import { Nullable } from "babylonjs/types";
  52486. /**
  52487. * Class containing static functions to help procedurally build meshes
  52488. */
  52489. export class IcoSphereBuilder {
  52490. /**
  52491. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52492. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52493. * * 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`)
  52494. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52495. * * 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
  52496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52499. * @param name defines the name of the mesh
  52500. * @param options defines the options used to create the mesh
  52501. * @param scene defines the hosting scene
  52502. * @returns the icosahedron mesh
  52503. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52504. */
  52505. static CreateIcoSphere(name: string, options: {
  52506. radius?: number;
  52507. radiusX?: number;
  52508. radiusY?: number;
  52509. radiusZ?: number;
  52510. flat?: boolean;
  52511. subdivisions?: number;
  52512. sideOrientation?: number;
  52513. frontUVs?: Vector4;
  52514. backUVs?: Vector4;
  52515. updatable?: boolean;
  52516. }, scene?: Nullable<Scene>): Mesh;
  52517. }
  52518. }
  52519. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52520. import { Vector3 } from "babylonjs/Maths/math";
  52521. import { Mesh } from "babylonjs/Meshes/mesh";
  52522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52523. /**
  52524. * Class containing static functions to help procedurally build meshes
  52525. */
  52526. export class DecalBuilder {
  52527. /**
  52528. * Creates a decal mesh.
  52529. * 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
  52530. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52531. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52532. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52533. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52534. * @param name defines the name of the mesh
  52535. * @param sourceMesh defines the mesh where the decal must be applied
  52536. * @param options defines the options used to create the mesh
  52537. * @param scene defines the hosting scene
  52538. * @returns the decal mesh
  52539. * @see https://doc.babylonjs.com/how_to/decals
  52540. */
  52541. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52542. position?: Vector3;
  52543. normal?: Vector3;
  52544. size?: Vector3;
  52545. angle?: number;
  52546. }): Mesh;
  52547. }
  52548. }
  52549. declare module "babylonjs/Meshes/meshBuilder" {
  52550. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52551. import { Nullable } from "babylonjs/types";
  52552. import { Scene } from "babylonjs/scene";
  52553. import { Mesh } from "babylonjs/Meshes/mesh";
  52554. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52555. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52557. /**
  52558. * Class containing static functions to help procedurally build meshes
  52559. */
  52560. export class MeshBuilder {
  52561. /**
  52562. * Creates a box mesh
  52563. * * The parameter `size` sets the size (float) of each box side (default 1)
  52564. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52565. * * 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)
  52566. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52570. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52571. * @param name defines the name of the mesh
  52572. * @param options defines the options used to create the mesh
  52573. * @param scene defines the hosting scene
  52574. * @returns the box mesh
  52575. */
  52576. static CreateBox(name: string, options: {
  52577. size?: number;
  52578. width?: number;
  52579. height?: number;
  52580. depth?: number;
  52581. faceUV?: Vector4[];
  52582. faceColors?: Color4[];
  52583. sideOrientation?: number;
  52584. frontUVs?: Vector4;
  52585. backUVs?: Vector4;
  52586. updatable?: boolean;
  52587. }, scene?: Nullable<Scene>): Mesh;
  52588. /**
  52589. * Creates a sphere mesh
  52590. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52591. * * 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`)
  52592. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52593. * * 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
  52594. * * 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)
  52595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52598. * @param name defines the name of the mesh
  52599. * @param options defines the options used to create the mesh
  52600. * @param scene defines the hosting scene
  52601. * @returns the sphere mesh
  52602. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52603. */
  52604. static CreateSphere(name: string, options: {
  52605. segments?: number;
  52606. diameter?: number;
  52607. diameterX?: number;
  52608. diameterY?: number;
  52609. diameterZ?: number;
  52610. arc?: number;
  52611. slice?: number;
  52612. sideOrientation?: number;
  52613. frontUVs?: Vector4;
  52614. backUVs?: Vector4;
  52615. updatable?: boolean;
  52616. }, scene?: Nullable<Scene>): Mesh;
  52617. /**
  52618. * Creates a plane polygonal mesh. By default, this is a disc
  52619. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52620. * * 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
  52621. * * 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
  52622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52625. * @param name defines the name of the mesh
  52626. * @param options defines the options used to create the mesh
  52627. * @param scene defines the hosting scene
  52628. * @returns the plane polygonal mesh
  52629. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52630. */
  52631. static CreateDisc(name: string, options: {
  52632. radius?: number;
  52633. tessellation?: number;
  52634. arc?: number;
  52635. updatable?: boolean;
  52636. sideOrientation?: number;
  52637. frontUVs?: Vector4;
  52638. backUVs?: Vector4;
  52639. }, scene?: Nullable<Scene>): Mesh;
  52640. /**
  52641. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52642. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52643. * * 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`)
  52644. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52645. * * 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
  52646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52649. * @param name defines the name of the mesh
  52650. * @param options defines the options used to create the mesh
  52651. * @param scene defines the hosting scene
  52652. * @returns the icosahedron mesh
  52653. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52654. */
  52655. static CreateIcoSphere(name: string, options: {
  52656. radius?: number;
  52657. radiusX?: number;
  52658. radiusY?: number;
  52659. radiusZ?: number;
  52660. flat?: boolean;
  52661. subdivisions?: number;
  52662. sideOrientation?: number;
  52663. frontUVs?: Vector4;
  52664. backUVs?: Vector4;
  52665. updatable?: boolean;
  52666. }, scene?: Nullable<Scene>): Mesh;
  52667. /**
  52668. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52669. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52670. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52671. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52672. * * 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
  52673. * * 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
  52674. * * 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
  52675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52678. * * 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
  52679. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52680. * * 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
  52681. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52683. * @param name defines the name of the mesh
  52684. * @param options defines the options used to create the mesh
  52685. * @param scene defines the hosting scene
  52686. * @returns the ribbon mesh
  52687. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52688. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52689. */
  52690. static CreateRibbon(name: string, options: {
  52691. pathArray: Vector3[][];
  52692. closeArray?: boolean;
  52693. closePath?: boolean;
  52694. offset?: number;
  52695. updatable?: boolean;
  52696. sideOrientation?: number;
  52697. frontUVs?: Vector4;
  52698. backUVs?: Vector4;
  52699. instance?: Mesh;
  52700. invertUV?: boolean;
  52701. uvs?: Vector2[];
  52702. colors?: Color4[];
  52703. }, scene?: Nullable<Scene>): Mesh;
  52704. /**
  52705. * Creates a cylinder or a cone mesh
  52706. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52707. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52708. * * 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.
  52709. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52710. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52711. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52712. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52713. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52714. * * 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).
  52715. * * 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
  52716. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52717. * * 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
  52718. * * 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.
  52719. * * If `enclose` is false, a ring surface is one element.
  52720. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52721. * * 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
  52722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 cylinder mesh
  52729. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52730. */
  52731. static CreateCylinder(name: string, options: {
  52732. height?: number;
  52733. diameterTop?: number;
  52734. diameterBottom?: number;
  52735. diameter?: number;
  52736. tessellation?: number;
  52737. subdivisions?: number;
  52738. arc?: number;
  52739. faceColors?: Color4[];
  52740. faceUV?: Vector4[];
  52741. updatable?: boolean;
  52742. hasRings?: boolean;
  52743. enclose?: boolean;
  52744. sideOrientation?: number;
  52745. frontUVs?: Vector4;
  52746. backUVs?: Vector4;
  52747. }, scene?: Nullable<Scene>): Mesh;
  52748. /**
  52749. * Creates a torus mesh
  52750. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52751. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52752. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52756. * @param name defines the name of the mesh
  52757. * @param options defines the options used to create the mesh
  52758. * @param scene defines the hosting scene
  52759. * @returns the torus mesh
  52760. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52761. */
  52762. static CreateTorus(name: string, options: {
  52763. diameter?: number;
  52764. thickness?: number;
  52765. tessellation?: number;
  52766. updatable?: boolean;
  52767. sideOrientation?: number;
  52768. frontUVs?: Vector4;
  52769. backUVs?: Vector4;
  52770. }, scene?: Nullable<Scene>): Mesh;
  52771. /**
  52772. * Creates a torus knot mesh
  52773. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52774. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52775. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52776. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52780. * @param name defines the name of the mesh
  52781. * @param options defines the options used to create the mesh
  52782. * @param scene defines the hosting scene
  52783. * @returns the torus knot mesh
  52784. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52785. */
  52786. static CreateTorusKnot(name: string, options: {
  52787. radius?: number;
  52788. tube?: number;
  52789. radialSegments?: number;
  52790. tubularSegments?: number;
  52791. p?: number;
  52792. q?: number;
  52793. updatable?: boolean;
  52794. sideOrientation?: number;
  52795. frontUVs?: Vector4;
  52796. backUVs?: Vector4;
  52797. }, scene?: Nullable<Scene>): Mesh;
  52798. /**
  52799. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52800. * * 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
  52801. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52802. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52803. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52804. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52805. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52806. * * 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
  52807. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52810. * @param name defines the name of the new line system
  52811. * @param options defines the options used to create the line system
  52812. * @param scene defines the hosting scene
  52813. * @returns a new line system mesh
  52814. */
  52815. static CreateLineSystem(name: string, options: {
  52816. lines: Vector3[][];
  52817. updatable?: boolean;
  52818. instance?: Nullable<LinesMesh>;
  52819. colors?: Nullable<Color4[][]>;
  52820. useVertexAlpha?: boolean;
  52821. }, scene: Nullable<Scene>): LinesMesh;
  52822. /**
  52823. * Creates a line mesh
  52824. * 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
  52825. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52826. * * The parameter `points` is an array successive Vector3
  52827. * * 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
  52828. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52829. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52830. * * When updating an instance, remember that only point positions can change, not the number of points
  52831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52833. * @param name defines the name of the new line system
  52834. * @param options defines the options used to create the line system
  52835. * @param scene defines the hosting scene
  52836. * @returns a new line mesh
  52837. */
  52838. static CreateLines(name: string, options: {
  52839. points: Vector3[];
  52840. updatable?: boolean;
  52841. instance?: Nullable<LinesMesh>;
  52842. colors?: Color4[];
  52843. useVertexAlpha?: boolean;
  52844. }, scene?: Nullable<Scene>): LinesMesh;
  52845. /**
  52846. * Creates a dashed line mesh
  52847. * * 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
  52848. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52849. * * The parameter `points` is an array successive Vector3
  52850. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52851. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52852. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52853. * * 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
  52854. * * When updating an instance, remember that only point positions can change, not the number of points
  52855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52856. * @param name defines the name of the mesh
  52857. * @param options defines the options used to create the mesh
  52858. * @param scene defines the hosting scene
  52859. * @returns the dashed line mesh
  52860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52861. */
  52862. static CreateDashedLines(name: string, options: {
  52863. points: Vector3[];
  52864. dashSize?: number;
  52865. gapSize?: number;
  52866. dashNb?: number;
  52867. updatable?: boolean;
  52868. instance?: LinesMesh;
  52869. }, scene?: Nullable<Scene>): LinesMesh;
  52870. /**
  52871. * 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.
  52872. * * 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.
  52873. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52874. * * 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.
  52875. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52876. * * 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
  52877. * * 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
  52878. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52883. * @param name defines the name of the mesh
  52884. * @param options defines the options used to create the mesh
  52885. * @param scene defines the hosting scene
  52886. * @returns the extruded shape mesh
  52887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52889. */
  52890. static ExtrudeShape(name: string, options: {
  52891. shape: Vector3[];
  52892. path: Vector3[];
  52893. scale?: number;
  52894. rotation?: number;
  52895. cap?: number;
  52896. updatable?: boolean;
  52897. sideOrientation?: number;
  52898. frontUVs?: Vector4;
  52899. backUVs?: Vector4;
  52900. instance?: Mesh;
  52901. invertUV?: boolean;
  52902. }, scene?: Nullable<Scene>): Mesh;
  52903. /**
  52904. * Creates an custom extruded shape mesh.
  52905. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52906. * * 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.
  52907. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52908. * * 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
  52909. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52910. * * 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
  52911. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52912. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52913. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52914. * * 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
  52915. * * 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
  52916. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52921. * @param name defines the name of the mesh
  52922. * @param options defines the options used to create the mesh
  52923. * @param scene defines the hosting scene
  52924. * @returns the custom extruded shape mesh
  52925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52926. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52928. */
  52929. static ExtrudeShapeCustom(name: string, options: {
  52930. shape: Vector3[];
  52931. path: Vector3[];
  52932. scaleFunction?: any;
  52933. rotationFunction?: any;
  52934. ribbonCloseArray?: boolean;
  52935. ribbonClosePath?: boolean;
  52936. cap?: number;
  52937. updatable?: boolean;
  52938. sideOrientation?: number;
  52939. frontUVs?: Vector4;
  52940. backUVs?: Vector4;
  52941. instance?: Mesh;
  52942. invertUV?: boolean;
  52943. }, scene?: Nullable<Scene>): Mesh;
  52944. /**
  52945. * Creates lathe mesh.
  52946. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52947. * * 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
  52948. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52949. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52950. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52951. * * 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
  52952. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52953. * * 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
  52954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52956. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52958. * @param name defines the name of the mesh
  52959. * @param options defines the options used to create the mesh
  52960. * @param scene defines the hosting scene
  52961. * @returns the lathe mesh
  52962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52963. */
  52964. static CreateLathe(name: string, options: {
  52965. shape: Vector3[];
  52966. radius?: number;
  52967. tessellation?: number;
  52968. clip?: number;
  52969. arc?: number;
  52970. closed?: boolean;
  52971. updatable?: boolean;
  52972. sideOrientation?: number;
  52973. frontUVs?: Vector4;
  52974. backUVs?: Vector4;
  52975. cap?: number;
  52976. invertUV?: boolean;
  52977. }, scene?: Nullable<Scene>): Mesh;
  52978. /**
  52979. * Creates a plane mesh
  52980. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52981. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52982. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52986. * @param name defines the name of the mesh
  52987. * @param options defines the options used to create the mesh
  52988. * @param scene defines the hosting scene
  52989. * @returns the plane mesh
  52990. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52991. */
  52992. static CreatePlane(name: string, options: {
  52993. size?: number;
  52994. width?: number;
  52995. height?: number;
  52996. sideOrientation?: number;
  52997. frontUVs?: Vector4;
  52998. backUVs?: Vector4;
  52999. updatable?: boolean;
  53000. sourcePlane?: Plane;
  53001. }, scene?: Nullable<Scene>): Mesh;
  53002. /**
  53003. * Creates a ground mesh
  53004. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53005. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53007. * @param name defines the name of the mesh
  53008. * @param options defines the options used to create the mesh
  53009. * @param scene defines the hosting scene
  53010. * @returns the ground mesh
  53011. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53012. */
  53013. static CreateGround(name: string, options: {
  53014. width?: number;
  53015. height?: number;
  53016. subdivisions?: number;
  53017. subdivisionsX?: number;
  53018. subdivisionsY?: number;
  53019. updatable?: boolean;
  53020. }, scene?: Nullable<Scene>): Mesh;
  53021. /**
  53022. * Creates a tiled ground mesh
  53023. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53024. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53025. * * 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
  53026. * * 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
  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 tiled ground mesh
  53032. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53033. */
  53034. static CreateTiledGround(name: string, options: {
  53035. xmin: number;
  53036. zmin: number;
  53037. xmax: number;
  53038. zmax: number;
  53039. subdivisions?: {
  53040. w: number;
  53041. h: number;
  53042. };
  53043. precision?: {
  53044. w: number;
  53045. h: number;
  53046. };
  53047. updatable?: boolean;
  53048. }, scene?: Nullable<Scene>): Mesh;
  53049. /**
  53050. * Creates a ground mesh from a height map
  53051. * * The parameter `url` sets the URL of the height map image resource.
  53052. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53053. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53054. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53055. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53056. * * 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.
  53057. * * 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).
  53058. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53060. * @param name defines the name of the mesh
  53061. * @param url defines the url to the height map
  53062. * @param options defines the options used to create the mesh
  53063. * @param scene defines the hosting scene
  53064. * @returns the ground mesh
  53065. * @see https://doc.babylonjs.com/babylon101/height_map
  53066. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53067. */
  53068. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53069. width?: number;
  53070. height?: number;
  53071. subdivisions?: number;
  53072. minHeight?: number;
  53073. maxHeight?: number;
  53074. colorFilter?: Color3;
  53075. alphaFilter?: number;
  53076. updatable?: boolean;
  53077. onReady?: (mesh: GroundMesh) => void;
  53078. }, scene?: Nullable<Scene>): GroundMesh;
  53079. /**
  53080. * Creates a polygon mesh
  53081. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53082. * * 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
  53083. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53086. * * Remember you can only change the shape positions, not their number when updating a polygon
  53087. * @param name defines the name of the mesh
  53088. * @param options defines the options used to create the mesh
  53089. * @param scene defines the hosting scene
  53090. * @param earcutInjection can be used to inject your own earcut reference
  53091. * @returns the polygon mesh
  53092. */
  53093. static CreatePolygon(name: string, options: {
  53094. shape: Vector3[];
  53095. holes?: Vector3[][];
  53096. depth?: number;
  53097. faceUV?: Vector4[];
  53098. faceColors?: Color4[];
  53099. updatable?: boolean;
  53100. sideOrientation?: number;
  53101. frontUVs?: Vector4;
  53102. backUVs?: Vector4;
  53103. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53104. /**
  53105. * Creates an extruded polygon mesh, with depth in the Y direction.
  53106. * * 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)
  53107. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53108. * @param name defines the name of the mesh
  53109. * @param options defines the options used to create the mesh
  53110. * @param scene defines the hosting scene
  53111. * @param earcutInjection can be used to inject your own earcut reference
  53112. * @returns the polygon mesh
  53113. */
  53114. static ExtrudePolygon(name: string, options: {
  53115. shape: Vector3[];
  53116. holes?: Vector3[][];
  53117. depth?: number;
  53118. faceUV?: Vector4[];
  53119. faceColors?: Color4[];
  53120. updatable?: boolean;
  53121. sideOrientation?: number;
  53122. frontUVs?: Vector4;
  53123. backUVs?: Vector4;
  53124. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53125. /**
  53126. * Creates a tube mesh.
  53127. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53128. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53129. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53130. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53131. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53132. * * 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)
  53133. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53134. * * 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
  53135. * * 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
  53136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53140. * @param name defines the name of the mesh
  53141. * @param options defines the options used to create the mesh
  53142. * @param scene defines the hosting scene
  53143. * @returns the tube mesh
  53144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53145. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53146. */
  53147. static CreateTube(name: string, options: {
  53148. path: Vector3[];
  53149. radius?: number;
  53150. tessellation?: number;
  53151. radiusFunction?: {
  53152. (i: number, distance: number): number;
  53153. };
  53154. cap?: number;
  53155. arc?: number;
  53156. updatable?: boolean;
  53157. sideOrientation?: number;
  53158. frontUVs?: Vector4;
  53159. backUVs?: Vector4;
  53160. instance?: Mesh;
  53161. invertUV?: boolean;
  53162. }, scene?: Nullable<Scene>): Mesh;
  53163. /**
  53164. * Creates a polyhedron mesh
  53165. * * 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
  53166. * * The parameter `size` (positive float, default 1) sets the polygon size
  53167. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53168. * * 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`
  53169. * * 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
  53170. * * 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)`)
  53171. * * 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
  53172. * * 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
  53173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53176. * @param name defines the name of the mesh
  53177. * @param options defines the options used to create the mesh
  53178. * @param scene defines the hosting scene
  53179. * @returns the polyhedron mesh
  53180. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53181. */
  53182. static CreatePolyhedron(name: string, options: {
  53183. type?: number;
  53184. size?: number;
  53185. sizeX?: number;
  53186. sizeY?: number;
  53187. sizeZ?: number;
  53188. custom?: any;
  53189. faceUV?: Vector4[];
  53190. faceColors?: Color4[];
  53191. flat?: boolean;
  53192. updatable?: boolean;
  53193. sideOrientation?: number;
  53194. frontUVs?: Vector4;
  53195. backUVs?: Vector4;
  53196. }, scene?: Nullable<Scene>): Mesh;
  53197. /**
  53198. * Creates a decal mesh.
  53199. * 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
  53200. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53201. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53202. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53203. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53204. * @param name defines the name of the mesh
  53205. * @param sourceMesh defines the mesh where the decal must be applied
  53206. * @param options defines the options used to create the mesh
  53207. * @param scene defines the hosting scene
  53208. * @returns the decal mesh
  53209. * @see https://doc.babylonjs.com/how_to/decals
  53210. */
  53211. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53212. position?: Vector3;
  53213. normal?: Vector3;
  53214. size?: Vector3;
  53215. angle?: number;
  53216. }): Mesh;
  53217. }
  53218. }
  53219. declare module "babylonjs/Meshes/meshSimplification" {
  53220. import { Mesh } from "babylonjs/Meshes/mesh";
  53221. /**
  53222. * A simplifier interface for future simplification implementations
  53223. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53224. */
  53225. export interface ISimplifier {
  53226. /**
  53227. * Simplification of a given mesh according to the given settings.
  53228. * Since this requires computation, it is assumed that the function runs async.
  53229. * @param settings The settings of the simplification, including quality and distance
  53230. * @param successCallback A callback that will be called after the mesh was simplified.
  53231. * @param errorCallback in case of an error, this callback will be called. optional.
  53232. */
  53233. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53234. }
  53235. /**
  53236. * Expected simplification settings.
  53237. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53238. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53239. */
  53240. export interface ISimplificationSettings {
  53241. /**
  53242. * Gets or sets the expected quality
  53243. */
  53244. quality: number;
  53245. /**
  53246. * Gets or sets the distance when this optimized version should be used
  53247. */
  53248. distance: number;
  53249. /**
  53250. * Gets an already optimized mesh
  53251. */
  53252. optimizeMesh?: boolean;
  53253. }
  53254. /**
  53255. * Class used to specify simplification options
  53256. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53257. */
  53258. export class SimplificationSettings implements ISimplificationSettings {
  53259. /** expected quality */
  53260. quality: number;
  53261. /** distance when this optimized version should be used */
  53262. distance: number;
  53263. /** already optimized mesh */
  53264. optimizeMesh?: boolean | undefined;
  53265. /**
  53266. * Creates a SimplificationSettings
  53267. * @param quality expected quality
  53268. * @param distance distance when this optimized version should be used
  53269. * @param optimizeMesh already optimized mesh
  53270. */
  53271. constructor(
  53272. /** expected quality */
  53273. quality: number,
  53274. /** distance when this optimized version should be used */
  53275. distance: number,
  53276. /** already optimized mesh */
  53277. optimizeMesh?: boolean | undefined);
  53278. }
  53279. /**
  53280. * Interface used to define a simplification task
  53281. */
  53282. export interface ISimplificationTask {
  53283. /**
  53284. * Array of settings
  53285. */
  53286. settings: Array<ISimplificationSettings>;
  53287. /**
  53288. * Simplification type
  53289. */
  53290. simplificationType: SimplificationType;
  53291. /**
  53292. * Mesh to simplify
  53293. */
  53294. mesh: Mesh;
  53295. /**
  53296. * Callback called on success
  53297. */
  53298. successCallback?: () => void;
  53299. /**
  53300. * Defines if parallel processing can be used
  53301. */
  53302. parallelProcessing: boolean;
  53303. }
  53304. /**
  53305. * Queue used to order the simplification tasks
  53306. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53307. */
  53308. export class SimplificationQueue {
  53309. private _simplificationArray;
  53310. /**
  53311. * Gets a boolean indicating that the process is still running
  53312. */
  53313. running: boolean;
  53314. /**
  53315. * Creates a new queue
  53316. */
  53317. constructor();
  53318. /**
  53319. * Adds a new simplification task
  53320. * @param task defines a task to add
  53321. */
  53322. addTask(task: ISimplificationTask): void;
  53323. /**
  53324. * Execute next task
  53325. */
  53326. executeNext(): void;
  53327. /**
  53328. * Execute a simplification task
  53329. * @param task defines the task to run
  53330. */
  53331. runSimplification(task: ISimplificationTask): void;
  53332. private getSimplifier;
  53333. }
  53334. /**
  53335. * The implemented types of simplification
  53336. * At the moment only Quadratic Error Decimation is implemented
  53337. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53338. */
  53339. export enum SimplificationType {
  53340. /** Quadratic error decimation */
  53341. QUADRATIC = 0
  53342. }
  53343. }
  53344. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53345. import { Scene } from "babylonjs/scene";
  53346. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53347. import { ISceneComponent } from "babylonjs/sceneComponent";
  53348. module "babylonjs/scene" {
  53349. interface Scene {
  53350. /** @hidden (Backing field) */
  53351. _simplificationQueue: SimplificationQueue;
  53352. /**
  53353. * Gets or sets the simplification queue attached to the scene
  53354. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53355. */
  53356. simplificationQueue: SimplificationQueue;
  53357. }
  53358. }
  53359. module "babylonjs/Meshes/mesh" {
  53360. interface Mesh {
  53361. /**
  53362. * Simplify the mesh according to the given array of settings.
  53363. * Function will return immediately and will simplify async
  53364. * @param settings a collection of simplification settings
  53365. * @param parallelProcessing should all levels calculate parallel or one after the other
  53366. * @param simplificationType the type of simplification to run
  53367. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53368. * @returns the current mesh
  53369. */
  53370. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53371. }
  53372. }
  53373. /**
  53374. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53375. * created in a scene
  53376. */
  53377. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53378. /**
  53379. * The component name helpfull to identify the component in the list of scene components.
  53380. */
  53381. readonly name: string;
  53382. /**
  53383. * The scene the component belongs to.
  53384. */
  53385. scene: Scene;
  53386. /**
  53387. * Creates a new instance of the component for the given scene
  53388. * @param scene Defines the scene to register the component in
  53389. */
  53390. constructor(scene: Scene);
  53391. /**
  53392. * Registers the component in a given scene
  53393. */
  53394. register(): void;
  53395. /**
  53396. * Rebuilds the elements related to this component in case of
  53397. * context lost for instance.
  53398. */
  53399. rebuild(): void;
  53400. /**
  53401. * Disposes the component and the associated ressources
  53402. */
  53403. dispose(): void;
  53404. private _beforeCameraUpdate;
  53405. }
  53406. }
  53407. declare module "babylonjs/Meshes/Builders/index" {
  53408. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53409. export * from "babylonjs/Meshes/Builders/discBuilder";
  53410. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53411. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53412. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53413. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53414. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53415. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53416. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53417. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53418. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53419. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53420. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53421. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53422. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53423. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53424. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53425. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53426. }
  53427. declare module "babylonjs/Meshes/index" {
  53428. export * from "babylonjs/Meshes/abstractMesh";
  53429. export * from "babylonjs/Meshes/buffer";
  53430. export * from "babylonjs/Meshes/Compression/index";
  53431. export * from "babylonjs/Meshes/csg";
  53432. export * from "babylonjs/Meshes/geometry";
  53433. export * from "babylonjs/Meshes/groundMesh";
  53434. export * from "babylonjs/Meshes/trailMesh";
  53435. export * from "babylonjs/Meshes/instancedMesh";
  53436. export * from "babylonjs/Meshes/linesMesh";
  53437. export * from "babylonjs/Meshes/mesh";
  53438. export * from "babylonjs/Meshes/mesh.vertexData";
  53439. export * from "babylonjs/Meshes/meshBuilder";
  53440. export * from "babylonjs/Meshes/meshSimplification";
  53441. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53442. export * from "babylonjs/Meshes/polygonMesh";
  53443. export * from "babylonjs/Meshes/subMesh";
  53444. export * from "babylonjs/Meshes/meshLODLevel";
  53445. export * from "babylonjs/Meshes/transformNode";
  53446. export * from "babylonjs/Meshes/Builders/index";
  53447. export * from "babylonjs/Meshes/dataBuffer";
  53448. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53449. }
  53450. declare module "babylonjs/Morph/index" {
  53451. export * from "babylonjs/Morph/morphTarget";
  53452. export * from "babylonjs/Morph/morphTargetManager";
  53453. }
  53454. declare module "babylonjs/Offline/database" {
  53455. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53456. /**
  53457. * Class used to enable access to IndexedDB
  53458. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53459. */
  53460. export class Database implements IOfflineProvider {
  53461. private _callbackManifestChecked;
  53462. private _currentSceneUrl;
  53463. private _db;
  53464. private _enableSceneOffline;
  53465. private _enableTexturesOffline;
  53466. private _manifestVersionFound;
  53467. private _mustUpdateRessources;
  53468. private _hasReachedQuota;
  53469. private _isSupported;
  53470. private _idbFactory;
  53471. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53472. private static IsUASupportingBlobStorage;
  53473. /**
  53474. * Gets a boolean indicating if Database storate is enabled (off by default)
  53475. */
  53476. static IDBStorageEnabled: boolean;
  53477. /**
  53478. * Gets a boolean indicating if scene must be saved in the database
  53479. */
  53480. readonly enableSceneOffline: boolean;
  53481. /**
  53482. * Gets a boolean indicating if textures must be saved in the database
  53483. */
  53484. readonly enableTexturesOffline: boolean;
  53485. /**
  53486. * Creates a new Database
  53487. * @param urlToScene defines the url to load the scene
  53488. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53489. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53490. */
  53491. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53492. private static _ParseURL;
  53493. private static _ReturnFullUrlLocation;
  53494. private _checkManifestFile;
  53495. /**
  53496. * Open the database and make it available
  53497. * @param successCallback defines the callback to call on success
  53498. * @param errorCallback defines the callback to call on error
  53499. */
  53500. open(successCallback: () => void, errorCallback: () => void): void;
  53501. /**
  53502. * Loads an image from the database
  53503. * @param url defines the url to load from
  53504. * @param image defines the target DOM image
  53505. */
  53506. loadImage(url: string, image: HTMLImageElement): void;
  53507. private _loadImageFromDBAsync;
  53508. private _saveImageIntoDBAsync;
  53509. private _checkVersionFromDB;
  53510. private _loadVersionFromDBAsync;
  53511. private _saveVersionIntoDBAsync;
  53512. /**
  53513. * Loads a file from database
  53514. * @param url defines the URL to load from
  53515. * @param sceneLoaded defines a callback to call on success
  53516. * @param progressCallBack defines a callback to call when progress changed
  53517. * @param errorCallback defines a callback to call on error
  53518. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53519. */
  53520. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53521. private _loadFileAsync;
  53522. private _saveFileAsync;
  53523. /**
  53524. * Validates if xhr data is correct
  53525. * @param xhr defines the request to validate
  53526. * @param dataType defines the expected data type
  53527. * @returns true if data is correct
  53528. */
  53529. private static _ValidateXHRData;
  53530. }
  53531. }
  53532. declare module "babylonjs/Offline/index" {
  53533. export * from "babylonjs/Offline/database";
  53534. export * from "babylonjs/Offline/IOfflineProvider";
  53535. }
  53536. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53537. /** @hidden */
  53538. export var gpuUpdateParticlesPixelShader: {
  53539. name: string;
  53540. shader: string;
  53541. };
  53542. }
  53543. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53544. /** @hidden */
  53545. export var gpuUpdateParticlesVertexShader: {
  53546. name: string;
  53547. shader: string;
  53548. };
  53549. }
  53550. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53551. /** @hidden */
  53552. export var clipPlaneFragmentDeclaration2: {
  53553. name: string;
  53554. shader: string;
  53555. };
  53556. }
  53557. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53558. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53559. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53560. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53561. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53562. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53563. /** @hidden */
  53564. export var gpuRenderParticlesPixelShader: {
  53565. name: string;
  53566. shader: string;
  53567. };
  53568. }
  53569. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53570. /** @hidden */
  53571. export var clipPlaneVertexDeclaration2: {
  53572. name: string;
  53573. shader: string;
  53574. };
  53575. }
  53576. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53577. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53578. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53579. /** @hidden */
  53580. export var gpuRenderParticlesVertexShader: {
  53581. name: string;
  53582. shader: string;
  53583. };
  53584. }
  53585. declare module "babylonjs/Particles/gpuParticleSystem" {
  53586. import { Nullable } from "babylonjs/types";
  53587. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53588. import { Observable } from "babylonjs/Misc/observable";
  53589. import { Color4, Color3 } from "babylonjs/Maths/math";
  53590. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53591. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53592. import { Scene, IDisposable } from "babylonjs/scene";
  53593. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53594. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53595. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53596. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53597. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53598. /**
  53599. * This represents a GPU particle system in Babylon
  53600. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53601. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53602. */
  53603. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53604. /**
  53605. * The layer mask we are rendering the particles through.
  53606. */
  53607. layerMask: number;
  53608. private _capacity;
  53609. private _activeCount;
  53610. private _currentActiveCount;
  53611. private _accumulatedCount;
  53612. private _renderEffect;
  53613. private _updateEffect;
  53614. private _buffer0;
  53615. private _buffer1;
  53616. private _spriteBuffer;
  53617. private _updateVAO;
  53618. private _renderVAO;
  53619. private _targetIndex;
  53620. private _sourceBuffer;
  53621. private _targetBuffer;
  53622. private _engine;
  53623. private _currentRenderId;
  53624. private _started;
  53625. private _stopped;
  53626. private _timeDelta;
  53627. private _randomTexture;
  53628. private _randomTexture2;
  53629. private _attributesStrideSize;
  53630. private _updateEffectOptions;
  53631. private _randomTextureSize;
  53632. private _actualFrame;
  53633. private readonly _rawTextureWidth;
  53634. /**
  53635. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53636. */
  53637. static readonly IsSupported: boolean;
  53638. /**
  53639. * An event triggered when the system is disposed.
  53640. */
  53641. onDisposeObservable: Observable<GPUParticleSystem>;
  53642. /**
  53643. * Gets the maximum number of particles active at the same time.
  53644. * @returns The max number of active particles.
  53645. */
  53646. getCapacity(): number;
  53647. /**
  53648. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53649. * to override the particles.
  53650. */
  53651. forceDepthWrite: boolean;
  53652. /**
  53653. * Gets or set the number of active particles
  53654. */
  53655. activeParticleCount: number;
  53656. private _preWarmDone;
  53657. /**
  53658. * Is this system ready to be used/rendered
  53659. * @return true if the system is ready
  53660. */
  53661. isReady(): boolean;
  53662. /**
  53663. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53664. * @returns True if it has been started, otherwise false.
  53665. */
  53666. isStarted(): boolean;
  53667. /**
  53668. * Starts the particle system and begins to emit
  53669. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53670. */
  53671. start(delay?: number): void;
  53672. /**
  53673. * Stops the particle system.
  53674. */
  53675. stop(): void;
  53676. /**
  53677. * Remove all active particles
  53678. */
  53679. reset(): void;
  53680. /**
  53681. * Returns the string "GPUParticleSystem"
  53682. * @returns a string containing the class name
  53683. */
  53684. getClassName(): string;
  53685. private _colorGradientsTexture;
  53686. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53687. /**
  53688. * Adds a new color gradient
  53689. * @param gradient defines the gradient to use (between 0 and 1)
  53690. * @param color1 defines the color to affect to the specified gradient
  53691. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53692. * @returns the current particle system
  53693. */
  53694. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53695. /**
  53696. * Remove a specific color gradient
  53697. * @param gradient defines the gradient to remove
  53698. * @returns the current particle system
  53699. */
  53700. removeColorGradient(gradient: number): GPUParticleSystem;
  53701. private _angularSpeedGradientsTexture;
  53702. private _sizeGradientsTexture;
  53703. private _velocityGradientsTexture;
  53704. private _limitVelocityGradientsTexture;
  53705. private _dragGradientsTexture;
  53706. private _addFactorGradient;
  53707. /**
  53708. * Adds a new size gradient
  53709. * @param gradient defines the gradient to use (between 0 and 1)
  53710. * @param factor defines the size factor to affect to the specified gradient
  53711. * @returns the current particle system
  53712. */
  53713. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53714. /**
  53715. * Remove a specific size gradient
  53716. * @param gradient defines the gradient to remove
  53717. * @returns the current particle system
  53718. */
  53719. removeSizeGradient(gradient: number): GPUParticleSystem;
  53720. /**
  53721. * Adds a new angular speed gradient
  53722. * @param gradient defines the gradient to use (between 0 and 1)
  53723. * @param factor defines the angular speed to affect to the specified gradient
  53724. * @returns the current particle system
  53725. */
  53726. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53727. /**
  53728. * Remove a specific angular speed gradient
  53729. * @param gradient defines the gradient to remove
  53730. * @returns the current particle system
  53731. */
  53732. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53733. /**
  53734. * Adds a new velocity gradient
  53735. * @param gradient defines the gradient to use (between 0 and 1)
  53736. * @param factor defines the velocity to affect to the specified gradient
  53737. * @returns the current particle system
  53738. */
  53739. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53740. /**
  53741. * Remove a specific velocity gradient
  53742. * @param gradient defines the gradient to remove
  53743. * @returns the current particle system
  53744. */
  53745. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53746. /**
  53747. * Adds a new limit velocity gradient
  53748. * @param gradient defines the gradient to use (between 0 and 1)
  53749. * @param factor defines the limit velocity value to affect to the specified gradient
  53750. * @returns the current particle system
  53751. */
  53752. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53753. /**
  53754. * Remove a specific limit velocity gradient
  53755. * @param gradient defines the gradient to remove
  53756. * @returns the current particle system
  53757. */
  53758. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53759. /**
  53760. * Adds a new drag gradient
  53761. * @param gradient defines the gradient to use (between 0 and 1)
  53762. * @param factor defines the drag value to affect to the specified gradient
  53763. * @returns the current particle system
  53764. */
  53765. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53766. /**
  53767. * Remove a specific drag gradient
  53768. * @param gradient defines the gradient to remove
  53769. * @returns the current particle system
  53770. */
  53771. removeDragGradient(gradient: number): GPUParticleSystem;
  53772. /**
  53773. * Not supported by GPUParticleSystem
  53774. * @param gradient defines the gradient to use (between 0 and 1)
  53775. * @param factor defines the emit rate value to affect to the specified gradient
  53776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53777. * @returns the current particle system
  53778. */
  53779. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53780. /**
  53781. * Not supported by GPUParticleSystem
  53782. * @param gradient defines the gradient to remove
  53783. * @returns the current particle system
  53784. */
  53785. removeEmitRateGradient(gradient: number): IParticleSystem;
  53786. /**
  53787. * Not supported by GPUParticleSystem
  53788. * @param gradient defines the gradient to use (between 0 and 1)
  53789. * @param factor defines the start size value to affect to the specified gradient
  53790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53791. * @returns the current particle system
  53792. */
  53793. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53794. /**
  53795. * Not supported by GPUParticleSystem
  53796. * @param gradient defines the gradient to remove
  53797. * @returns the current particle system
  53798. */
  53799. removeStartSizeGradient(gradient: number): IParticleSystem;
  53800. /**
  53801. * Not supported by GPUParticleSystem
  53802. * @param gradient defines the gradient to use (between 0 and 1)
  53803. * @param min defines the color remap minimal range
  53804. * @param max defines the color remap maximal range
  53805. * @returns the current particle system
  53806. */
  53807. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53808. /**
  53809. * Not supported by GPUParticleSystem
  53810. * @param gradient defines the gradient to remove
  53811. * @returns the current particle system
  53812. */
  53813. removeColorRemapGradient(): IParticleSystem;
  53814. /**
  53815. * Not supported by GPUParticleSystem
  53816. * @param gradient defines the gradient to use (between 0 and 1)
  53817. * @param min defines the alpha remap minimal range
  53818. * @param max defines the alpha remap maximal range
  53819. * @returns the current particle system
  53820. */
  53821. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53822. /**
  53823. * Not supported by GPUParticleSystem
  53824. * @param gradient defines the gradient to remove
  53825. * @returns the current particle system
  53826. */
  53827. removeAlphaRemapGradient(): IParticleSystem;
  53828. /**
  53829. * Not supported by GPUParticleSystem
  53830. * @param gradient defines the gradient to use (between 0 and 1)
  53831. * @param color defines the color to affect to the specified gradient
  53832. * @returns the current particle system
  53833. */
  53834. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53835. /**
  53836. * Not supported by GPUParticleSystem
  53837. * @param gradient defines the gradient to remove
  53838. * @returns the current particle system
  53839. */
  53840. removeRampGradient(): IParticleSystem;
  53841. /**
  53842. * Not supported by GPUParticleSystem
  53843. * @returns the list of ramp gradients
  53844. */
  53845. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53846. /**
  53847. * Not supported by GPUParticleSystem
  53848. * Gets or sets a boolean indicating that ramp gradients must be used
  53849. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53850. */
  53851. useRampGradients: boolean;
  53852. /**
  53853. * Not supported by GPUParticleSystem
  53854. * @param gradient defines the gradient to use (between 0 and 1)
  53855. * @param factor defines the life time factor to affect to the specified gradient
  53856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53857. * @returns the current particle system
  53858. */
  53859. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53860. /**
  53861. * Not supported by GPUParticleSystem
  53862. * @param gradient defines the gradient to remove
  53863. * @returns the current particle system
  53864. */
  53865. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53866. /**
  53867. * Instantiates a GPU particle system.
  53868. * 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.
  53869. * @param name The name of the particle system
  53870. * @param options The options used to create the system
  53871. * @param scene The scene the particle system belongs to
  53872. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53873. */
  53874. constructor(name: string, options: Partial<{
  53875. capacity: number;
  53876. randomTextureSize: number;
  53877. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53878. protected _reset(): void;
  53879. private _createUpdateVAO;
  53880. private _createRenderVAO;
  53881. private _initialize;
  53882. /** @hidden */
  53883. _recreateUpdateEffect(): void;
  53884. /** @hidden */
  53885. _recreateRenderEffect(): void;
  53886. /**
  53887. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53888. * @param preWarm defines if we are in the pre-warmimg phase
  53889. */
  53890. animate(preWarm?: boolean): void;
  53891. private _createFactorGradientTexture;
  53892. private _createSizeGradientTexture;
  53893. private _createAngularSpeedGradientTexture;
  53894. private _createVelocityGradientTexture;
  53895. private _createLimitVelocityGradientTexture;
  53896. private _createDragGradientTexture;
  53897. private _createColorGradientTexture;
  53898. /**
  53899. * Renders the particle system in its current state
  53900. * @param preWarm defines if the system should only update the particles but not render them
  53901. * @returns the current number of particles
  53902. */
  53903. render(preWarm?: boolean): number;
  53904. /**
  53905. * Rebuilds the particle system
  53906. */
  53907. rebuild(): void;
  53908. private _releaseBuffers;
  53909. private _releaseVAOs;
  53910. /**
  53911. * Disposes the particle system and free the associated resources
  53912. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53913. */
  53914. dispose(disposeTexture?: boolean): void;
  53915. /**
  53916. * Clones the particle system.
  53917. * @param name The name of the cloned object
  53918. * @param newEmitter The new emitter to use
  53919. * @returns the cloned particle system
  53920. */
  53921. clone(name: string, newEmitter: any): GPUParticleSystem;
  53922. /**
  53923. * Serializes the particle system to a JSON object.
  53924. * @returns the JSON object
  53925. */
  53926. serialize(): any;
  53927. /**
  53928. * Parses a JSON object to create a GPU particle system.
  53929. * @param parsedParticleSystem The JSON object to parse
  53930. * @param scene The scene to create the particle system in
  53931. * @param rootUrl The root url to use to load external dependencies like texture
  53932. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53933. * @returns the parsed GPU particle system
  53934. */
  53935. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53936. }
  53937. }
  53938. declare module "babylonjs/Particles/particleSystemSet" {
  53939. import { Nullable } from "babylonjs/types";
  53940. import { Color3 } from "babylonjs/Maths/math";
  53941. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53943. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53944. import { Scene, IDisposable } from "babylonjs/scene";
  53945. /**
  53946. * Represents a set of particle systems working together to create a specific effect
  53947. */
  53948. export class ParticleSystemSet implements IDisposable {
  53949. private _emitterCreationOptions;
  53950. private _emitterNode;
  53951. /**
  53952. * Gets the particle system list
  53953. */
  53954. systems: IParticleSystem[];
  53955. /**
  53956. * Gets the emitter node used with this set
  53957. */
  53958. readonly emitterNode: Nullable<TransformNode>;
  53959. /**
  53960. * Creates a new emitter mesh as a sphere
  53961. * @param options defines the options used to create the sphere
  53962. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53963. * @param scene defines the hosting scene
  53964. */
  53965. setEmitterAsSphere(options: {
  53966. diameter: number;
  53967. segments: number;
  53968. color: Color3;
  53969. }, renderingGroupId: number, scene: Scene): void;
  53970. /**
  53971. * Starts all particle systems of the set
  53972. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53973. */
  53974. start(emitter?: AbstractMesh): void;
  53975. /**
  53976. * Release all associated resources
  53977. */
  53978. dispose(): void;
  53979. /**
  53980. * Serialize the set into a JSON compatible object
  53981. * @returns a JSON compatible representation of the set
  53982. */
  53983. serialize(): any;
  53984. /**
  53985. * Parse a new ParticleSystemSet from a serialized source
  53986. * @param data defines a JSON compatible representation of the set
  53987. * @param scene defines the hosting scene
  53988. * @param gpu defines if we want GPU particles or CPU particles
  53989. * @returns a new ParticleSystemSet
  53990. */
  53991. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53992. }
  53993. }
  53994. declare module "babylonjs/Particles/particleHelper" {
  53995. import { Nullable } from "babylonjs/types";
  53996. import { Scene } from "babylonjs/scene";
  53997. import { Vector3 } from "babylonjs/Maths/math";
  53998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53999. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54000. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54001. /**
  54002. * This class is made for on one-liner static method to help creating particle system set.
  54003. */
  54004. export class ParticleHelper {
  54005. /**
  54006. * Gets or sets base Assets URL
  54007. */
  54008. static BaseAssetsUrl: string;
  54009. /**
  54010. * Create a default particle system that you can tweak
  54011. * @param emitter defines the emitter to use
  54012. * @param capacity defines the system capacity (default is 500 particles)
  54013. * @param scene defines the hosting scene
  54014. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54015. * @returns the new Particle system
  54016. */
  54017. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54018. /**
  54019. * This is the main static method (one-liner) of this helper to create different particle systems
  54020. * @param type This string represents the type to the particle system to create
  54021. * @param scene The scene where the particle system should live
  54022. * @param gpu If the system will use gpu
  54023. * @returns the ParticleSystemSet created
  54024. */
  54025. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54026. /**
  54027. * Static function used to export a particle system to a ParticleSystemSet variable.
  54028. * Please note that the emitter shape is not exported
  54029. * @param systems defines the particle systems to export
  54030. * @returns the created particle system set
  54031. */
  54032. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54033. }
  54034. }
  54035. declare module "babylonjs/Particles/particleSystemComponent" {
  54036. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54037. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54038. import "babylonjs/Shaders/particles.vertex";
  54039. module "babylonjs/Engines/engine" {
  54040. interface Engine {
  54041. /**
  54042. * Create an effect to use with particle systems.
  54043. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54044. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54045. * @param uniformsNames defines a list of attribute names
  54046. * @param samplers defines an array of string used to represent textures
  54047. * @param defines defines the string containing the defines to use to compile the shaders
  54048. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54049. * @param onCompiled defines a function to call when the effect creation is successful
  54050. * @param onError defines a function to call when the effect creation has failed
  54051. * @returns the new Effect
  54052. */
  54053. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54054. }
  54055. }
  54056. module "babylonjs/Meshes/mesh" {
  54057. interface Mesh {
  54058. /**
  54059. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54060. * @returns an array of IParticleSystem
  54061. */
  54062. getEmittedParticleSystems(): IParticleSystem[];
  54063. /**
  54064. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54065. * @returns an array of IParticleSystem
  54066. */
  54067. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54068. }
  54069. }
  54070. /**
  54071. * @hidden
  54072. */
  54073. export var _IDoNeedToBeInTheBuild: number;
  54074. }
  54075. declare module "babylonjs/Particles/index" {
  54076. export * from "babylonjs/Particles/baseParticleSystem";
  54077. export * from "babylonjs/Particles/EmitterTypes/index";
  54078. export * from "babylonjs/Particles/gpuParticleSystem";
  54079. export * from "babylonjs/Particles/IParticleSystem";
  54080. export * from "babylonjs/Particles/particle";
  54081. export * from "babylonjs/Particles/particleHelper";
  54082. export * from "babylonjs/Particles/particleSystem";
  54083. export * from "babylonjs/Particles/particleSystemComponent";
  54084. export * from "babylonjs/Particles/particleSystemSet";
  54085. export * from "babylonjs/Particles/solidParticle";
  54086. export * from "babylonjs/Particles/solidParticleSystem";
  54087. export * from "babylonjs/Particles/subEmitter";
  54088. }
  54089. declare module "babylonjs/Physics/physicsEngineComponent" {
  54090. import { Nullable } from "babylonjs/types";
  54091. import { Observable, Observer } from "babylonjs/Misc/observable";
  54092. import { Vector3 } from "babylonjs/Maths/math";
  54093. import { Mesh } from "babylonjs/Meshes/mesh";
  54094. import { ISceneComponent } from "babylonjs/sceneComponent";
  54095. import { Scene } from "babylonjs/scene";
  54096. import { Node } from "babylonjs/node";
  54097. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54098. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54099. module "babylonjs/scene" {
  54100. interface Scene {
  54101. /** @hidden (Backing field) */
  54102. _physicsEngine: Nullable<IPhysicsEngine>;
  54103. /**
  54104. * Gets the current physics engine
  54105. * @returns a IPhysicsEngine or null if none attached
  54106. */
  54107. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54108. /**
  54109. * Enables physics to the current scene
  54110. * @param gravity defines the scene's gravity for the physics engine
  54111. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54112. * @return a boolean indicating if the physics engine was initialized
  54113. */
  54114. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54115. /**
  54116. * Disables and disposes the physics engine associated with the scene
  54117. */
  54118. disablePhysicsEngine(): void;
  54119. /**
  54120. * Gets a boolean indicating if there is an active physics engine
  54121. * @returns a boolean indicating if there is an active physics engine
  54122. */
  54123. isPhysicsEnabled(): boolean;
  54124. /**
  54125. * Deletes a physics compound impostor
  54126. * @param compound defines the compound to delete
  54127. */
  54128. deleteCompoundImpostor(compound: any): void;
  54129. /**
  54130. * An event triggered when physic simulation is about to be run
  54131. */
  54132. onBeforePhysicsObservable: Observable<Scene>;
  54133. /**
  54134. * An event triggered when physic simulation has been done
  54135. */
  54136. onAfterPhysicsObservable: Observable<Scene>;
  54137. }
  54138. }
  54139. module "babylonjs/Meshes/abstractMesh" {
  54140. interface AbstractMesh {
  54141. /** @hidden */
  54142. _physicsImpostor: Nullable<PhysicsImpostor>;
  54143. /**
  54144. * Gets or sets impostor used for physic simulation
  54145. * @see http://doc.babylonjs.com/features/physics_engine
  54146. */
  54147. physicsImpostor: Nullable<PhysicsImpostor>;
  54148. /**
  54149. * Gets the current physics impostor
  54150. * @see http://doc.babylonjs.com/features/physics_engine
  54151. * @returns a physics impostor or null
  54152. */
  54153. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54154. /** Apply a physic impulse to the mesh
  54155. * @param force defines the force to apply
  54156. * @param contactPoint defines where to apply the force
  54157. * @returns the current mesh
  54158. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54159. */
  54160. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54161. /**
  54162. * Creates a physic joint between two meshes
  54163. * @param otherMesh defines the other mesh to use
  54164. * @param pivot1 defines the pivot to use on this mesh
  54165. * @param pivot2 defines the pivot to use on the other mesh
  54166. * @param options defines additional options (can be plugin dependent)
  54167. * @returns the current mesh
  54168. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54169. */
  54170. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54171. /** @hidden */
  54172. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54173. }
  54174. }
  54175. /**
  54176. * Defines the physics engine scene component responsible to manage a physics engine
  54177. */
  54178. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54179. /**
  54180. * The component name helpful to identify the component in the list of scene components.
  54181. */
  54182. readonly name: string;
  54183. /**
  54184. * The scene the component belongs to.
  54185. */
  54186. scene: Scene;
  54187. /**
  54188. * Creates a new instance of the component for the given scene
  54189. * @param scene Defines the scene to register the component in
  54190. */
  54191. constructor(scene: Scene);
  54192. /**
  54193. * Registers the component in a given scene
  54194. */
  54195. register(): void;
  54196. /**
  54197. * Rebuilds the elements related to this component in case of
  54198. * context lost for instance.
  54199. */
  54200. rebuild(): void;
  54201. /**
  54202. * Disposes the component and the associated ressources
  54203. */
  54204. dispose(): void;
  54205. }
  54206. }
  54207. declare module "babylonjs/Physics/physicsHelper" {
  54208. import { Nullable } from "babylonjs/types";
  54209. import { Vector3 } from "babylonjs/Maths/math";
  54210. import { Mesh } from "babylonjs/Meshes/mesh";
  54211. import { Scene } from "babylonjs/scene";
  54212. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54213. /**
  54214. * A helper for physics simulations
  54215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54216. */
  54217. export class PhysicsHelper {
  54218. private _scene;
  54219. private _physicsEngine;
  54220. /**
  54221. * Initializes the Physics helper
  54222. * @param scene Babylon.js scene
  54223. */
  54224. constructor(scene: Scene);
  54225. /**
  54226. * Applies a radial explosion impulse
  54227. * @param origin the origin of the explosion
  54228. * @param radiusOrEventOptions the radius or the options of radial explosion
  54229. * @param strength the explosion strength
  54230. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54231. * @returns A physics radial explosion event, or null
  54232. */
  54233. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54234. /**
  54235. * Applies a radial explosion force
  54236. * @param origin the origin of the explosion
  54237. * @param radiusOrEventOptions the radius or the options of radial explosion
  54238. * @param strength the explosion strength
  54239. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54240. * @returns A physics radial explosion event, or null
  54241. */
  54242. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54243. /**
  54244. * Creates a gravitational field
  54245. * @param origin the origin of the explosion
  54246. * @param radiusOrEventOptions the radius or the options of radial explosion
  54247. * @param strength the explosion strength
  54248. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54249. * @returns A physics gravitational field event, or null
  54250. */
  54251. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54252. /**
  54253. * Creates a physics updraft event
  54254. * @param origin the origin of the updraft
  54255. * @param radiusOrEventOptions the radius or the options of the updraft
  54256. * @param strength the strength of the updraft
  54257. * @param height the height of the updraft
  54258. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54259. * @returns A physics updraft event, or null
  54260. */
  54261. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54262. /**
  54263. * Creates a physics vortex event
  54264. * @param origin the of the vortex
  54265. * @param radiusOrEventOptions the radius or the options of the vortex
  54266. * @param strength the strength of the vortex
  54267. * @param height the height of the vortex
  54268. * @returns a Physics vortex event, or null
  54269. * A physics vortex event or null
  54270. */
  54271. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54272. }
  54273. /**
  54274. * Represents a physics radial explosion event
  54275. */
  54276. class PhysicsRadialExplosionEvent {
  54277. private _scene;
  54278. private _options;
  54279. private _sphere;
  54280. private _dataFetched;
  54281. /**
  54282. * Initializes a radial explosioin event
  54283. * @param _scene BabylonJS scene
  54284. * @param _options The options for the vortex event
  54285. */
  54286. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54287. /**
  54288. * Returns the data related to the radial explosion event (sphere).
  54289. * @returns The radial explosion event data
  54290. */
  54291. getData(): PhysicsRadialExplosionEventData;
  54292. /**
  54293. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54294. * @param impostor A physics imposter
  54295. * @param origin the origin of the explosion
  54296. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54297. */
  54298. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54299. /**
  54300. * Triggers affecterd impostors callbacks
  54301. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54302. */
  54303. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54304. /**
  54305. * Disposes the sphere.
  54306. * @param force Specifies if the sphere should be disposed by force
  54307. */
  54308. dispose(force?: boolean): void;
  54309. /*** Helpers ***/
  54310. private _prepareSphere;
  54311. private _intersectsWithSphere;
  54312. }
  54313. /**
  54314. * Represents a gravitational field event
  54315. */
  54316. class PhysicsGravitationalFieldEvent {
  54317. private _physicsHelper;
  54318. private _scene;
  54319. private _origin;
  54320. private _options;
  54321. private _tickCallback;
  54322. private _sphere;
  54323. private _dataFetched;
  54324. /**
  54325. * Initializes the physics gravitational field event
  54326. * @param _physicsHelper A physics helper
  54327. * @param _scene BabylonJS scene
  54328. * @param _origin The origin position of the gravitational field event
  54329. * @param _options The options for the vortex event
  54330. */
  54331. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54332. /**
  54333. * Returns the data related to the gravitational field event (sphere).
  54334. * @returns A gravitational field event
  54335. */
  54336. getData(): PhysicsGravitationalFieldEventData;
  54337. /**
  54338. * Enables the gravitational field.
  54339. */
  54340. enable(): void;
  54341. /**
  54342. * Disables the gravitational field.
  54343. */
  54344. disable(): void;
  54345. /**
  54346. * Disposes the sphere.
  54347. * @param force The force to dispose from the gravitational field event
  54348. */
  54349. dispose(force?: boolean): void;
  54350. private _tick;
  54351. }
  54352. /**
  54353. * Represents a physics updraft event
  54354. */
  54355. class PhysicsUpdraftEvent {
  54356. private _scene;
  54357. private _origin;
  54358. private _options;
  54359. private _physicsEngine;
  54360. private _originTop;
  54361. private _originDirection;
  54362. private _tickCallback;
  54363. private _cylinder;
  54364. private _cylinderPosition;
  54365. private _dataFetched;
  54366. /**
  54367. * Initializes the physics updraft event
  54368. * @param _scene BabylonJS scene
  54369. * @param _origin The origin position of the updraft
  54370. * @param _options The options for the updraft event
  54371. */
  54372. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54373. /**
  54374. * Returns the data related to the updraft event (cylinder).
  54375. * @returns A physics updraft event
  54376. */
  54377. getData(): PhysicsUpdraftEventData;
  54378. /**
  54379. * Enables the updraft.
  54380. */
  54381. enable(): void;
  54382. /**
  54383. * Disables the updraft.
  54384. */
  54385. disable(): void;
  54386. /**
  54387. * Disposes the cylinder.
  54388. * @param force Specifies if the updraft should be disposed by force
  54389. */
  54390. dispose(force?: boolean): void;
  54391. private getImpostorHitData;
  54392. private _tick;
  54393. /*** Helpers ***/
  54394. private _prepareCylinder;
  54395. private _intersectsWithCylinder;
  54396. }
  54397. /**
  54398. * Represents a physics vortex event
  54399. */
  54400. class PhysicsVortexEvent {
  54401. private _scene;
  54402. private _origin;
  54403. private _options;
  54404. private _physicsEngine;
  54405. private _originTop;
  54406. private _tickCallback;
  54407. private _cylinder;
  54408. private _cylinderPosition;
  54409. private _dataFetched;
  54410. /**
  54411. * Initializes the physics vortex event
  54412. * @param _scene The BabylonJS scene
  54413. * @param _origin The origin position of the vortex
  54414. * @param _options The options for the vortex event
  54415. */
  54416. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54417. /**
  54418. * Returns the data related to the vortex event (cylinder).
  54419. * @returns The physics vortex event data
  54420. */
  54421. getData(): PhysicsVortexEventData;
  54422. /**
  54423. * Enables the vortex.
  54424. */
  54425. enable(): void;
  54426. /**
  54427. * Disables the cortex.
  54428. */
  54429. disable(): void;
  54430. /**
  54431. * Disposes the sphere.
  54432. * @param force
  54433. */
  54434. dispose(force?: boolean): void;
  54435. private getImpostorHitData;
  54436. private _tick;
  54437. /*** Helpers ***/
  54438. private _prepareCylinder;
  54439. private _intersectsWithCylinder;
  54440. }
  54441. /**
  54442. * Options fot the radial explosion event
  54443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54444. */
  54445. export class PhysicsRadialExplosionEventOptions {
  54446. /**
  54447. * The radius of the sphere for the radial explosion.
  54448. */
  54449. radius: number;
  54450. /**
  54451. * The strenth of the explosion.
  54452. */
  54453. strength: number;
  54454. /**
  54455. * The strenght of the force in correspondence to the distance of the affected object
  54456. */
  54457. falloff: PhysicsRadialImpulseFalloff;
  54458. /**
  54459. * Sphere options for the radial explosion.
  54460. */
  54461. sphere: {
  54462. segments: number;
  54463. diameter: number;
  54464. };
  54465. /**
  54466. * Sphere options for the radial explosion.
  54467. */
  54468. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54469. }
  54470. /**
  54471. * Options fot the updraft event
  54472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54473. */
  54474. export class PhysicsUpdraftEventOptions {
  54475. /**
  54476. * The radius of the cylinder for the vortex
  54477. */
  54478. radius: number;
  54479. /**
  54480. * The strenth of the updraft.
  54481. */
  54482. strength: number;
  54483. /**
  54484. * The height of the cylinder for the updraft.
  54485. */
  54486. height: number;
  54487. /**
  54488. * The mode for the the updraft.
  54489. */
  54490. updraftMode: PhysicsUpdraftMode;
  54491. }
  54492. /**
  54493. * Options fot the vortex event
  54494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54495. */
  54496. export class PhysicsVortexEventOptions {
  54497. /**
  54498. * The radius of the cylinder for the vortex
  54499. */
  54500. radius: number;
  54501. /**
  54502. * The strenth of the vortex.
  54503. */
  54504. strength: number;
  54505. /**
  54506. * The height of the cylinder for the vortex.
  54507. */
  54508. height: number;
  54509. /**
  54510. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54511. */
  54512. centripetalForceThreshold: number;
  54513. /**
  54514. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54515. */
  54516. centripetalForceMultiplier: number;
  54517. /**
  54518. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54519. */
  54520. centrifugalForceMultiplier: number;
  54521. /**
  54522. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54523. */
  54524. updraftForceMultiplier: number;
  54525. }
  54526. /**
  54527. * The strenght of the force in correspondence to the distance of the affected object
  54528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54529. */
  54530. export enum PhysicsRadialImpulseFalloff {
  54531. /** Defines that impulse is constant in strength across it's whole radius */
  54532. Constant = 0,
  54533. /** Defines that impulse gets weaker if it's further from the origin */
  54534. Linear = 1
  54535. }
  54536. /**
  54537. * The strength of the force in correspondence to the distance of the affected object
  54538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54539. */
  54540. export enum PhysicsUpdraftMode {
  54541. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54542. Center = 0,
  54543. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54544. Perpendicular = 1
  54545. }
  54546. /**
  54547. * Interface for a physics hit data
  54548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54549. */
  54550. export interface PhysicsHitData {
  54551. /**
  54552. * The force applied at the contact point
  54553. */
  54554. force: Vector3;
  54555. /**
  54556. * The contact point
  54557. */
  54558. contactPoint: Vector3;
  54559. /**
  54560. * The distance from the origin to the contact point
  54561. */
  54562. distanceFromOrigin: number;
  54563. }
  54564. /**
  54565. * Interface for radial explosion event data
  54566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54567. */
  54568. export interface PhysicsRadialExplosionEventData {
  54569. /**
  54570. * A sphere used for the radial explosion event
  54571. */
  54572. sphere: Mesh;
  54573. }
  54574. /**
  54575. * Interface for gravitational field event data
  54576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54577. */
  54578. export interface PhysicsGravitationalFieldEventData {
  54579. /**
  54580. * A sphere mesh used for the gravitational field event
  54581. */
  54582. sphere: Mesh;
  54583. }
  54584. /**
  54585. * Interface for updraft event data
  54586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54587. */
  54588. export interface PhysicsUpdraftEventData {
  54589. /**
  54590. * A cylinder used for the updraft event
  54591. */
  54592. cylinder: Mesh;
  54593. }
  54594. /**
  54595. * Interface for vortex event data
  54596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54597. */
  54598. export interface PhysicsVortexEventData {
  54599. /**
  54600. * A cylinder used for the vortex event
  54601. */
  54602. cylinder: Mesh;
  54603. }
  54604. /**
  54605. * Interface for an affected physics impostor
  54606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54607. */
  54608. export interface PhysicsAffectedImpostorWithData {
  54609. /**
  54610. * The impostor affected by the effect
  54611. */
  54612. impostor: PhysicsImpostor;
  54613. /**
  54614. * The data about the hit/horce from the explosion
  54615. */
  54616. hitData: PhysicsHitData;
  54617. }
  54618. }
  54619. declare module "babylonjs/Physics/Plugins/index" {
  54620. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54621. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54622. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54623. }
  54624. declare module "babylonjs/Physics/index" {
  54625. export * from "babylonjs/Physics/IPhysicsEngine";
  54626. export * from "babylonjs/Physics/physicsEngine";
  54627. export * from "babylonjs/Physics/physicsEngineComponent";
  54628. export * from "babylonjs/Physics/physicsHelper";
  54629. export * from "babylonjs/Physics/physicsImpostor";
  54630. export * from "babylonjs/Physics/physicsJoint";
  54631. export * from "babylonjs/Physics/Plugins/index";
  54632. }
  54633. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54634. /** @hidden */
  54635. export var blackAndWhitePixelShader: {
  54636. name: string;
  54637. shader: string;
  54638. };
  54639. }
  54640. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54641. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54642. import { Camera } from "babylonjs/Cameras/camera";
  54643. import { Engine } from "babylonjs/Engines/engine";
  54644. import "babylonjs/Shaders/blackAndWhite.fragment";
  54645. /**
  54646. * Post process used to render in black and white
  54647. */
  54648. export class BlackAndWhitePostProcess extends PostProcess {
  54649. /**
  54650. * Linear about to convert he result to black and white (default: 1)
  54651. */
  54652. degree: number;
  54653. /**
  54654. * Creates a black and white post process
  54655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54656. * @param name The name of the effect.
  54657. * @param options The required width/height ratio to downsize to before computing the render pass.
  54658. * @param camera The camera to apply the render pass to.
  54659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54660. * @param engine The engine which the post process will be applied. (default: current engine)
  54661. * @param reusable If the post process can be reused on the same frame. (default: false)
  54662. */
  54663. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54664. }
  54665. }
  54666. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54667. import { Nullable } from "babylonjs/types";
  54668. import { Camera } from "babylonjs/Cameras/camera";
  54669. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54670. import { Engine } from "babylonjs/Engines/engine";
  54671. /**
  54672. * This represents a set of one or more post processes in Babylon.
  54673. * A post process can be used to apply a shader to a texture after it is rendered.
  54674. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54675. */
  54676. export class PostProcessRenderEffect {
  54677. private _postProcesses;
  54678. private _getPostProcesses;
  54679. private _singleInstance;
  54680. private _cameras;
  54681. private _indicesForCamera;
  54682. /**
  54683. * Name of the effect
  54684. * @hidden
  54685. */
  54686. _name: string;
  54687. /**
  54688. * Instantiates a post process render effect.
  54689. * A post process can be used to apply a shader to a texture after it is rendered.
  54690. * @param engine The engine the effect is tied to
  54691. * @param name The name of the effect
  54692. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54693. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54694. */
  54695. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54696. /**
  54697. * Checks if all the post processes in the effect are supported.
  54698. */
  54699. readonly isSupported: boolean;
  54700. /**
  54701. * Updates the current state of the effect
  54702. * @hidden
  54703. */
  54704. _update(): void;
  54705. /**
  54706. * Attaches the effect on cameras
  54707. * @param cameras The camera to attach to.
  54708. * @hidden
  54709. */
  54710. _attachCameras(cameras: Camera): void;
  54711. /**
  54712. * Attaches the effect on cameras
  54713. * @param cameras The camera to attach to.
  54714. * @hidden
  54715. */
  54716. _attachCameras(cameras: Camera[]): void;
  54717. /**
  54718. * Detaches the effect on cameras
  54719. * @param cameras The camera to detatch from.
  54720. * @hidden
  54721. */
  54722. _detachCameras(cameras: Camera): void;
  54723. /**
  54724. * Detatches the effect on cameras
  54725. * @param cameras The camera to detatch from.
  54726. * @hidden
  54727. */
  54728. _detachCameras(cameras: Camera[]): void;
  54729. /**
  54730. * Enables the effect on given cameras
  54731. * @param cameras The camera to enable.
  54732. * @hidden
  54733. */
  54734. _enable(cameras: Camera): void;
  54735. /**
  54736. * Enables the effect on given cameras
  54737. * @param cameras The camera to enable.
  54738. * @hidden
  54739. */
  54740. _enable(cameras: Nullable<Camera[]>): void;
  54741. /**
  54742. * Disables the effect on the given cameras
  54743. * @param cameras The camera to disable.
  54744. * @hidden
  54745. */
  54746. _disable(cameras: Camera): void;
  54747. /**
  54748. * Disables the effect on the given cameras
  54749. * @param cameras The camera to disable.
  54750. * @hidden
  54751. */
  54752. _disable(cameras: Nullable<Camera[]>): void;
  54753. /**
  54754. * Gets a list of the post processes contained in the effect.
  54755. * @param camera The camera to get the post processes on.
  54756. * @returns The list of the post processes in the effect.
  54757. */
  54758. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54759. }
  54760. }
  54761. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54762. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54763. /** @hidden */
  54764. export var extractHighlightsPixelShader: {
  54765. name: string;
  54766. shader: string;
  54767. };
  54768. }
  54769. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54770. import { Nullable } from "babylonjs/types";
  54771. import { Camera } from "babylonjs/Cameras/camera";
  54772. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54773. import { Engine } from "babylonjs/Engines/engine";
  54774. import "babylonjs/Shaders/extractHighlights.fragment";
  54775. /**
  54776. * 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.
  54777. */
  54778. export class ExtractHighlightsPostProcess extends PostProcess {
  54779. /**
  54780. * The luminance threshold, pixels below this value will be set to black.
  54781. */
  54782. threshold: number;
  54783. /** @hidden */
  54784. _exposure: number;
  54785. /**
  54786. * Post process which has the input texture to be used when performing highlight extraction
  54787. * @hidden
  54788. */
  54789. _inputPostProcess: Nullable<PostProcess>;
  54790. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54791. }
  54792. }
  54793. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54794. /** @hidden */
  54795. export var bloomMergePixelShader: {
  54796. name: string;
  54797. shader: string;
  54798. };
  54799. }
  54800. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54801. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54802. import { Nullable } from "babylonjs/types";
  54803. import { Engine } from "babylonjs/Engines/engine";
  54804. import { Camera } from "babylonjs/Cameras/camera";
  54805. import "babylonjs/Shaders/bloomMerge.fragment";
  54806. /**
  54807. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54808. */
  54809. export class BloomMergePostProcess extends PostProcess {
  54810. /** Weight of the bloom to be added to the original input. */
  54811. weight: number;
  54812. /**
  54813. * Creates a new instance of @see BloomMergePostProcess
  54814. * @param name The name of the effect.
  54815. * @param originalFromInput Post process which's input will be used for the merge.
  54816. * @param blurred Blurred highlights post process which's output will be used.
  54817. * @param weight Weight of the bloom to be added to the original input.
  54818. * @param options The required width/height ratio to downsize to before computing the render pass.
  54819. * @param camera The camera to apply the render pass to.
  54820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54821. * @param engine The engine which the post process will be applied. (default: current engine)
  54822. * @param reusable If the post process can be reused on the same frame. (default: false)
  54823. * @param textureType Type of textures used when performing the post process. (default: 0)
  54824. * @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)
  54825. */
  54826. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54827. /** Weight of the bloom to be added to the original input. */
  54828. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54829. }
  54830. }
  54831. declare module "babylonjs/PostProcesses/bloomEffect" {
  54832. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54833. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54834. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54835. import { Camera } from "babylonjs/Cameras/camera";
  54836. import { Scene } from "babylonjs/scene";
  54837. /**
  54838. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54839. */
  54840. export class BloomEffect extends PostProcessRenderEffect {
  54841. private bloomScale;
  54842. /**
  54843. * @hidden Internal
  54844. */
  54845. _effects: Array<PostProcess>;
  54846. /**
  54847. * @hidden Internal
  54848. */
  54849. _downscale: ExtractHighlightsPostProcess;
  54850. private _blurX;
  54851. private _blurY;
  54852. private _merge;
  54853. /**
  54854. * The luminance threshold to find bright areas of the image to bloom.
  54855. */
  54856. threshold: number;
  54857. /**
  54858. * The strength of the bloom.
  54859. */
  54860. weight: number;
  54861. /**
  54862. * Specifies the size of the bloom blur kernel, relative to the final output size
  54863. */
  54864. kernel: number;
  54865. /**
  54866. * Creates a new instance of @see BloomEffect
  54867. * @param scene The scene the effect belongs to.
  54868. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54869. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54870. * @param bloomWeight The the strength of bloom.
  54871. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54872. * @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)
  54873. */
  54874. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54875. /**
  54876. * Disposes each of the internal effects for a given camera.
  54877. * @param camera The camera to dispose the effect on.
  54878. */
  54879. disposeEffects(camera: Camera): void;
  54880. /**
  54881. * @hidden Internal
  54882. */
  54883. _updateEffects(): void;
  54884. /**
  54885. * Internal
  54886. * @returns if all the contained post processes are ready.
  54887. * @hidden
  54888. */
  54889. _isReady(): boolean;
  54890. }
  54891. }
  54892. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54893. /** @hidden */
  54894. export var chromaticAberrationPixelShader: {
  54895. name: string;
  54896. shader: string;
  54897. };
  54898. }
  54899. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54900. import { Vector2 } from "babylonjs/Maths/math";
  54901. import { Nullable } from "babylonjs/types";
  54902. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54903. import { Camera } from "babylonjs/Cameras/camera";
  54904. import { Engine } from "babylonjs/Engines/engine";
  54905. import "babylonjs/Shaders/chromaticAberration.fragment";
  54906. /**
  54907. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54908. */
  54909. export class ChromaticAberrationPostProcess extends PostProcess {
  54910. /**
  54911. * The amount of seperation of rgb channels (default: 30)
  54912. */
  54913. aberrationAmount: number;
  54914. /**
  54915. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54916. */
  54917. radialIntensity: number;
  54918. /**
  54919. * 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))
  54920. */
  54921. direction: Vector2;
  54922. /**
  54923. * 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))
  54924. */
  54925. centerPosition: Vector2;
  54926. /**
  54927. * Creates a new instance ChromaticAberrationPostProcess
  54928. * @param name The name of the effect.
  54929. * @param screenWidth The width of the screen to apply the effect on.
  54930. * @param screenHeight The height of the screen to apply the effect on.
  54931. * @param options The required width/height ratio to downsize to before computing the render pass.
  54932. * @param camera The camera to apply the render pass to.
  54933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54934. * @param engine The engine which the post process will be applied. (default: current engine)
  54935. * @param reusable If the post process can be reused on the same frame. (default: false)
  54936. * @param textureType Type of textures used when performing the post process. (default: 0)
  54937. * @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)
  54938. */
  54939. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54940. }
  54941. }
  54942. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54943. /** @hidden */
  54944. export var circleOfConfusionPixelShader: {
  54945. name: string;
  54946. shader: string;
  54947. };
  54948. }
  54949. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54950. import { Nullable } from "babylonjs/types";
  54951. import { Engine } from "babylonjs/Engines/engine";
  54952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54954. import { Camera } from "babylonjs/Cameras/camera";
  54955. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54956. /**
  54957. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54958. */
  54959. export class CircleOfConfusionPostProcess extends PostProcess {
  54960. /**
  54961. * 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.
  54962. */
  54963. lensSize: number;
  54964. /**
  54965. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54966. */
  54967. fStop: number;
  54968. /**
  54969. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54970. */
  54971. focusDistance: number;
  54972. /**
  54973. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54974. */
  54975. focalLength: number;
  54976. private _depthTexture;
  54977. /**
  54978. * Creates a new instance CircleOfConfusionPostProcess
  54979. * @param name The name of the effect.
  54980. * @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.
  54981. * @param options The required width/height ratio to downsize to before computing the render pass.
  54982. * @param camera The camera to apply the render pass to.
  54983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54984. * @param engine The engine which the post process will be applied. (default: current engine)
  54985. * @param reusable If the post process can be reused on the same frame. (default: false)
  54986. * @param textureType Type of textures used when performing the post process. (default: 0)
  54987. * @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)
  54988. */
  54989. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54990. /**
  54991. * 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.
  54992. */
  54993. depthTexture: RenderTargetTexture;
  54994. }
  54995. }
  54996. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54997. /** @hidden */
  54998. export var colorCorrectionPixelShader: {
  54999. name: string;
  55000. shader: string;
  55001. };
  55002. }
  55003. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55004. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55005. import { Engine } from "babylonjs/Engines/engine";
  55006. import { Camera } from "babylonjs/Cameras/camera";
  55007. import "babylonjs/Shaders/colorCorrection.fragment";
  55008. /**
  55009. *
  55010. * This post-process allows the modification of rendered colors by using
  55011. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55012. *
  55013. * The object needs to be provided an url to a texture containing the color
  55014. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55015. * Use an image editing software to tweak the LUT to match your needs.
  55016. *
  55017. * For an example of a color LUT, see here:
  55018. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55019. * For explanations on color grading, see here:
  55020. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55021. *
  55022. */
  55023. export class ColorCorrectionPostProcess extends PostProcess {
  55024. private _colorTableTexture;
  55025. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55026. }
  55027. }
  55028. declare module "babylonjs/Shaders/convolution.fragment" {
  55029. /** @hidden */
  55030. export var convolutionPixelShader: {
  55031. name: string;
  55032. shader: string;
  55033. };
  55034. }
  55035. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55036. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55037. import { Nullable } from "babylonjs/types";
  55038. import { Camera } from "babylonjs/Cameras/camera";
  55039. import { Engine } from "babylonjs/Engines/engine";
  55040. import "babylonjs/Shaders/convolution.fragment";
  55041. /**
  55042. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55043. * input texture to perform effects such as edge detection or sharpening
  55044. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55045. */
  55046. export class ConvolutionPostProcess extends PostProcess {
  55047. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55048. kernel: number[];
  55049. /**
  55050. * Creates a new instance ConvolutionPostProcess
  55051. * @param name The name of the effect.
  55052. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55053. * @param options The required width/height ratio to downsize to before computing the render pass.
  55054. * @param camera The camera to apply the render pass to.
  55055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55056. * @param engine The engine which the post process will be applied. (default: current engine)
  55057. * @param reusable If the post process can be reused on the same frame. (default: false)
  55058. * @param textureType Type of textures used when performing the post process. (default: 0)
  55059. */
  55060. constructor(name: string,
  55061. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55062. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55063. /**
  55064. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55065. */
  55066. static EdgeDetect0Kernel: number[];
  55067. /**
  55068. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55069. */
  55070. static EdgeDetect1Kernel: number[];
  55071. /**
  55072. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55073. */
  55074. static EdgeDetect2Kernel: number[];
  55075. /**
  55076. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55077. */
  55078. static SharpenKernel: number[];
  55079. /**
  55080. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55081. */
  55082. static EmbossKernel: number[];
  55083. /**
  55084. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55085. */
  55086. static GaussianKernel: number[];
  55087. }
  55088. }
  55089. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55090. import { Nullable } from "babylonjs/types";
  55091. import { Vector2 } from "babylonjs/Maths/math";
  55092. import { Camera } from "babylonjs/Cameras/camera";
  55093. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55094. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55095. import { Engine } from "babylonjs/Engines/engine";
  55096. import { Scene } from "babylonjs/scene";
  55097. /**
  55098. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55099. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55100. * based on samples that have a large difference in distance than the center pixel.
  55101. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55102. */
  55103. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55104. direction: Vector2;
  55105. /**
  55106. * Creates a new instance CircleOfConfusionPostProcess
  55107. * @param name The name of the effect.
  55108. * @param scene The scene the effect belongs to.
  55109. * @param direction The direction the blur should be applied.
  55110. * @param kernel The size of the kernel used to blur.
  55111. * @param options The required width/height ratio to downsize to before computing the render pass.
  55112. * @param camera The camera to apply the render pass to.
  55113. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55114. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55116. * @param engine The engine which the post process will be applied. (default: current engine)
  55117. * @param reusable If the post process can be reused on the same frame. (default: false)
  55118. * @param textureType Type of textures used when performing the post process. (default: 0)
  55119. * @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)
  55120. */
  55121. 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);
  55122. }
  55123. }
  55124. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55125. /** @hidden */
  55126. export var depthOfFieldMergePixelShader: {
  55127. name: string;
  55128. shader: string;
  55129. };
  55130. }
  55131. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55132. import { Nullable } from "babylonjs/types";
  55133. import { Camera } from "babylonjs/Cameras/camera";
  55134. import { Effect } from "babylonjs/Materials/effect";
  55135. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55136. import { Engine } from "babylonjs/Engines/engine";
  55137. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55138. /**
  55139. * Options to be set when merging outputs from the default pipeline.
  55140. */
  55141. export class DepthOfFieldMergePostProcessOptions {
  55142. /**
  55143. * The original image to merge on top of
  55144. */
  55145. originalFromInput: PostProcess;
  55146. /**
  55147. * Parameters to perform the merge of the depth of field effect
  55148. */
  55149. depthOfField?: {
  55150. circleOfConfusion: PostProcess;
  55151. blurSteps: Array<PostProcess>;
  55152. };
  55153. /**
  55154. * Parameters to perform the merge of bloom effect
  55155. */
  55156. bloom?: {
  55157. blurred: PostProcess;
  55158. weight: number;
  55159. };
  55160. }
  55161. /**
  55162. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55163. */
  55164. export class DepthOfFieldMergePostProcess extends PostProcess {
  55165. private blurSteps;
  55166. /**
  55167. * Creates a new instance of DepthOfFieldMergePostProcess
  55168. * @param name The name of the effect.
  55169. * @param originalFromInput Post process which's input will be used for the merge.
  55170. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55171. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55172. * @param options The required width/height ratio to downsize to before computing the render pass.
  55173. * @param camera The camera to apply the render pass to.
  55174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55175. * @param engine The engine which the post process will be applied. (default: current engine)
  55176. * @param reusable If the post process can be reused on the same frame. (default: false)
  55177. * @param textureType Type of textures used when performing the post process. (default: 0)
  55178. * @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)
  55179. */
  55180. 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);
  55181. /**
  55182. * Updates the effect with the current post process compile time values and recompiles the shader.
  55183. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55184. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55185. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55186. * @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
  55187. * @param onCompiled Called when the shader has been compiled.
  55188. * @param onError Called if there is an error when compiling a shader.
  55189. */
  55190. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55191. }
  55192. }
  55193. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55194. import { Nullable } from "babylonjs/types";
  55195. import { Camera } from "babylonjs/Cameras/camera";
  55196. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55197. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55198. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55199. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55200. import { Scene } from "babylonjs/scene";
  55201. /**
  55202. * Specifies the level of max blur that should be applied when using the depth of field effect
  55203. */
  55204. export enum DepthOfFieldEffectBlurLevel {
  55205. /**
  55206. * Subtle blur
  55207. */
  55208. Low = 0,
  55209. /**
  55210. * Medium blur
  55211. */
  55212. Medium = 1,
  55213. /**
  55214. * Large blur
  55215. */
  55216. High = 2
  55217. }
  55218. /**
  55219. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55220. */
  55221. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55222. private _circleOfConfusion;
  55223. /**
  55224. * @hidden Internal, blurs from high to low
  55225. */
  55226. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55227. private _depthOfFieldBlurY;
  55228. private _dofMerge;
  55229. /**
  55230. * @hidden Internal post processes in depth of field effect
  55231. */
  55232. _effects: Array<PostProcess>;
  55233. /**
  55234. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55235. */
  55236. focalLength: number;
  55237. /**
  55238. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55239. */
  55240. fStop: number;
  55241. /**
  55242. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55243. */
  55244. focusDistance: number;
  55245. /**
  55246. * 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.
  55247. */
  55248. lensSize: number;
  55249. /**
  55250. * Creates a new instance DepthOfFieldEffect
  55251. * @param scene The scene the effect belongs to.
  55252. * @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.
  55253. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55254. * @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)
  55255. */
  55256. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55257. /**
  55258. * Get the current class name of the current effet
  55259. * @returns "DepthOfFieldEffect"
  55260. */
  55261. getClassName(): string;
  55262. /**
  55263. * 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.
  55264. */
  55265. depthTexture: RenderTargetTexture;
  55266. /**
  55267. * Disposes each of the internal effects for a given camera.
  55268. * @param camera The camera to dispose the effect on.
  55269. */
  55270. disposeEffects(camera: Camera): void;
  55271. /**
  55272. * @hidden Internal
  55273. */
  55274. _updateEffects(): void;
  55275. /**
  55276. * Internal
  55277. * @returns if all the contained post processes are ready.
  55278. * @hidden
  55279. */
  55280. _isReady(): boolean;
  55281. }
  55282. }
  55283. declare module "babylonjs/Shaders/displayPass.fragment" {
  55284. /** @hidden */
  55285. export var displayPassPixelShader: {
  55286. name: string;
  55287. shader: string;
  55288. };
  55289. }
  55290. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55291. import { Nullable } from "babylonjs/types";
  55292. import { Camera } from "babylonjs/Cameras/camera";
  55293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55294. import { Engine } from "babylonjs/Engines/engine";
  55295. import "babylonjs/Shaders/displayPass.fragment";
  55296. /**
  55297. * DisplayPassPostProcess which produces an output the same as it's input
  55298. */
  55299. export class DisplayPassPostProcess extends PostProcess {
  55300. /**
  55301. * Creates the DisplayPassPostProcess
  55302. * @param name The name of the effect.
  55303. * @param options The required width/height ratio to downsize to before computing the render pass.
  55304. * @param camera The camera to apply the render pass to.
  55305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55306. * @param engine The engine which the post process will be applied. (default: current engine)
  55307. * @param reusable If the post process can be reused on the same frame. (default: false)
  55308. */
  55309. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55310. }
  55311. }
  55312. declare module "babylonjs/Shaders/filter.fragment" {
  55313. /** @hidden */
  55314. export var filterPixelShader: {
  55315. name: string;
  55316. shader: string;
  55317. };
  55318. }
  55319. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55320. import { Nullable } from "babylonjs/types";
  55321. import { Matrix } from "babylonjs/Maths/math";
  55322. import { Camera } from "babylonjs/Cameras/camera";
  55323. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55324. import { Engine } from "babylonjs/Engines/engine";
  55325. import "babylonjs/Shaders/filter.fragment";
  55326. /**
  55327. * Applies a kernel filter to the image
  55328. */
  55329. export class FilterPostProcess extends PostProcess {
  55330. /** The matrix to be applied to the image */
  55331. kernelMatrix: Matrix;
  55332. /**
  55333. *
  55334. * @param name The name of the effect.
  55335. * @param kernelMatrix The matrix to be applied to the image
  55336. * @param options The required width/height ratio to downsize to before computing the render pass.
  55337. * @param camera The camera to apply the render pass to.
  55338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55339. * @param engine The engine which the post process will be applied. (default: current engine)
  55340. * @param reusable If the post process can be reused on the same frame. (default: false)
  55341. */
  55342. constructor(name: string,
  55343. /** The matrix to be applied to the image */
  55344. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55345. }
  55346. }
  55347. declare module "babylonjs/Shaders/fxaa.fragment" {
  55348. /** @hidden */
  55349. export var fxaaPixelShader: {
  55350. name: string;
  55351. shader: string;
  55352. };
  55353. }
  55354. declare module "babylonjs/Shaders/fxaa.vertex" {
  55355. /** @hidden */
  55356. export var fxaaVertexShader: {
  55357. name: string;
  55358. shader: string;
  55359. };
  55360. }
  55361. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55362. import { Nullable } from "babylonjs/types";
  55363. import { Camera } from "babylonjs/Cameras/camera";
  55364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55365. import { Engine } from "babylonjs/Engines/engine";
  55366. import "babylonjs/Shaders/fxaa.fragment";
  55367. import "babylonjs/Shaders/fxaa.vertex";
  55368. /**
  55369. * Fxaa post process
  55370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55371. */
  55372. export class FxaaPostProcess extends PostProcess {
  55373. /** @hidden */
  55374. texelWidth: number;
  55375. /** @hidden */
  55376. texelHeight: number;
  55377. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55378. private _getDefines;
  55379. }
  55380. }
  55381. declare module "babylonjs/Shaders/grain.fragment" {
  55382. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55383. /** @hidden */
  55384. export var grainPixelShader: {
  55385. name: string;
  55386. shader: string;
  55387. };
  55388. }
  55389. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55390. import { Nullable } from "babylonjs/types";
  55391. import { Camera } from "babylonjs/Cameras/camera";
  55392. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55393. import { Engine } from "babylonjs/Engines/engine";
  55394. import "babylonjs/Shaders/grain.fragment";
  55395. /**
  55396. * The GrainPostProcess adds noise to the image at mid luminance levels
  55397. */
  55398. export class GrainPostProcess extends PostProcess {
  55399. /**
  55400. * The intensity of the grain added (default: 30)
  55401. */
  55402. intensity: number;
  55403. /**
  55404. * If the grain should be randomized on every frame
  55405. */
  55406. animated: boolean;
  55407. /**
  55408. * Creates a new instance of @see GrainPostProcess
  55409. * @param name The name of the effect.
  55410. * @param options The required width/height ratio to downsize to before computing the render pass.
  55411. * @param camera The camera to apply the render pass to.
  55412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55413. * @param engine The engine which the post process will be applied. (default: current engine)
  55414. * @param reusable If the post process can be reused on the same frame. (default: false)
  55415. * @param textureType Type of textures used when performing the post process. (default: 0)
  55416. * @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)
  55417. */
  55418. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55419. }
  55420. }
  55421. declare module "babylonjs/Shaders/highlights.fragment" {
  55422. /** @hidden */
  55423. export var highlightsPixelShader: {
  55424. name: string;
  55425. shader: string;
  55426. };
  55427. }
  55428. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55429. import { Nullable } from "babylonjs/types";
  55430. import { Camera } from "babylonjs/Cameras/camera";
  55431. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55432. import { Engine } from "babylonjs/Engines/engine";
  55433. import "babylonjs/Shaders/highlights.fragment";
  55434. /**
  55435. * Extracts highlights from the image
  55436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55437. */
  55438. export class HighlightsPostProcess extends PostProcess {
  55439. /**
  55440. * Extracts highlights from the image
  55441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55442. * @param name The name of the effect.
  55443. * @param options The required width/height ratio to downsize to before computing the render pass.
  55444. * @param camera The camera to apply the render pass to.
  55445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55446. * @param engine The engine which the post process will be applied. (default: current engine)
  55447. * @param reusable If the post process can be reused on the same frame. (default: false)
  55448. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55449. */
  55450. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55451. }
  55452. }
  55453. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55454. /** @hidden */
  55455. export var mrtFragmentDeclaration: {
  55456. name: string;
  55457. shader: string;
  55458. };
  55459. }
  55460. declare module "babylonjs/Shaders/geometry.fragment" {
  55461. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55462. /** @hidden */
  55463. export var geometryPixelShader: {
  55464. name: string;
  55465. shader: string;
  55466. };
  55467. }
  55468. declare module "babylonjs/Shaders/geometry.vertex" {
  55469. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55470. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55471. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55472. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55473. /** @hidden */
  55474. export var geometryVertexShader: {
  55475. name: string;
  55476. shader: string;
  55477. };
  55478. }
  55479. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55480. import { Matrix } from "babylonjs/Maths/math";
  55481. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55482. import { Mesh } from "babylonjs/Meshes/mesh";
  55483. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55484. import { Effect } from "babylonjs/Materials/effect";
  55485. import { Scene } from "babylonjs/scene";
  55486. import "babylonjs/Shaders/geometry.fragment";
  55487. import "babylonjs/Shaders/geometry.vertex";
  55488. /**
  55489. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55490. */
  55491. export class GeometryBufferRenderer {
  55492. /**
  55493. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55494. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55495. */
  55496. static readonly POSITION_TEXTURE_TYPE: number;
  55497. /**
  55498. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55499. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55500. */
  55501. static readonly VELOCITY_TEXTURE_TYPE: number;
  55502. /**
  55503. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55504. * in order to compute objects velocities when enableVelocity is set to "true"
  55505. * @hidden
  55506. */
  55507. _previousTransformationMatrices: {
  55508. [index: number]: Matrix;
  55509. };
  55510. private _scene;
  55511. private _multiRenderTarget;
  55512. private _ratio;
  55513. private _enablePosition;
  55514. private _enableVelocity;
  55515. private _positionIndex;
  55516. private _velocityIndex;
  55517. protected _effect: Effect;
  55518. protected _cachedDefines: string;
  55519. /**
  55520. * Set the render list (meshes to be rendered) used in the G buffer.
  55521. */
  55522. renderList: Mesh[];
  55523. /**
  55524. * Gets wether or not G buffer are supported by the running hardware.
  55525. * This requires draw buffer supports
  55526. */
  55527. readonly isSupported: boolean;
  55528. /**
  55529. * Returns the index of the given texture type in the G-Buffer textures array
  55530. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55531. * @returns the index of the given texture type in the G-Buffer textures array
  55532. */
  55533. getTextureIndex(textureType: number): number;
  55534. /**
  55535. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55536. */
  55537. /**
  55538. * Sets whether or not objects positions are enabled for the G buffer.
  55539. */
  55540. enablePosition: boolean;
  55541. /**
  55542. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55543. */
  55544. /**
  55545. * Sets wether or not objects velocities are enabled for the G buffer.
  55546. */
  55547. enableVelocity: boolean;
  55548. /**
  55549. * Gets the scene associated with the buffer.
  55550. */
  55551. readonly scene: Scene;
  55552. /**
  55553. * Gets the ratio used by the buffer during its creation.
  55554. * How big is the buffer related to the main canvas.
  55555. */
  55556. readonly ratio: number;
  55557. /** @hidden */
  55558. static _SceneComponentInitialization: (scene: Scene) => void;
  55559. /**
  55560. * Creates a new G Buffer for the scene
  55561. * @param scene The scene the buffer belongs to
  55562. * @param ratio How big is the buffer related to the main canvas.
  55563. */
  55564. constructor(scene: Scene, ratio?: number);
  55565. /**
  55566. * Checks wether everything is ready to render a submesh to the G buffer.
  55567. * @param subMesh the submesh to check readiness for
  55568. * @param useInstances is the mesh drawn using instance or not
  55569. * @returns true if ready otherwise false
  55570. */
  55571. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55572. /**
  55573. * Gets the current underlying G Buffer.
  55574. * @returns the buffer
  55575. */
  55576. getGBuffer(): MultiRenderTarget;
  55577. /**
  55578. * Gets the number of samples used to render the buffer (anti aliasing).
  55579. */
  55580. /**
  55581. * Sets the number of samples used to render the buffer (anti aliasing).
  55582. */
  55583. samples: number;
  55584. /**
  55585. * Disposes the renderer and frees up associated resources.
  55586. */
  55587. dispose(): void;
  55588. protected _createRenderTargets(): void;
  55589. }
  55590. }
  55591. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55592. import { Nullable } from "babylonjs/types";
  55593. import { Scene } from "babylonjs/scene";
  55594. import { ISceneComponent } from "babylonjs/sceneComponent";
  55595. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55596. module "babylonjs/scene" {
  55597. interface Scene {
  55598. /** @hidden (Backing field) */
  55599. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55600. /**
  55601. * Gets or Sets the current geometry buffer associated to the scene.
  55602. */
  55603. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55604. /**
  55605. * Enables a GeometryBufferRender and associates it with the scene
  55606. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55607. * @returns the GeometryBufferRenderer
  55608. */
  55609. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55610. /**
  55611. * Disables the GeometryBufferRender associated with the scene
  55612. */
  55613. disableGeometryBufferRenderer(): void;
  55614. }
  55615. }
  55616. /**
  55617. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55618. * in several rendering techniques.
  55619. */
  55620. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55621. /**
  55622. * The component name helpful to identify the component in the list of scene components.
  55623. */
  55624. readonly name: string;
  55625. /**
  55626. * The scene the component belongs to.
  55627. */
  55628. scene: Scene;
  55629. /**
  55630. * Creates a new instance of the component for the given scene
  55631. * @param scene Defines the scene to register the component in
  55632. */
  55633. constructor(scene: Scene);
  55634. /**
  55635. * Registers the component in a given scene
  55636. */
  55637. register(): void;
  55638. /**
  55639. * Rebuilds the elements related to this component in case of
  55640. * context lost for instance.
  55641. */
  55642. rebuild(): void;
  55643. /**
  55644. * Disposes the component and the associated ressources
  55645. */
  55646. dispose(): void;
  55647. private _gatherRenderTargets;
  55648. }
  55649. }
  55650. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55651. /** @hidden */
  55652. export var motionBlurPixelShader: {
  55653. name: string;
  55654. shader: string;
  55655. };
  55656. }
  55657. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55658. import { Nullable } from "babylonjs/types";
  55659. import { Camera } from "babylonjs/Cameras/camera";
  55660. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55661. import { Scene } from "babylonjs/scene";
  55662. import "babylonjs/Animations/animatable";
  55663. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55664. import "babylonjs/Shaders/motionBlur.fragment";
  55665. import { Engine } from "babylonjs/Engines/engine";
  55666. /**
  55667. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55668. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55669. * As an example, all you have to do is to create the post-process:
  55670. * var mb = new BABYLON.MotionBlurPostProcess(
  55671. * 'mb', // The name of the effect.
  55672. * scene, // The scene containing the objects to blur according to their velocity.
  55673. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55674. * camera // The camera to apply the render pass to.
  55675. * );
  55676. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55677. */
  55678. export class MotionBlurPostProcess extends PostProcess {
  55679. /**
  55680. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55681. */
  55682. motionStrength: number;
  55683. /**
  55684. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55685. */
  55686. /**
  55687. * Sets the number of iterations to be used for motion blur quality
  55688. */
  55689. motionBlurSamples: number;
  55690. private _motionBlurSamples;
  55691. private _geometryBufferRenderer;
  55692. /**
  55693. * Creates a new instance MotionBlurPostProcess
  55694. * @param name The name of the effect.
  55695. * @param scene The scene containing the objects to blur according to their velocity.
  55696. * @param options The required width/height ratio to downsize to before computing the render pass.
  55697. * @param camera The camera to apply the render pass to.
  55698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55699. * @param engine The engine which the post process will be applied. (default: current engine)
  55700. * @param reusable If the post process can be reused on the same frame. (default: false)
  55701. * @param textureType Type of textures used when performing the post process. (default: 0)
  55702. * @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)
  55703. */
  55704. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55705. /**
  55706. * Disposes the post process.
  55707. * @param camera The camera to dispose the post process on.
  55708. */
  55709. dispose(camera?: Camera): void;
  55710. }
  55711. }
  55712. declare module "babylonjs/Shaders/refraction.fragment" {
  55713. /** @hidden */
  55714. export var refractionPixelShader: {
  55715. name: string;
  55716. shader: string;
  55717. };
  55718. }
  55719. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55720. import { Color3 } from "babylonjs/Maths/math";
  55721. import { Camera } from "babylonjs/Cameras/camera";
  55722. import { Texture } from "babylonjs/Materials/Textures/texture";
  55723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55724. import { Engine } from "babylonjs/Engines/engine";
  55725. import "babylonjs/Shaders/refraction.fragment";
  55726. /**
  55727. * Post process which applies a refractin texture
  55728. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55729. */
  55730. export class RefractionPostProcess extends PostProcess {
  55731. /** the base color of the refraction (used to taint the rendering) */
  55732. color: Color3;
  55733. /** simulated refraction depth */
  55734. depth: number;
  55735. /** the coefficient of the base color (0 to remove base color tainting) */
  55736. colorLevel: number;
  55737. private _refTexture;
  55738. private _ownRefractionTexture;
  55739. /**
  55740. * Gets or sets the refraction texture
  55741. * Please note that you are responsible for disposing the texture if you set it manually
  55742. */
  55743. refractionTexture: Texture;
  55744. /**
  55745. * Initializes the RefractionPostProcess
  55746. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55747. * @param name The name of the effect.
  55748. * @param refractionTextureUrl Url of the refraction texture to use
  55749. * @param color the base color of the refraction (used to taint the rendering)
  55750. * @param depth simulated refraction depth
  55751. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55752. * @param camera The camera to apply the render pass to.
  55753. * @param options The required width/height ratio to downsize to before computing the render pass.
  55754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55755. * @param engine The engine which the post process will be applied. (default: current engine)
  55756. * @param reusable If the post process can be reused on the same frame. (default: false)
  55757. */
  55758. constructor(name: string, refractionTextureUrl: string,
  55759. /** the base color of the refraction (used to taint the rendering) */
  55760. color: Color3,
  55761. /** simulated refraction depth */
  55762. depth: number,
  55763. /** the coefficient of the base color (0 to remove base color tainting) */
  55764. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55765. /**
  55766. * Disposes of the post process
  55767. * @param camera Camera to dispose post process on
  55768. */
  55769. dispose(camera: Camera): void;
  55770. }
  55771. }
  55772. declare module "babylonjs/Shaders/sharpen.fragment" {
  55773. /** @hidden */
  55774. export var sharpenPixelShader: {
  55775. name: string;
  55776. shader: string;
  55777. };
  55778. }
  55779. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55780. import { Nullable } from "babylonjs/types";
  55781. import { Camera } from "babylonjs/Cameras/camera";
  55782. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55783. import "babylonjs/Shaders/sharpen.fragment";
  55784. import { Engine } from "babylonjs/Engines/engine";
  55785. /**
  55786. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55787. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55788. */
  55789. export class SharpenPostProcess extends PostProcess {
  55790. /**
  55791. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55792. */
  55793. colorAmount: number;
  55794. /**
  55795. * How much sharpness should be applied (default: 0.3)
  55796. */
  55797. edgeAmount: number;
  55798. /**
  55799. * Creates a new instance ConvolutionPostProcess
  55800. * @param name The name of the effect.
  55801. * @param options The required width/height ratio to downsize to before computing the render pass.
  55802. * @param camera The camera to apply the render pass to.
  55803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55804. * @param engine The engine which the post process will be applied. (default: current engine)
  55805. * @param reusable If the post process can be reused on the same frame. (default: false)
  55806. * @param textureType Type of textures used when performing the post process. (default: 0)
  55807. * @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)
  55808. */
  55809. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55810. }
  55811. }
  55812. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55813. import { Nullable } from "babylonjs/types";
  55814. import { Camera } from "babylonjs/Cameras/camera";
  55815. import { Engine } from "babylonjs/Engines/engine";
  55816. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55817. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55818. /**
  55819. * PostProcessRenderPipeline
  55820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55821. */
  55822. export class PostProcessRenderPipeline {
  55823. private engine;
  55824. private _renderEffects;
  55825. private _renderEffectsForIsolatedPass;
  55826. /**
  55827. * List of inspectable custom properties (used by the Inspector)
  55828. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55829. */
  55830. inspectableCustomProperties: IInspectable[];
  55831. /**
  55832. * @hidden
  55833. */
  55834. protected _cameras: Camera[];
  55835. /** @hidden */
  55836. _name: string;
  55837. /**
  55838. * Gets pipeline name
  55839. */
  55840. readonly name: string;
  55841. /**
  55842. * Initializes a PostProcessRenderPipeline
  55843. * @param engine engine to add the pipeline to
  55844. * @param name name of the pipeline
  55845. */
  55846. constructor(engine: Engine, name: string);
  55847. /**
  55848. * Gets the class name
  55849. * @returns "PostProcessRenderPipeline"
  55850. */
  55851. getClassName(): string;
  55852. /**
  55853. * If all the render effects in the pipeline are supported
  55854. */
  55855. readonly isSupported: boolean;
  55856. /**
  55857. * Adds an effect to the pipeline
  55858. * @param renderEffect the effect to add
  55859. */
  55860. addEffect(renderEffect: PostProcessRenderEffect): void;
  55861. /** @hidden */
  55862. _rebuild(): void;
  55863. /** @hidden */
  55864. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55865. /** @hidden */
  55866. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55867. /** @hidden */
  55868. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55869. /** @hidden */
  55870. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55871. /** @hidden */
  55872. _attachCameras(cameras: Camera, unique: boolean): void;
  55873. /** @hidden */
  55874. _attachCameras(cameras: Camera[], unique: boolean): void;
  55875. /** @hidden */
  55876. _detachCameras(cameras: Camera): void;
  55877. /** @hidden */
  55878. _detachCameras(cameras: Nullable<Camera[]>): void;
  55879. /** @hidden */
  55880. _update(): void;
  55881. /** @hidden */
  55882. _reset(): void;
  55883. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55884. /**
  55885. * Disposes of the pipeline
  55886. */
  55887. dispose(): void;
  55888. }
  55889. }
  55890. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55891. import { Camera } from "babylonjs/Cameras/camera";
  55892. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55893. /**
  55894. * PostProcessRenderPipelineManager class
  55895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55896. */
  55897. export class PostProcessRenderPipelineManager {
  55898. private _renderPipelines;
  55899. /**
  55900. * Initializes a PostProcessRenderPipelineManager
  55901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55902. */
  55903. constructor();
  55904. /**
  55905. * Gets the list of supported render pipelines
  55906. */
  55907. readonly supportedPipelines: PostProcessRenderPipeline[];
  55908. /**
  55909. * Adds a pipeline to the manager
  55910. * @param renderPipeline The pipeline to add
  55911. */
  55912. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55913. /**
  55914. * Attaches a camera to the pipeline
  55915. * @param renderPipelineName The name of the pipeline to attach to
  55916. * @param cameras the camera to attach
  55917. * @param unique if the camera can be attached multiple times to the pipeline
  55918. */
  55919. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55920. /**
  55921. * Detaches a camera from the pipeline
  55922. * @param renderPipelineName The name of the pipeline to detach from
  55923. * @param cameras the camera to detach
  55924. */
  55925. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55926. /**
  55927. * Enables an effect by name on a pipeline
  55928. * @param renderPipelineName the name of the pipeline to enable the effect in
  55929. * @param renderEffectName the name of the effect to enable
  55930. * @param cameras the cameras that the effect should be enabled on
  55931. */
  55932. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55933. /**
  55934. * Disables an effect by name on a pipeline
  55935. * @param renderPipelineName the name of the pipeline to disable the effect in
  55936. * @param renderEffectName the name of the effect to disable
  55937. * @param cameras the cameras that the effect should be disabled on
  55938. */
  55939. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55940. /**
  55941. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55942. */
  55943. update(): void;
  55944. /** @hidden */
  55945. _rebuild(): void;
  55946. /**
  55947. * Disposes of the manager and pipelines
  55948. */
  55949. dispose(): void;
  55950. }
  55951. }
  55952. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55953. import { ISceneComponent } from "babylonjs/sceneComponent";
  55954. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55955. import { Scene } from "babylonjs/scene";
  55956. module "babylonjs/scene" {
  55957. interface Scene {
  55958. /** @hidden (Backing field) */
  55959. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55960. /**
  55961. * Gets the postprocess render pipeline manager
  55962. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55963. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55964. */
  55965. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55966. }
  55967. }
  55968. /**
  55969. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55970. */
  55971. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55972. /**
  55973. * The component name helpfull to identify the component in the list of scene components.
  55974. */
  55975. readonly name: string;
  55976. /**
  55977. * The scene the component belongs to.
  55978. */
  55979. scene: Scene;
  55980. /**
  55981. * Creates a new instance of the component for the given scene
  55982. * @param scene Defines the scene to register the component in
  55983. */
  55984. constructor(scene: Scene);
  55985. /**
  55986. * Registers the component in a given scene
  55987. */
  55988. register(): void;
  55989. /**
  55990. * Rebuilds the elements related to this component in case of
  55991. * context lost for instance.
  55992. */
  55993. rebuild(): void;
  55994. /**
  55995. * Disposes the component and the associated ressources
  55996. */
  55997. dispose(): void;
  55998. private _gatherRenderTargets;
  55999. }
  56000. }
  56001. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56002. import { IAnimatable } from "babylonjs/Misc/tools";
  56003. import { Camera } from "babylonjs/Cameras/camera";
  56004. import { IDisposable } from "babylonjs/scene";
  56005. import { Scene } from "babylonjs/scene";
  56006. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56007. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56008. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56009. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56010. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56011. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56012. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56013. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56014. import { Animation } from "babylonjs/Animations/animation";
  56015. /**
  56016. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56017. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56018. */
  56019. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56020. private _scene;
  56021. private _camerasToBeAttached;
  56022. /**
  56023. * ID of the sharpen post process,
  56024. */
  56025. private readonly SharpenPostProcessId;
  56026. /**
  56027. * @ignore
  56028. * ID of the image processing post process;
  56029. */
  56030. readonly ImageProcessingPostProcessId: string;
  56031. /**
  56032. * @ignore
  56033. * ID of the Fast Approximate Anti-Aliasing post process;
  56034. */
  56035. readonly FxaaPostProcessId: string;
  56036. /**
  56037. * ID of the chromatic aberration post process,
  56038. */
  56039. private readonly ChromaticAberrationPostProcessId;
  56040. /**
  56041. * ID of the grain post process
  56042. */
  56043. private readonly GrainPostProcessId;
  56044. /**
  56045. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56046. */
  56047. sharpen: SharpenPostProcess;
  56048. private _sharpenEffect;
  56049. private bloom;
  56050. /**
  56051. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56052. */
  56053. depthOfField: DepthOfFieldEffect;
  56054. /**
  56055. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56056. */
  56057. fxaa: FxaaPostProcess;
  56058. /**
  56059. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56060. */
  56061. imageProcessing: ImageProcessingPostProcess;
  56062. /**
  56063. * Chromatic aberration post process which will shift rgb colors in the image
  56064. */
  56065. chromaticAberration: ChromaticAberrationPostProcess;
  56066. private _chromaticAberrationEffect;
  56067. /**
  56068. * Grain post process which add noise to the image
  56069. */
  56070. grain: GrainPostProcess;
  56071. private _grainEffect;
  56072. /**
  56073. * Glow post process which adds a glow to emissive areas of the image
  56074. */
  56075. private _glowLayer;
  56076. /**
  56077. * Animations which can be used to tweak settings over a period of time
  56078. */
  56079. animations: Animation[];
  56080. private _imageProcessingConfigurationObserver;
  56081. private _sharpenEnabled;
  56082. private _bloomEnabled;
  56083. private _depthOfFieldEnabled;
  56084. private _depthOfFieldBlurLevel;
  56085. private _fxaaEnabled;
  56086. private _imageProcessingEnabled;
  56087. private _defaultPipelineTextureType;
  56088. private _bloomScale;
  56089. private _chromaticAberrationEnabled;
  56090. private _grainEnabled;
  56091. private _buildAllowed;
  56092. /**
  56093. * Gets active scene
  56094. */
  56095. readonly scene: Scene;
  56096. /**
  56097. * Enable or disable the sharpen process from the pipeline
  56098. */
  56099. sharpenEnabled: boolean;
  56100. private _resizeObserver;
  56101. private _hardwareScaleLevel;
  56102. private _bloomKernel;
  56103. /**
  56104. * Specifies the size of the bloom blur kernel, relative to the final output size
  56105. */
  56106. bloomKernel: number;
  56107. /**
  56108. * Specifies the weight of the bloom in the final rendering
  56109. */
  56110. private _bloomWeight;
  56111. /**
  56112. * Specifies the luma threshold for the area that will be blurred by the bloom
  56113. */
  56114. private _bloomThreshold;
  56115. private _hdr;
  56116. /**
  56117. * The strength of the bloom.
  56118. */
  56119. bloomWeight: number;
  56120. /**
  56121. * The strength of the bloom.
  56122. */
  56123. bloomThreshold: number;
  56124. /**
  56125. * The scale of the bloom, lower value will provide better performance.
  56126. */
  56127. bloomScale: number;
  56128. /**
  56129. * Enable or disable the bloom from the pipeline
  56130. */
  56131. bloomEnabled: boolean;
  56132. private _rebuildBloom;
  56133. /**
  56134. * If the depth of field is enabled.
  56135. */
  56136. depthOfFieldEnabled: boolean;
  56137. /**
  56138. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56139. */
  56140. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56141. /**
  56142. * If the anti aliasing is enabled.
  56143. */
  56144. fxaaEnabled: boolean;
  56145. private _samples;
  56146. /**
  56147. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56148. */
  56149. samples: number;
  56150. /**
  56151. * If image processing is enabled.
  56152. */
  56153. imageProcessingEnabled: boolean;
  56154. /**
  56155. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56156. */
  56157. glowLayerEnabled: boolean;
  56158. /**
  56159. * Enable or disable the chromaticAberration process from the pipeline
  56160. */
  56161. chromaticAberrationEnabled: boolean;
  56162. /**
  56163. * Enable or disable the grain process from the pipeline
  56164. */
  56165. grainEnabled: boolean;
  56166. /**
  56167. * @constructor
  56168. * @param name - The rendering pipeline name (default: "")
  56169. * @param hdr - If high dynamic range textures should be used (default: true)
  56170. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56171. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56172. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56173. */
  56174. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56175. /**
  56176. * Get the class name
  56177. * @returns "DefaultRenderingPipeline"
  56178. */
  56179. getClassName(): string;
  56180. /**
  56181. * Force the compilation of the entire pipeline.
  56182. */
  56183. prepare(): void;
  56184. private _hasCleared;
  56185. private _prevPostProcess;
  56186. private _prevPrevPostProcess;
  56187. private _setAutoClearAndTextureSharing;
  56188. private _depthOfFieldSceneObserver;
  56189. private _buildPipeline;
  56190. private _disposePostProcesses;
  56191. /**
  56192. * Adds a camera to the pipeline
  56193. * @param camera the camera to be added
  56194. */
  56195. addCamera(camera: Camera): void;
  56196. /**
  56197. * Removes a camera from the pipeline
  56198. * @param camera the camera to remove
  56199. */
  56200. removeCamera(camera: Camera): void;
  56201. /**
  56202. * Dispose of the pipeline and stop all post processes
  56203. */
  56204. dispose(): void;
  56205. /**
  56206. * Serialize the rendering pipeline (Used when exporting)
  56207. * @returns the serialized object
  56208. */
  56209. serialize(): any;
  56210. /**
  56211. * Parse the serialized pipeline
  56212. * @param source Source pipeline.
  56213. * @param scene The scene to load the pipeline to.
  56214. * @param rootUrl The URL of the serialized pipeline.
  56215. * @returns An instantiated pipeline from the serialized object.
  56216. */
  56217. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56218. }
  56219. }
  56220. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56221. /** @hidden */
  56222. export var lensHighlightsPixelShader: {
  56223. name: string;
  56224. shader: string;
  56225. };
  56226. }
  56227. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56228. /** @hidden */
  56229. export var depthOfFieldPixelShader: {
  56230. name: string;
  56231. shader: string;
  56232. };
  56233. }
  56234. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56235. import { Camera } from "babylonjs/Cameras/camera";
  56236. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56237. import { Scene } from "babylonjs/scene";
  56238. import "babylonjs/Shaders/chromaticAberration.fragment";
  56239. import "babylonjs/Shaders/lensHighlights.fragment";
  56240. import "babylonjs/Shaders/depthOfField.fragment";
  56241. /**
  56242. * BABYLON.JS Chromatic Aberration GLSL Shader
  56243. * Author: Olivier Guyot
  56244. * Separates very slightly R, G and B colors on the edges of the screen
  56245. * Inspired by Francois Tarlier & Martins Upitis
  56246. */
  56247. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56248. /**
  56249. * @ignore
  56250. * The chromatic aberration PostProcess id in the pipeline
  56251. */
  56252. LensChromaticAberrationEffect: string;
  56253. /**
  56254. * @ignore
  56255. * The highlights enhancing PostProcess id in the pipeline
  56256. */
  56257. HighlightsEnhancingEffect: string;
  56258. /**
  56259. * @ignore
  56260. * The depth-of-field PostProcess id in the pipeline
  56261. */
  56262. LensDepthOfFieldEffect: string;
  56263. private _scene;
  56264. private _depthTexture;
  56265. private _grainTexture;
  56266. private _chromaticAberrationPostProcess;
  56267. private _highlightsPostProcess;
  56268. private _depthOfFieldPostProcess;
  56269. private _edgeBlur;
  56270. private _grainAmount;
  56271. private _chromaticAberration;
  56272. private _distortion;
  56273. private _highlightsGain;
  56274. private _highlightsThreshold;
  56275. private _dofDistance;
  56276. private _dofAperture;
  56277. private _dofDarken;
  56278. private _dofPentagon;
  56279. private _blurNoise;
  56280. /**
  56281. * @constructor
  56282. *
  56283. * Effect parameters are as follow:
  56284. * {
  56285. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56286. * edge_blur: number; // from 0 to x (1 for realism)
  56287. * distortion: number; // from 0 to x (1 for realism)
  56288. * grain_amount: number; // from 0 to 1
  56289. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56290. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56291. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56292. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56293. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56294. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56295. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56296. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56297. * }
  56298. * Note: if an effect parameter is unset, effect is disabled
  56299. *
  56300. * @param name The rendering pipeline name
  56301. * @param parameters - An object containing all parameters (see above)
  56302. * @param scene The scene linked to this pipeline
  56303. * @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)
  56304. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56305. */
  56306. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56307. /**
  56308. * Get the class name
  56309. * @returns "LensRenderingPipeline"
  56310. */
  56311. getClassName(): string;
  56312. /**
  56313. * Gets associated scene
  56314. */
  56315. readonly scene: Scene;
  56316. /**
  56317. * Gets or sets the edge blur
  56318. */
  56319. edgeBlur: number;
  56320. /**
  56321. * Gets or sets the grain amount
  56322. */
  56323. grainAmount: number;
  56324. /**
  56325. * Gets or sets the chromatic aberration amount
  56326. */
  56327. chromaticAberration: number;
  56328. /**
  56329. * Gets or sets the depth of field aperture
  56330. */
  56331. dofAperture: number;
  56332. /**
  56333. * Gets or sets the edge distortion
  56334. */
  56335. edgeDistortion: number;
  56336. /**
  56337. * Gets or sets the depth of field distortion
  56338. */
  56339. dofDistortion: number;
  56340. /**
  56341. * Gets or sets the darken out of focus amount
  56342. */
  56343. darkenOutOfFocus: number;
  56344. /**
  56345. * Gets or sets a boolean indicating if blur noise is enabled
  56346. */
  56347. blurNoise: boolean;
  56348. /**
  56349. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56350. */
  56351. pentagonBokeh: boolean;
  56352. /**
  56353. * Gets or sets the highlight grain amount
  56354. */
  56355. highlightsGain: number;
  56356. /**
  56357. * Gets or sets the highlight threshold
  56358. */
  56359. highlightsThreshold: number;
  56360. /**
  56361. * Sets the amount of blur at the edges
  56362. * @param amount blur amount
  56363. */
  56364. setEdgeBlur(amount: number): void;
  56365. /**
  56366. * Sets edge blur to 0
  56367. */
  56368. disableEdgeBlur(): void;
  56369. /**
  56370. * Sets the amout of grain
  56371. * @param amount Amount of grain
  56372. */
  56373. setGrainAmount(amount: number): void;
  56374. /**
  56375. * Set grain amount to 0
  56376. */
  56377. disableGrain(): void;
  56378. /**
  56379. * Sets the chromatic aberration amount
  56380. * @param amount amount of chromatic aberration
  56381. */
  56382. setChromaticAberration(amount: number): void;
  56383. /**
  56384. * Sets chromatic aberration amount to 0
  56385. */
  56386. disableChromaticAberration(): void;
  56387. /**
  56388. * Sets the EdgeDistortion amount
  56389. * @param amount amount of EdgeDistortion
  56390. */
  56391. setEdgeDistortion(amount: number): void;
  56392. /**
  56393. * Sets edge distortion to 0
  56394. */
  56395. disableEdgeDistortion(): void;
  56396. /**
  56397. * Sets the FocusDistance amount
  56398. * @param amount amount of FocusDistance
  56399. */
  56400. setFocusDistance(amount: number): void;
  56401. /**
  56402. * Disables depth of field
  56403. */
  56404. disableDepthOfField(): void;
  56405. /**
  56406. * Sets the Aperture amount
  56407. * @param amount amount of Aperture
  56408. */
  56409. setAperture(amount: number): void;
  56410. /**
  56411. * Sets the DarkenOutOfFocus amount
  56412. * @param amount amount of DarkenOutOfFocus
  56413. */
  56414. setDarkenOutOfFocus(amount: number): void;
  56415. private _pentagonBokehIsEnabled;
  56416. /**
  56417. * Creates a pentagon bokeh effect
  56418. */
  56419. enablePentagonBokeh(): void;
  56420. /**
  56421. * Disables the pentagon bokeh effect
  56422. */
  56423. disablePentagonBokeh(): void;
  56424. /**
  56425. * Enables noise blur
  56426. */
  56427. enableNoiseBlur(): void;
  56428. /**
  56429. * Disables noise blur
  56430. */
  56431. disableNoiseBlur(): void;
  56432. /**
  56433. * Sets the HighlightsGain amount
  56434. * @param amount amount of HighlightsGain
  56435. */
  56436. setHighlightsGain(amount: number): void;
  56437. /**
  56438. * Sets the HighlightsThreshold amount
  56439. * @param amount amount of HighlightsThreshold
  56440. */
  56441. setHighlightsThreshold(amount: number): void;
  56442. /**
  56443. * Disables highlights
  56444. */
  56445. disableHighlights(): void;
  56446. /**
  56447. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56448. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56449. */
  56450. dispose(disableDepthRender?: boolean): void;
  56451. private _createChromaticAberrationPostProcess;
  56452. private _createHighlightsPostProcess;
  56453. private _createDepthOfFieldPostProcess;
  56454. private _createGrainTexture;
  56455. }
  56456. }
  56457. declare module "babylonjs/Shaders/ssao2.fragment" {
  56458. /** @hidden */
  56459. export var ssao2PixelShader: {
  56460. name: string;
  56461. shader: string;
  56462. };
  56463. }
  56464. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56465. /** @hidden */
  56466. export var ssaoCombinePixelShader: {
  56467. name: string;
  56468. shader: string;
  56469. };
  56470. }
  56471. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56472. import { Camera } from "babylonjs/Cameras/camera";
  56473. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56474. import { Scene } from "babylonjs/scene";
  56475. import "babylonjs/Shaders/ssao2.fragment";
  56476. import "babylonjs/Shaders/ssaoCombine.fragment";
  56477. /**
  56478. * Render pipeline to produce ssao effect
  56479. */
  56480. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56481. /**
  56482. * @ignore
  56483. * The PassPostProcess id in the pipeline that contains the original scene color
  56484. */
  56485. SSAOOriginalSceneColorEffect: string;
  56486. /**
  56487. * @ignore
  56488. * The SSAO PostProcess id in the pipeline
  56489. */
  56490. SSAORenderEffect: string;
  56491. /**
  56492. * @ignore
  56493. * The horizontal blur PostProcess id in the pipeline
  56494. */
  56495. SSAOBlurHRenderEffect: string;
  56496. /**
  56497. * @ignore
  56498. * The vertical blur PostProcess id in the pipeline
  56499. */
  56500. SSAOBlurVRenderEffect: string;
  56501. /**
  56502. * @ignore
  56503. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56504. */
  56505. SSAOCombineRenderEffect: string;
  56506. /**
  56507. * The output strength of the SSAO post-process. Default value is 1.0.
  56508. */
  56509. totalStrength: number;
  56510. /**
  56511. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56512. */
  56513. maxZ: number;
  56514. /**
  56515. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56516. */
  56517. minZAspect: number;
  56518. private _samples;
  56519. /**
  56520. * Number of samples used for the SSAO calculations. Default value is 8
  56521. */
  56522. samples: number;
  56523. private _textureSamples;
  56524. /**
  56525. * Number of samples to use for antialiasing
  56526. */
  56527. textureSamples: number;
  56528. /**
  56529. * Ratio object used for SSAO ratio and blur ratio
  56530. */
  56531. private _ratio;
  56532. /**
  56533. * Dynamically generated sphere sampler.
  56534. */
  56535. private _sampleSphere;
  56536. /**
  56537. * Blur filter offsets
  56538. */
  56539. private _samplerOffsets;
  56540. private _expensiveBlur;
  56541. /**
  56542. * If bilateral blur should be used
  56543. */
  56544. expensiveBlur: boolean;
  56545. /**
  56546. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56547. */
  56548. radius: number;
  56549. /**
  56550. * The base color of the SSAO post-process
  56551. * The final result is "base + ssao" between [0, 1]
  56552. */
  56553. base: number;
  56554. /**
  56555. * Support test.
  56556. */
  56557. static readonly IsSupported: boolean;
  56558. private _scene;
  56559. private _depthTexture;
  56560. private _normalTexture;
  56561. private _randomTexture;
  56562. private _originalColorPostProcess;
  56563. private _ssaoPostProcess;
  56564. private _blurHPostProcess;
  56565. private _blurVPostProcess;
  56566. private _ssaoCombinePostProcess;
  56567. private _firstUpdate;
  56568. /**
  56569. * Gets active scene
  56570. */
  56571. readonly scene: Scene;
  56572. /**
  56573. * @constructor
  56574. * @param name The rendering pipeline name
  56575. * @param scene The scene linked to this pipeline
  56576. * @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 }
  56577. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56578. */
  56579. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56580. /**
  56581. * Get the class name
  56582. * @returns "SSAO2RenderingPipeline"
  56583. */
  56584. getClassName(): string;
  56585. /**
  56586. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56587. */
  56588. dispose(disableGeometryBufferRenderer?: boolean): void;
  56589. private _createBlurPostProcess;
  56590. /** @hidden */
  56591. _rebuild(): void;
  56592. private _bits;
  56593. private _radicalInverse_VdC;
  56594. private _hammersley;
  56595. private _hemisphereSample_uniform;
  56596. private _generateHemisphere;
  56597. private _createSSAOPostProcess;
  56598. private _createSSAOCombinePostProcess;
  56599. private _createRandomTexture;
  56600. /**
  56601. * Serialize the rendering pipeline (Used when exporting)
  56602. * @returns the serialized object
  56603. */
  56604. serialize(): any;
  56605. /**
  56606. * Parse the serialized pipeline
  56607. * @param source Source pipeline.
  56608. * @param scene The scene to load the pipeline to.
  56609. * @param rootUrl The URL of the serialized pipeline.
  56610. * @returns An instantiated pipeline from the serialized object.
  56611. */
  56612. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56613. }
  56614. }
  56615. declare module "babylonjs/Shaders/ssao.fragment" {
  56616. /** @hidden */
  56617. export var ssaoPixelShader: {
  56618. name: string;
  56619. shader: string;
  56620. };
  56621. }
  56622. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56623. import { Camera } from "babylonjs/Cameras/camera";
  56624. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56625. import { Scene } from "babylonjs/scene";
  56626. import "babylonjs/Shaders/ssao.fragment";
  56627. import "babylonjs/Shaders/ssaoCombine.fragment";
  56628. /**
  56629. * Render pipeline to produce ssao effect
  56630. */
  56631. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56632. /**
  56633. * @ignore
  56634. * The PassPostProcess id in the pipeline that contains the original scene color
  56635. */
  56636. SSAOOriginalSceneColorEffect: string;
  56637. /**
  56638. * @ignore
  56639. * The SSAO PostProcess id in the pipeline
  56640. */
  56641. SSAORenderEffect: string;
  56642. /**
  56643. * @ignore
  56644. * The horizontal blur PostProcess id in the pipeline
  56645. */
  56646. SSAOBlurHRenderEffect: string;
  56647. /**
  56648. * @ignore
  56649. * The vertical blur PostProcess id in the pipeline
  56650. */
  56651. SSAOBlurVRenderEffect: string;
  56652. /**
  56653. * @ignore
  56654. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56655. */
  56656. SSAOCombineRenderEffect: string;
  56657. /**
  56658. * The output strength of the SSAO post-process. Default value is 1.0.
  56659. */
  56660. totalStrength: number;
  56661. /**
  56662. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56663. */
  56664. radius: number;
  56665. /**
  56666. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56667. * Must not be equal to fallOff and superior to fallOff.
  56668. * Default value is 0.0075
  56669. */
  56670. area: number;
  56671. /**
  56672. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56673. * Must not be equal to area and inferior to area.
  56674. * Default value is 0.000001
  56675. */
  56676. fallOff: number;
  56677. /**
  56678. * The base color of the SSAO post-process
  56679. * The final result is "base + ssao" between [0, 1]
  56680. */
  56681. base: number;
  56682. private _scene;
  56683. private _depthTexture;
  56684. private _randomTexture;
  56685. private _originalColorPostProcess;
  56686. private _ssaoPostProcess;
  56687. private _blurHPostProcess;
  56688. private _blurVPostProcess;
  56689. private _ssaoCombinePostProcess;
  56690. private _firstUpdate;
  56691. /**
  56692. * Gets active scene
  56693. */
  56694. readonly scene: Scene;
  56695. /**
  56696. * @constructor
  56697. * @param name - The rendering pipeline name
  56698. * @param scene - The scene linked to this pipeline
  56699. * @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 }
  56700. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56701. */
  56702. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56703. /**
  56704. * Get the class name
  56705. * @returns "SSAORenderingPipeline"
  56706. */
  56707. getClassName(): string;
  56708. /**
  56709. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56710. */
  56711. dispose(disableDepthRender?: boolean): void;
  56712. private _createBlurPostProcess;
  56713. /** @hidden */
  56714. _rebuild(): void;
  56715. private _createSSAOPostProcess;
  56716. private _createSSAOCombinePostProcess;
  56717. private _createRandomTexture;
  56718. }
  56719. }
  56720. declare module "babylonjs/Shaders/standard.fragment" {
  56721. /** @hidden */
  56722. export var standardPixelShader: {
  56723. name: string;
  56724. shader: string;
  56725. };
  56726. }
  56727. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56728. import { Nullable } from "babylonjs/types";
  56729. import { IAnimatable } from "babylonjs/Misc/tools";
  56730. import { Camera } from "babylonjs/Cameras/camera";
  56731. import { Texture } from "babylonjs/Materials/Textures/texture";
  56732. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56733. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56734. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56735. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56736. import { IDisposable } from "babylonjs/scene";
  56737. import { SpotLight } from "babylonjs/Lights/spotLight";
  56738. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56739. import { Scene } from "babylonjs/scene";
  56740. import { Animation } from "babylonjs/Animations/animation";
  56741. import "babylonjs/Shaders/standard.fragment";
  56742. /**
  56743. * Standard rendering pipeline
  56744. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56745. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56746. */
  56747. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56748. /**
  56749. * Public members
  56750. */
  56751. /**
  56752. * Post-process which contains the original scene color before the pipeline applies all the effects
  56753. */
  56754. originalPostProcess: Nullable<PostProcess>;
  56755. /**
  56756. * Post-process used to down scale an image x4
  56757. */
  56758. downSampleX4PostProcess: Nullable<PostProcess>;
  56759. /**
  56760. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56761. */
  56762. brightPassPostProcess: Nullable<PostProcess>;
  56763. /**
  56764. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56765. */
  56766. blurHPostProcesses: PostProcess[];
  56767. /**
  56768. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56769. */
  56770. blurVPostProcesses: PostProcess[];
  56771. /**
  56772. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56773. */
  56774. textureAdderPostProcess: Nullable<PostProcess>;
  56775. /**
  56776. * Post-process used to create volumetric lighting effect
  56777. */
  56778. volumetricLightPostProcess: Nullable<PostProcess>;
  56779. /**
  56780. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56781. */
  56782. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56783. /**
  56784. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56785. */
  56786. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56787. /**
  56788. * Post-process used to merge the volumetric light effect and the real scene color
  56789. */
  56790. volumetricLightMergePostProces: Nullable<PostProcess>;
  56791. /**
  56792. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56793. */
  56794. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56795. /**
  56796. * Base post-process used to calculate the average luminance of the final image for HDR
  56797. */
  56798. luminancePostProcess: Nullable<PostProcess>;
  56799. /**
  56800. * Post-processes used to create down sample post-processes in order to get
  56801. * the average luminance of the final image for HDR
  56802. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56803. */
  56804. luminanceDownSamplePostProcesses: PostProcess[];
  56805. /**
  56806. * Post-process used to create a HDR effect (light adaptation)
  56807. */
  56808. hdrPostProcess: Nullable<PostProcess>;
  56809. /**
  56810. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56811. */
  56812. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56813. /**
  56814. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56815. */
  56816. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56817. /**
  56818. * Post-process used to merge the final HDR post-process and the real scene color
  56819. */
  56820. hdrFinalPostProcess: Nullable<PostProcess>;
  56821. /**
  56822. * Post-process used to create a lens flare effect
  56823. */
  56824. lensFlarePostProcess: Nullable<PostProcess>;
  56825. /**
  56826. * Post-process that merges the result of the lens flare post-process and the real scene color
  56827. */
  56828. lensFlareComposePostProcess: Nullable<PostProcess>;
  56829. /**
  56830. * Post-process used to create a motion blur effect
  56831. */
  56832. motionBlurPostProcess: Nullable<PostProcess>;
  56833. /**
  56834. * Post-process used to create a depth of field effect
  56835. */
  56836. depthOfFieldPostProcess: Nullable<PostProcess>;
  56837. /**
  56838. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56839. */
  56840. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56841. /**
  56842. * Represents the brightness threshold in order to configure the illuminated surfaces
  56843. */
  56844. brightThreshold: number;
  56845. /**
  56846. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56847. */
  56848. blurWidth: number;
  56849. /**
  56850. * Sets if the blur for highlighted surfaces must be only horizontal
  56851. */
  56852. horizontalBlur: boolean;
  56853. /**
  56854. * Gets the overall exposure used by the pipeline
  56855. */
  56856. /**
  56857. * Sets the overall exposure used by the pipeline
  56858. */
  56859. exposure: number;
  56860. /**
  56861. * Texture used typically to simulate "dirty" on camera lens
  56862. */
  56863. lensTexture: Nullable<Texture>;
  56864. /**
  56865. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56866. */
  56867. volumetricLightCoefficient: number;
  56868. /**
  56869. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56870. */
  56871. volumetricLightPower: number;
  56872. /**
  56873. * Used the set the blur intensity to smooth the volumetric lights
  56874. */
  56875. volumetricLightBlurScale: number;
  56876. /**
  56877. * Light (spot or directional) used to generate the volumetric lights rays
  56878. * The source light must have a shadow generate so the pipeline can get its
  56879. * depth map
  56880. */
  56881. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56882. /**
  56883. * For eye adaptation, represents the minimum luminance the eye can see
  56884. */
  56885. hdrMinimumLuminance: number;
  56886. /**
  56887. * For eye adaptation, represents the decrease luminance speed
  56888. */
  56889. hdrDecreaseRate: number;
  56890. /**
  56891. * For eye adaptation, represents the increase luminance speed
  56892. */
  56893. hdrIncreaseRate: number;
  56894. /**
  56895. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56896. */
  56897. /**
  56898. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56899. */
  56900. hdrAutoExposure: boolean;
  56901. /**
  56902. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56903. */
  56904. lensColorTexture: Nullable<Texture>;
  56905. /**
  56906. * The overall strengh for the lens flare effect
  56907. */
  56908. lensFlareStrength: number;
  56909. /**
  56910. * Dispersion coefficient for lens flare ghosts
  56911. */
  56912. lensFlareGhostDispersal: number;
  56913. /**
  56914. * Main lens flare halo width
  56915. */
  56916. lensFlareHaloWidth: number;
  56917. /**
  56918. * Based on the lens distortion effect, defines how much the lens flare result
  56919. * is distorted
  56920. */
  56921. lensFlareDistortionStrength: number;
  56922. /**
  56923. * Lens star texture must be used to simulate rays on the flares and is available
  56924. * in the documentation
  56925. */
  56926. lensStarTexture: Nullable<Texture>;
  56927. /**
  56928. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56929. * flare effect by taking account of the dirt texture
  56930. */
  56931. lensFlareDirtTexture: Nullable<Texture>;
  56932. /**
  56933. * Represents the focal length for the depth of field effect
  56934. */
  56935. depthOfFieldDistance: number;
  56936. /**
  56937. * Represents the blur intensity for the blurred part of the depth of field effect
  56938. */
  56939. depthOfFieldBlurWidth: number;
  56940. /**
  56941. * For motion blur, defines how much the image is blurred by the movement
  56942. */
  56943. motionStrength: number;
  56944. /**
  56945. * List of animations for the pipeline (IAnimatable implementation)
  56946. */
  56947. animations: Animation[];
  56948. /**
  56949. * Private members
  56950. */
  56951. private _scene;
  56952. private _currentDepthOfFieldSource;
  56953. private _basePostProcess;
  56954. private _fixedExposure;
  56955. private _currentExposure;
  56956. private _hdrAutoExposure;
  56957. private _hdrCurrentLuminance;
  56958. private _floatTextureType;
  56959. private _ratio;
  56960. private _bloomEnabled;
  56961. private _depthOfFieldEnabled;
  56962. private _vlsEnabled;
  56963. private _lensFlareEnabled;
  56964. private _hdrEnabled;
  56965. private _motionBlurEnabled;
  56966. private _fxaaEnabled;
  56967. private _motionBlurSamples;
  56968. private _volumetricLightStepsCount;
  56969. private _samples;
  56970. /**
  56971. * @ignore
  56972. * Specifies if the bloom pipeline is enabled
  56973. */
  56974. BloomEnabled: boolean;
  56975. /**
  56976. * @ignore
  56977. * Specifies if the depth of field pipeline is enabed
  56978. */
  56979. DepthOfFieldEnabled: boolean;
  56980. /**
  56981. * @ignore
  56982. * Specifies if the lens flare pipeline is enabed
  56983. */
  56984. LensFlareEnabled: boolean;
  56985. /**
  56986. * @ignore
  56987. * Specifies if the HDR pipeline is enabled
  56988. */
  56989. HDREnabled: boolean;
  56990. /**
  56991. * @ignore
  56992. * Specifies if the volumetric lights scattering effect is enabled
  56993. */
  56994. VLSEnabled: boolean;
  56995. /**
  56996. * @ignore
  56997. * Specifies if the motion blur effect is enabled
  56998. */
  56999. MotionBlurEnabled: boolean;
  57000. /**
  57001. * Specifies if anti-aliasing is enabled
  57002. */
  57003. fxaaEnabled: boolean;
  57004. /**
  57005. * Specifies the number of steps used to calculate the volumetric lights
  57006. * Typically in interval [50, 200]
  57007. */
  57008. volumetricLightStepsCount: number;
  57009. /**
  57010. * Specifies the number of samples used for the motion blur effect
  57011. * Typically in interval [16, 64]
  57012. */
  57013. motionBlurSamples: number;
  57014. /**
  57015. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57016. */
  57017. samples: number;
  57018. /**
  57019. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57020. * @constructor
  57021. * @param name The rendering pipeline name
  57022. * @param scene The scene linked to this pipeline
  57023. * @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)
  57024. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57025. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57026. */
  57027. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57028. private _buildPipeline;
  57029. private _createDownSampleX4PostProcess;
  57030. private _createBrightPassPostProcess;
  57031. private _createBlurPostProcesses;
  57032. private _createTextureAdderPostProcess;
  57033. private _createVolumetricLightPostProcess;
  57034. private _createLuminancePostProcesses;
  57035. private _createHdrPostProcess;
  57036. private _createLensFlarePostProcess;
  57037. private _createDepthOfFieldPostProcess;
  57038. private _createMotionBlurPostProcess;
  57039. private _getDepthTexture;
  57040. private _disposePostProcesses;
  57041. /**
  57042. * Dispose of the pipeline and stop all post processes
  57043. */
  57044. dispose(): void;
  57045. /**
  57046. * Serialize the rendering pipeline (Used when exporting)
  57047. * @returns the serialized object
  57048. */
  57049. serialize(): any;
  57050. /**
  57051. * Parse the serialized pipeline
  57052. * @param source Source pipeline.
  57053. * @param scene The scene to load the pipeline to.
  57054. * @param rootUrl The URL of the serialized pipeline.
  57055. * @returns An instantiated pipeline from the serialized object.
  57056. */
  57057. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57058. /**
  57059. * Luminance steps
  57060. */
  57061. static LuminanceSteps: number;
  57062. }
  57063. }
  57064. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57065. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57066. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57067. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57068. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57069. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57070. }
  57071. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57072. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57073. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57074. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57075. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57076. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57077. }
  57078. declare module "babylonjs/Shaders/tonemap.fragment" {
  57079. /** @hidden */
  57080. export var tonemapPixelShader: {
  57081. name: string;
  57082. shader: string;
  57083. };
  57084. }
  57085. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57086. import { Camera } from "babylonjs/Cameras/camera";
  57087. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57088. import "babylonjs/Shaders/tonemap.fragment";
  57089. import { Engine } from "babylonjs/Engines/engine";
  57090. /** Defines operator used for tonemapping */
  57091. export enum TonemappingOperator {
  57092. /** Hable */
  57093. Hable = 0,
  57094. /** Reinhard */
  57095. Reinhard = 1,
  57096. /** HejiDawson */
  57097. HejiDawson = 2,
  57098. /** Photographic */
  57099. Photographic = 3
  57100. }
  57101. /**
  57102. * Defines a post process to apply tone mapping
  57103. */
  57104. export class TonemapPostProcess extends PostProcess {
  57105. private _operator;
  57106. /** Defines the required exposure adjustement */
  57107. exposureAdjustment: number;
  57108. /**
  57109. * Creates a new TonemapPostProcess
  57110. * @param name defines the name of the postprocess
  57111. * @param _operator defines the operator to use
  57112. * @param exposureAdjustment defines the required exposure adjustement
  57113. * @param camera defines the camera to use (can be null)
  57114. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57115. * @param engine defines the hosting engine (can be ignore if camera is set)
  57116. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57117. */
  57118. constructor(name: string, _operator: TonemappingOperator,
  57119. /** Defines the required exposure adjustement */
  57120. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57121. }
  57122. }
  57123. declare module "babylonjs/Shaders/depth.vertex" {
  57124. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57125. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57126. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57127. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57128. /** @hidden */
  57129. export var depthVertexShader: {
  57130. name: string;
  57131. shader: string;
  57132. };
  57133. }
  57134. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57135. /** @hidden */
  57136. export var volumetricLightScatteringPixelShader: {
  57137. name: string;
  57138. shader: string;
  57139. };
  57140. }
  57141. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57142. /** @hidden */
  57143. export var volumetricLightScatteringPassPixelShader: {
  57144. name: string;
  57145. shader: string;
  57146. };
  57147. }
  57148. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57149. import { Vector3 } from "babylonjs/Maths/math";
  57150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57151. import { Mesh } from "babylonjs/Meshes/mesh";
  57152. import { Camera } from "babylonjs/Cameras/camera";
  57153. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57154. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57155. import { Scene } from "babylonjs/scene";
  57156. import "babylonjs/Meshes/Builders/planeBuilder";
  57157. import "babylonjs/Shaders/depth.vertex";
  57158. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57159. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57160. import { Engine } from "babylonjs/Engines/engine";
  57161. /**
  57162. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57163. */
  57164. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57165. private _volumetricLightScatteringPass;
  57166. private _volumetricLightScatteringRTT;
  57167. private _viewPort;
  57168. private _screenCoordinates;
  57169. private _cachedDefines;
  57170. /**
  57171. * If not undefined, the mesh position is computed from the attached node position
  57172. */
  57173. attachedNode: {
  57174. position: Vector3;
  57175. };
  57176. /**
  57177. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57178. */
  57179. customMeshPosition: Vector3;
  57180. /**
  57181. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57182. */
  57183. useCustomMeshPosition: boolean;
  57184. /**
  57185. * If the post-process should inverse the light scattering direction
  57186. */
  57187. invert: boolean;
  57188. /**
  57189. * The internal mesh used by the post-process
  57190. */
  57191. mesh: Mesh;
  57192. /**
  57193. * @hidden
  57194. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57195. */
  57196. useDiffuseColor: boolean;
  57197. /**
  57198. * Array containing the excluded meshes not rendered in the internal pass
  57199. */
  57200. excludedMeshes: AbstractMesh[];
  57201. /**
  57202. * Controls the overall intensity of the post-process
  57203. */
  57204. exposure: number;
  57205. /**
  57206. * Dissipates each sample's contribution in range [0, 1]
  57207. */
  57208. decay: number;
  57209. /**
  57210. * Controls the overall intensity of each sample
  57211. */
  57212. weight: number;
  57213. /**
  57214. * Controls the density of each sample
  57215. */
  57216. density: number;
  57217. /**
  57218. * @constructor
  57219. * @param name The post-process name
  57220. * @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)
  57221. * @param camera The camera that the post-process will be attached to
  57222. * @param mesh The mesh used to create the light scattering
  57223. * @param samples The post-process quality, default 100
  57224. * @param samplingModeThe post-process filtering mode
  57225. * @param engine The babylon engine
  57226. * @param reusable If the post-process is reusable
  57227. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57228. */
  57229. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57230. /**
  57231. * Returns the string "VolumetricLightScatteringPostProcess"
  57232. * @returns "VolumetricLightScatteringPostProcess"
  57233. */
  57234. getClassName(): string;
  57235. private _isReady;
  57236. /**
  57237. * Sets the new light position for light scattering effect
  57238. * @param position The new custom light position
  57239. */
  57240. setCustomMeshPosition(position: Vector3): void;
  57241. /**
  57242. * Returns the light position for light scattering effect
  57243. * @return Vector3 The custom light position
  57244. */
  57245. getCustomMeshPosition(): Vector3;
  57246. /**
  57247. * Disposes the internal assets and detaches the post-process from the camera
  57248. */
  57249. dispose(camera: Camera): void;
  57250. /**
  57251. * Returns the render target texture used by the post-process
  57252. * @return the render target texture used by the post-process
  57253. */
  57254. getPass(): RenderTargetTexture;
  57255. private _meshExcluded;
  57256. private _createPass;
  57257. private _updateMeshScreenCoordinates;
  57258. /**
  57259. * Creates a default mesh for the Volumeric Light Scattering post-process
  57260. * @param name The mesh name
  57261. * @param scene The scene where to create the mesh
  57262. * @return the default mesh
  57263. */
  57264. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57265. }
  57266. }
  57267. declare module "babylonjs/PostProcesses/index" {
  57268. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57269. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57270. export * from "babylonjs/PostProcesses/bloomEffect";
  57271. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57272. export * from "babylonjs/PostProcesses/blurPostProcess";
  57273. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57274. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57275. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57276. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57277. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57278. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57279. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57280. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57281. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57282. export * from "babylonjs/PostProcesses/filterPostProcess";
  57283. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57284. export * from "babylonjs/PostProcesses/grainPostProcess";
  57285. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57286. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57287. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57288. export * from "babylonjs/PostProcesses/passPostProcess";
  57289. export * from "babylonjs/PostProcesses/postProcess";
  57290. export * from "babylonjs/PostProcesses/postProcessManager";
  57291. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57292. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57293. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57294. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57295. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57296. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57297. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57298. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57299. }
  57300. declare module "babylonjs/Probes/index" {
  57301. export * from "babylonjs/Probes/reflectionProbe";
  57302. }
  57303. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57304. import { Scene } from "babylonjs/scene";
  57305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57306. import { Color3 } from "babylonjs/Maths/math";
  57307. import { SmartArray } from "babylonjs/Misc/smartArray";
  57308. import { ISceneComponent } from "babylonjs/sceneComponent";
  57309. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57310. import "babylonjs/Meshes/Builders/boxBuilder";
  57311. import "babylonjs/Shaders/color.fragment";
  57312. import "babylonjs/Shaders/color.vertex";
  57313. module "babylonjs/scene" {
  57314. interface Scene {
  57315. /** @hidden (Backing field) */
  57316. _boundingBoxRenderer: BoundingBoxRenderer;
  57317. /** @hidden (Backing field) */
  57318. _forceShowBoundingBoxes: boolean;
  57319. /**
  57320. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57321. */
  57322. forceShowBoundingBoxes: boolean;
  57323. /**
  57324. * Gets the bounding box renderer associated with the scene
  57325. * @returns a BoundingBoxRenderer
  57326. */
  57327. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57328. }
  57329. }
  57330. module "babylonjs/Meshes/abstractMesh" {
  57331. interface AbstractMesh {
  57332. /** @hidden (Backing field) */
  57333. _showBoundingBox: boolean;
  57334. /**
  57335. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57336. */
  57337. showBoundingBox: boolean;
  57338. }
  57339. }
  57340. /**
  57341. * Component responsible of rendering the bounding box of the meshes in a scene.
  57342. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57343. */
  57344. export class BoundingBoxRenderer implements ISceneComponent {
  57345. /**
  57346. * The component name helpfull to identify the component in the list of scene components.
  57347. */
  57348. readonly name: string;
  57349. /**
  57350. * The scene the component belongs to.
  57351. */
  57352. scene: Scene;
  57353. /**
  57354. * Color of the bounding box lines placed in front of an object
  57355. */
  57356. frontColor: Color3;
  57357. /**
  57358. * Color of the bounding box lines placed behind an object
  57359. */
  57360. backColor: Color3;
  57361. /**
  57362. * Defines if the renderer should show the back lines or not
  57363. */
  57364. showBackLines: boolean;
  57365. /**
  57366. * @hidden
  57367. */
  57368. renderList: SmartArray<BoundingBox>;
  57369. private _colorShader;
  57370. private _vertexBuffers;
  57371. private _indexBuffer;
  57372. /**
  57373. * Instantiates a new bounding box renderer in a scene.
  57374. * @param scene the scene the renderer renders in
  57375. */
  57376. constructor(scene: Scene);
  57377. /**
  57378. * Registers the component in a given scene
  57379. */
  57380. register(): void;
  57381. private _evaluateSubMesh;
  57382. private _activeMesh;
  57383. private _prepareRessources;
  57384. private _createIndexBuffer;
  57385. /**
  57386. * Rebuilds the elements related to this component in case of
  57387. * context lost for instance.
  57388. */
  57389. rebuild(): void;
  57390. /**
  57391. * @hidden
  57392. */
  57393. reset(): void;
  57394. /**
  57395. * Render the bounding boxes of a specific rendering group
  57396. * @param renderingGroupId defines the rendering group to render
  57397. */
  57398. render(renderingGroupId: number): void;
  57399. /**
  57400. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57401. * @param mesh Define the mesh to render the occlusion bounding box for
  57402. */
  57403. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57404. /**
  57405. * Dispose and release the resources attached to this renderer.
  57406. */
  57407. dispose(): void;
  57408. }
  57409. }
  57410. declare module "babylonjs/Shaders/depth.fragment" {
  57411. /** @hidden */
  57412. export var depthPixelShader: {
  57413. name: string;
  57414. shader: string;
  57415. };
  57416. }
  57417. declare module "babylonjs/Rendering/depthRenderer" {
  57418. import { Nullable } from "babylonjs/types";
  57419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57420. import { Scene } from "babylonjs/scene";
  57421. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57422. import { Camera } from "babylonjs/Cameras/camera";
  57423. import "babylonjs/Shaders/depth.fragment";
  57424. import "babylonjs/Shaders/depth.vertex";
  57425. /**
  57426. * This represents a depth renderer in Babylon.
  57427. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57428. */
  57429. export class DepthRenderer {
  57430. private _scene;
  57431. private _depthMap;
  57432. private _effect;
  57433. private _cachedDefines;
  57434. private _camera;
  57435. /**
  57436. * Specifiess that the depth renderer will only be used within
  57437. * the camera it is created for.
  57438. * This can help forcing its rendering during the camera processing.
  57439. */
  57440. useOnlyInActiveCamera: boolean;
  57441. /** @hidden */
  57442. static _SceneComponentInitialization: (scene: Scene) => void;
  57443. /**
  57444. * Instantiates a depth renderer
  57445. * @param scene The scene the renderer belongs to
  57446. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57447. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57448. */
  57449. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57450. /**
  57451. * Creates the depth rendering effect and checks if the effect is ready.
  57452. * @param subMesh The submesh to be used to render the depth map of
  57453. * @param useInstances If multiple world instances should be used
  57454. * @returns if the depth renderer is ready to render the depth map
  57455. */
  57456. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57457. /**
  57458. * Gets the texture which the depth map will be written to.
  57459. * @returns The depth map texture
  57460. */
  57461. getDepthMap(): RenderTargetTexture;
  57462. /**
  57463. * Disposes of the depth renderer.
  57464. */
  57465. dispose(): void;
  57466. }
  57467. }
  57468. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57469. import { Nullable } from "babylonjs/types";
  57470. import { Scene } from "babylonjs/scene";
  57471. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57472. import { Camera } from "babylonjs/Cameras/camera";
  57473. import { ISceneComponent } from "babylonjs/sceneComponent";
  57474. module "babylonjs/scene" {
  57475. interface Scene {
  57476. /** @hidden (Backing field) */
  57477. _depthRenderer: {
  57478. [id: string]: DepthRenderer;
  57479. };
  57480. /**
  57481. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57482. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57483. * @returns the created depth renderer
  57484. */
  57485. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57486. /**
  57487. * Disables a depth renderer for a given camera
  57488. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57489. */
  57490. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57491. }
  57492. }
  57493. /**
  57494. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57495. * in several rendering techniques.
  57496. */
  57497. export class DepthRendererSceneComponent implements ISceneComponent {
  57498. /**
  57499. * The component name helpfull to identify the component in the list of scene components.
  57500. */
  57501. readonly name: string;
  57502. /**
  57503. * The scene the component belongs to.
  57504. */
  57505. scene: Scene;
  57506. /**
  57507. * Creates a new instance of the component for the given scene
  57508. * @param scene Defines the scene to register the component in
  57509. */
  57510. constructor(scene: Scene);
  57511. /**
  57512. * Registers the component in a given scene
  57513. */
  57514. register(): void;
  57515. /**
  57516. * Rebuilds the elements related to this component in case of
  57517. * context lost for instance.
  57518. */
  57519. rebuild(): void;
  57520. /**
  57521. * Disposes the component and the associated ressources
  57522. */
  57523. dispose(): void;
  57524. private _gatherRenderTargets;
  57525. private _gatherActiveCameraRenderTargets;
  57526. }
  57527. }
  57528. declare module "babylonjs/Shaders/outline.fragment" {
  57529. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57530. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57531. /** @hidden */
  57532. export var outlinePixelShader: {
  57533. name: string;
  57534. shader: string;
  57535. };
  57536. }
  57537. declare module "babylonjs/Shaders/outline.vertex" {
  57538. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57539. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57540. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57541. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57542. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57543. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57544. /** @hidden */
  57545. export var outlineVertexShader: {
  57546. name: string;
  57547. shader: string;
  57548. };
  57549. }
  57550. declare module "babylonjs/Rendering/outlineRenderer" {
  57551. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57552. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57553. import { Scene } from "babylonjs/scene";
  57554. import { ISceneComponent } from "babylonjs/sceneComponent";
  57555. import "babylonjs/Shaders/outline.fragment";
  57556. import "babylonjs/Shaders/outline.vertex";
  57557. module "babylonjs/scene" {
  57558. interface Scene {
  57559. /** @hidden */
  57560. _outlineRenderer: OutlineRenderer;
  57561. /**
  57562. * Gets the outline renderer associated with the scene
  57563. * @returns a OutlineRenderer
  57564. */
  57565. getOutlineRenderer(): OutlineRenderer;
  57566. }
  57567. }
  57568. module "babylonjs/Meshes/abstractMesh" {
  57569. interface AbstractMesh {
  57570. /** @hidden (Backing field) */
  57571. _renderOutline: boolean;
  57572. /**
  57573. * Gets or sets a boolean indicating if the outline must be rendered as well
  57574. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57575. */
  57576. renderOutline: boolean;
  57577. /** @hidden (Backing field) */
  57578. _renderOverlay: boolean;
  57579. /**
  57580. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57581. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57582. */
  57583. renderOverlay: boolean;
  57584. }
  57585. }
  57586. /**
  57587. * This class is responsible to draw bothe outline/overlay of meshes.
  57588. * It should not be used directly but through the available method on mesh.
  57589. */
  57590. export class OutlineRenderer implements ISceneComponent {
  57591. /**
  57592. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57593. */
  57594. private static _StencilReference;
  57595. /**
  57596. * The name of the component. Each component must have a unique name.
  57597. */
  57598. name: string;
  57599. /**
  57600. * The scene the component belongs to.
  57601. */
  57602. scene: Scene;
  57603. /**
  57604. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57605. */
  57606. zOffset: number;
  57607. private _engine;
  57608. private _effect;
  57609. private _cachedDefines;
  57610. private _savedDepthWrite;
  57611. /**
  57612. * Instantiates a new outline renderer. (There could be only one per scene).
  57613. * @param scene Defines the scene it belongs to
  57614. */
  57615. constructor(scene: Scene);
  57616. /**
  57617. * Register the component to one instance of a scene.
  57618. */
  57619. register(): void;
  57620. /**
  57621. * Rebuilds the elements related to this component in case of
  57622. * context lost for instance.
  57623. */
  57624. rebuild(): void;
  57625. /**
  57626. * Disposes the component and the associated ressources.
  57627. */
  57628. dispose(): void;
  57629. /**
  57630. * Renders the outline in the canvas.
  57631. * @param subMesh Defines the sumesh to render
  57632. * @param batch Defines the batch of meshes in case of instances
  57633. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57634. */
  57635. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57636. /**
  57637. * Returns whether or not the outline renderer is ready for a given submesh.
  57638. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57639. * @param subMesh Defines the submesh to check readyness for
  57640. * @param useInstances Defines wheter wee are trying to render instances or not
  57641. * @returns true if ready otherwise false
  57642. */
  57643. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57644. private _beforeRenderingMesh;
  57645. private _afterRenderingMesh;
  57646. }
  57647. }
  57648. declare module "babylonjs/Rendering/index" {
  57649. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57650. export * from "babylonjs/Rendering/depthRenderer";
  57651. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57652. export * from "babylonjs/Rendering/edgesRenderer";
  57653. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57654. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57655. export * from "babylonjs/Rendering/outlineRenderer";
  57656. export * from "babylonjs/Rendering/renderingGroup";
  57657. export * from "babylonjs/Rendering/renderingManager";
  57658. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57659. }
  57660. declare module "babylonjs/Sprites/index" {
  57661. export * from "babylonjs/Sprites/sprite";
  57662. export * from "babylonjs/Sprites/spriteManager";
  57663. export * from "babylonjs/Sprites/spriteSceneComponent";
  57664. }
  57665. declare module "babylonjs/Misc/assetsManager" {
  57666. import { Scene } from "babylonjs/scene";
  57667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57669. import { Skeleton } from "babylonjs/Bones/skeleton";
  57670. import { Observable } from "babylonjs/Misc/observable";
  57671. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57672. import { Texture } from "babylonjs/Materials/Textures/texture";
  57673. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57674. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57675. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57676. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57677. /**
  57678. * Defines the list of states available for a task inside a AssetsManager
  57679. */
  57680. export enum AssetTaskState {
  57681. /**
  57682. * Initialization
  57683. */
  57684. INIT = 0,
  57685. /**
  57686. * Running
  57687. */
  57688. RUNNING = 1,
  57689. /**
  57690. * Done
  57691. */
  57692. DONE = 2,
  57693. /**
  57694. * Error
  57695. */
  57696. ERROR = 3
  57697. }
  57698. /**
  57699. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57700. */
  57701. export abstract class AbstractAssetTask {
  57702. /**
  57703. * Task name
  57704. */ name: string;
  57705. /**
  57706. * Callback called when the task is successful
  57707. */
  57708. onSuccess: (task: any) => void;
  57709. /**
  57710. * Callback called when the task is not successful
  57711. */
  57712. onError: (task: any, message?: string, exception?: any) => void;
  57713. /**
  57714. * Creates a new AssetsManager
  57715. * @param name defines the name of the task
  57716. */
  57717. constructor(
  57718. /**
  57719. * Task name
  57720. */ name: string);
  57721. private _isCompleted;
  57722. private _taskState;
  57723. private _errorObject;
  57724. /**
  57725. * Get if the task is completed
  57726. */
  57727. readonly isCompleted: boolean;
  57728. /**
  57729. * Gets the current state of the task
  57730. */
  57731. readonly taskState: AssetTaskState;
  57732. /**
  57733. * Gets the current error object (if task is in error)
  57734. */
  57735. readonly errorObject: {
  57736. message?: string;
  57737. exception?: any;
  57738. };
  57739. /**
  57740. * Internal only
  57741. * @hidden
  57742. */
  57743. _setErrorObject(message?: string, exception?: any): void;
  57744. /**
  57745. * Execute the current task
  57746. * @param scene defines the scene where you want your assets to be loaded
  57747. * @param onSuccess is a callback called when the task is successfully executed
  57748. * @param onError is a callback called if an error occurs
  57749. */
  57750. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57751. /**
  57752. * Execute the current task
  57753. * @param scene defines the scene where you want your assets to be loaded
  57754. * @param onSuccess is a callback called when the task is successfully executed
  57755. * @param onError is a callback called if an error occurs
  57756. */
  57757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57758. /**
  57759. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57760. * This can be used with failed tasks that have the reason for failure fixed.
  57761. */
  57762. reset(): void;
  57763. private onErrorCallback;
  57764. private onDoneCallback;
  57765. }
  57766. /**
  57767. * Define the interface used by progress events raised during assets loading
  57768. */
  57769. export interface IAssetsProgressEvent {
  57770. /**
  57771. * Defines the number of remaining tasks to process
  57772. */
  57773. remainingCount: number;
  57774. /**
  57775. * Defines the total number of tasks
  57776. */
  57777. totalCount: number;
  57778. /**
  57779. * Defines the task that was just processed
  57780. */
  57781. task: AbstractAssetTask;
  57782. }
  57783. /**
  57784. * Class used to share progress information about assets loading
  57785. */
  57786. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57787. /**
  57788. * Defines the number of remaining tasks to process
  57789. */
  57790. remainingCount: number;
  57791. /**
  57792. * Defines the total number of tasks
  57793. */
  57794. totalCount: number;
  57795. /**
  57796. * Defines the task that was just processed
  57797. */
  57798. task: AbstractAssetTask;
  57799. /**
  57800. * Creates a AssetsProgressEvent
  57801. * @param remainingCount defines the number of remaining tasks to process
  57802. * @param totalCount defines the total number of tasks
  57803. * @param task defines the task that was just processed
  57804. */
  57805. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57806. }
  57807. /**
  57808. * Define a task used by AssetsManager to load meshes
  57809. */
  57810. export class MeshAssetTask extends AbstractAssetTask {
  57811. /**
  57812. * Defines the name of the task
  57813. */
  57814. name: string;
  57815. /**
  57816. * Defines the list of mesh's names you want to load
  57817. */
  57818. meshesNames: any;
  57819. /**
  57820. * Defines the root url to use as a base to load your meshes and associated resources
  57821. */
  57822. rootUrl: string;
  57823. /**
  57824. * Defines the filename of the scene to load from
  57825. */
  57826. sceneFilename: string;
  57827. /**
  57828. * Gets the list of loaded meshes
  57829. */
  57830. loadedMeshes: Array<AbstractMesh>;
  57831. /**
  57832. * Gets the list of loaded particle systems
  57833. */
  57834. loadedParticleSystems: Array<IParticleSystem>;
  57835. /**
  57836. * Gets the list of loaded skeletons
  57837. */
  57838. loadedSkeletons: Array<Skeleton>;
  57839. /**
  57840. * Gets the list of loaded animation groups
  57841. */
  57842. loadedAnimationGroups: Array<AnimationGroup>;
  57843. /**
  57844. * Callback called when the task is successful
  57845. */
  57846. onSuccess: (task: MeshAssetTask) => void;
  57847. /**
  57848. * Callback called when the task is successful
  57849. */
  57850. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57851. /**
  57852. * Creates a new MeshAssetTask
  57853. * @param name defines the name of the task
  57854. * @param meshesNames defines the list of mesh's names you want to load
  57855. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57856. * @param sceneFilename defines the filename of the scene to load from
  57857. */
  57858. constructor(
  57859. /**
  57860. * Defines the name of the task
  57861. */
  57862. name: string,
  57863. /**
  57864. * Defines the list of mesh's names you want to load
  57865. */
  57866. meshesNames: any,
  57867. /**
  57868. * Defines the root url to use as a base to load your meshes and associated resources
  57869. */
  57870. rootUrl: string,
  57871. /**
  57872. * Defines the filename of the scene to load from
  57873. */
  57874. sceneFilename: string);
  57875. /**
  57876. * Execute the current task
  57877. * @param scene defines the scene where you want your assets to be loaded
  57878. * @param onSuccess is a callback called when the task is successfully executed
  57879. * @param onError is a callback called if an error occurs
  57880. */
  57881. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57882. }
  57883. /**
  57884. * Define a task used by AssetsManager to load text content
  57885. */
  57886. export class TextFileAssetTask extends AbstractAssetTask {
  57887. /**
  57888. * Defines the name of the task
  57889. */
  57890. name: string;
  57891. /**
  57892. * Defines the location of the file to load
  57893. */
  57894. url: string;
  57895. /**
  57896. * Gets the loaded text string
  57897. */
  57898. text: string;
  57899. /**
  57900. * Callback called when the task is successful
  57901. */
  57902. onSuccess: (task: TextFileAssetTask) => void;
  57903. /**
  57904. * Callback called when the task is successful
  57905. */
  57906. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57907. /**
  57908. * Creates a new TextFileAssetTask object
  57909. * @param name defines the name of the task
  57910. * @param url defines the location of the file to load
  57911. */
  57912. constructor(
  57913. /**
  57914. * Defines the name of the task
  57915. */
  57916. name: string,
  57917. /**
  57918. * Defines the location of the file to load
  57919. */
  57920. url: string);
  57921. /**
  57922. * Execute the current task
  57923. * @param scene defines the scene where you want your assets to be loaded
  57924. * @param onSuccess is a callback called when the task is successfully executed
  57925. * @param onError is a callback called if an error occurs
  57926. */
  57927. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57928. }
  57929. /**
  57930. * Define a task used by AssetsManager to load binary data
  57931. */
  57932. export class BinaryFileAssetTask extends AbstractAssetTask {
  57933. /**
  57934. * Defines the name of the task
  57935. */
  57936. name: string;
  57937. /**
  57938. * Defines the location of the file to load
  57939. */
  57940. url: string;
  57941. /**
  57942. * Gets the lodaded data (as an array buffer)
  57943. */
  57944. data: ArrayBuffer;
  57945. /**
  57946. * Callback called when the task is successful
  57947. */
  57948. onSuccess: (task: BinaryFileAssetTask) => void;
  57949. /**
  57950. * Callback called when the task is successful
  57951. */
  57952. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57953. /**
  57954. * Creates a new BinaryFileAssetTask object
  57955. * @param name defines the name of the new task
  57956. * @param url defines the location of the file to load
  57957. */
  57958. constructor(
  57959. /**
  57960. * Defines the name of the task
  57961. */
  57962. name: string,
  57963. /**
  57964. * Defines the location of the file to load
  57965. */
  57966. url: string);
  57967. /**
  57968. * Execute the current task
  57969. * @param scene defines the scene where you want your assets to be loaded
  57970. * @param onSuccess is a callback called when the task is successfully executed
  57971. * @param onError is a callback called if an error occurs
  57972. */
  57973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57974. }
  57975. /**
  57976. * Define a task used by AssetsManager to load images
  57977. */
  57978. export class ImageAssetTask extends AbstractAssetTask {
  57979. /**
  57980. * Defines the name of the task
  57981. */
  57982. name: string;
  57983. /**
  57984. * Defines the location of the image to load
  57985. */
  57986. url: string;
  57987. /**
  57988. * Gets the loaded images
  57989. */
  57990. image: HTMLImageElement;
  57991. /**
  57992. * Callback called when the task is successful
  57993. */
  57994. onSuccess: (task: ImageAssetTask) => void;
  57995. /**
  57996. * Callback called when the task is successful
  57997. */
  57998. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57999. /**
  58000. * Creates a new ImageAssetTask
  58001. * @param name defines the name of the task
  58002. * @param url defines the location of the image to load
  58003. */
  58004. constructor(
  58005. /**
  58006. * Defines the name of the task
  58007. */
  58008. name: string,
  58009. /**
  58010. * Defines the location of the image to load
  58011. */
  58012. url: string);
  58013. /**
  58014. * Execute the current task
  58015. * @param scene defines the scene where you want your assets to be loaded
  58016. * @param onSuccess is a callback called when the task is successfully executed
  58017. * @param onError is a callback called if an error occurs
  58018. */
  58019. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58020. }
  58021. /**
  58022. * Defines the interface used by texture loading tasks
  58023. */
  58024. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58025. /**
  58026. * Gets the loaded texture
  58027. */
  58028. texture: TEX;
  58029. }
  58030. /**
  58031. * Define a task used by AssetsManager to load 2D textures
  58032. */
  58033. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58034. /**
  58035. * Defines the name of the task
  58036. */
  58037. name: string;
  58038. /**
  58039. * Defines the location of the file to load
  58040. */
  58041. url: string;
  58042. /**
  58043. * Defines if mipmap should not be generated (default is false)
  58044. */
  58045. noMipmap?: boolean | undefined;
  58046. /**
  58047. * Defines if texture must be inverted on Y axis (default is false)
  58048. */
  58049. invertY?: boolean | undefined;
  58050. /**
  58051. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58052. */
  58053. samplingMode: number;
  58054. /**
  58055. * Gets the loaded texture
  58056. */
  58057. texture: Texture;
  58058. /**
  58059. * Callback called when the task is successful
  58060. */
  58061. onSuccess: (task: TextureAssetTask) => void;
  58062. /**
  58063. * Callback called when the task is successful
  58064. */
  58065. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58066. /**
  58067. * Creates a new TextureAssetTask object
  58068. * @param name defines the name of the task
  58069. * @param url defines the location of the file to load
  58070. * @param noMipmap defines if mipmap should not be generated (default is false)
  58071. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58072. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58073. */
  58074. constructor(
  58075. /**
  58076. * Defines the name of the task
  58077. */
  58078. name: string,
  58079. /**
  58080. * Defines the location of the file to load
  58081. */
  58082. url: string,
  58083. /**
  58084. * Defines if mipmap should not be generated (default is false)
  58085. */
  58086. noMipmap?: boolean | undefined,
  58087. /**
  58088. * Defines if texture must be inverted on Y axis (default is false)
  58089. */
  58090. invertY?: boolean | undefined,
  58091. /**
  58092. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58093. */
  58094. samplingMode?: number);
  58095. /**
  58096. * Execute the current task
  58097. * @param scene defines the scene where you want your assets to be loaded
  58098. * @param onSuccess is a callback called when the task is successfully executed
  58099. * @param onError is a callback called if an error occurs
  58100. */
  58101. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58102. }
  58103. /**
  58104. * Define a task used by AssetsManager to load cube textures
  58105. */
  58106. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58107. /**
  58108. * Defines the name of the task
  58109. */
  58110. name: string;
  58111. /**
  58112. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58113. */
  58114. url: string;
  58115. /**
  58116. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58117. */
  58118. extensions?: string[] | undefined;
  58119. /**
  58120. * Defines if mipmaps should not be generated (default is false)
  58121. */
  58122. noMipmap?: boolean | undefined;
  58123. /**
  58124. * Defines the explicit list of files (undefined by default)
  58125. */
  58126. files?: string[] | undefined;
  58127. /**
  58128. * Gets the loaded texture
  58129. */
  58130. texture: CubeTexture;
  58131. /**
  58132. * Callback called when the task is successful
  58133. */
  58134. onSuccess: (task: CubeTextureAssetTask) => void;
  58135. /**
  58136. * Callback called when the task is successful
  58137. */
  58138. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58139. /**
  58140. * Creates a new CubeTextureAssetTask
  58141. * @param name defines the name of the task
  58142. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58143. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58144. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58145. * @param files defines the explicit list of files (undefined by default)
  58146. */
  58147. constructor(
  58148. /**
  58149. * Defines the name of the task
  58150. */
  58151. name: string,
  58152. /**
  58153. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58154. */
  58155. url: string,
  58156. /**
  58157. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58158. */
  58159. extensions?: string[] | undefined,
  58160. /**
  58161. * Defines if mipmaps should not be generated (default is false)
  58162. */
  58163. noMipmap?: boolean | undefined,
  58164. /**
  58165. * Defines the explicit list of files (undefined by default)
  58166. */
  58167. files?: string[] | undefined);
  58168. /**
  58169. * Execute the current task
  58170. * @param scene defines the scene where you want your assets to be loaded
  58171. * @param onSuccess is a callback called when the task is successfully executed
  58172. * @param onError is a callback called if an error occurs
  58173. */
  58174. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58175. }
  58176. /**
  58177. * Define a task used by AssetsManager to load HDR cube textures
  58178. */
  58179. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58180. /**
  58181. * Defines the name of the task
  58182. */
  58183. name: string;
  58184. /**
  58185. * Defines the location of the file to load
  58186. */
  58187. url: string;
  58188. /**
  58189. * Defines the desired size (the more it increases the longer the generation will be)
  58190. */
  58191. size: number;
  58192. /**
  58193. * Defines if mipmaps should not be generated (default is false)
  58194. */
  58195. noMipmap: boolean;
  58196. /**
  58197. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58198. */
  58199. generateHarmonics: boolean;
  58200. /**
  58201. * 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)
  58202. */
  58203. gammaSpace: boolean;
  58204. /**
  58205. * Internal Use Only
  58206. */
  58207. reserved: boolean;
  58208. /**
  58209. * Gets the loaded texture
  58210. */
  58211. texture: HDRCubeTexture;
  58212. /**
  58213. * Callback called when the task is successful
  58214. */
  58215. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58216. /**
  58217. * Callback called when the task is successful
  58218. */
  58219. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58220. /**
  58221. * Creates a new HDRCubeTextureAssetTask object
  58222. * @param name defines the name of the task
  58223. * @param url defines the location of the file to load
  58224. * @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.
  58225. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58226. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58227. * @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)
  58228. * @param reserved Internal use only
  58229. */
  58230. constructor(
  58231. /**
  58232. * Defines the name of the task
  58233. */
  58234. name: string,
  58235. /**
  58236. * Defines the location of the file to load
  58237. */
  58238. url: string,
  58239. /**
  58240. * Defines the desired size (the more it increases the longer the generation will be)
  58241. */
  58242. size: number,
  58243. /**
  58244. * Defines if mipmaps should not be generated (default is false)
  58245. */
  58246. noMipmap?: boolean,
  58247. /**
  58248. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58249. */
  58250. generateHarmonics?: boolean,
  58251. /**
  58252. * 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)
  58253. */
  58254. gammaSpace?: boolean,
  58255. /**
  58256. * Internal Use Only
  58257. */
  58258. reserved?: boolean);
  58259. /**
  58260. * Execute the current task
  58261. * @param scene defines the scene where you want your assets to be loaded
  58262. * @param onSuccess is a callback called when the task is successfully executed
  58263. * @param onError is a callback called if an error occurs
  58264. */
  58265. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58266. }
  58267. /**
  58268. * Define a task used by AssetsManager to load Equirectangular cube textures
  58269. */
  58270. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58271. /**
  58272. * Defines the name of the task
  58273. */
  58274. name: string;
  58275. /**
  58276. * Defines the location of the file to load
  58277. */
  58278. url: string;
  58279. /**
  58280. * Defines the desired size (the more it increases the longer the generation will be)
  58281. */
  58282. size: number;
  58283. /**
  58284. * Defines if mipmaps should not be generated (default is false)
  58285. */
  58286. noMipmap: boolean;
  58287. /**
  58288. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58289. * but the standard material would require them in Gamma space) (default is true)
  58290. */
  58291. gammaSpace: boolean;
  58292. /**
  58293. * Gets the loaded texture
  58294. */
  58295. texture: EquiRectangularCubeTexture;
  58296. /**
  58297. * Callback called when the task is successful
  58298. */
  58299. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58300. /**
  58301. * Callback called when the task is successful
  58302. */
  58303. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58304. /**
  58305. * Creates a new EquiRectangularCubeTextureAssetTask object
  58306. * @param name defines the name of the task
  58307. * @param url defines the location of the file to load
  58308. * @param size defines the desired size (the more it increases the longer the generation will be)
  58309. * If the size is omitted this implies you are using a preprocessed cubemap.
  58310. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58311. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58312. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58313. * (default is true)
  58314. */
  58315. constructor(
  58316. /**
  58317. * Defines the name of the task
  58318. */
  58319. name: string,
  58320. /**
  58321. * Defines the location of the file to load
  58322. */
  58323. url: string,
  58324. /**
  58325. * Defines the desired size (the more it increases the longer the generation will be)
  58326. */
  58327. size: number,
  58328. /**
  58329. * Defines if mipmaps should not be generated (default is false)
  58330. */
  58331. noMipmap?: boolean,
  58332. /**
  58333. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58334. * but the standard material would require them in Gamma space) (default is true)
  58335. */
  58336. gammaSpace?: boolean);
  58337. /**
  58338. * Execute the current task
  58339. * @param scene defines the scene where you want your assets to be loaded
  58340. * @param onSuccess is a callback called when the task is successfully executed
  58341. * @param onError is a callback called if an error occurs
  58342. */
  58343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58344. }
  58345. /**
  58346. * This class can be used to easily import assets into a scene
  58347. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58348. */
  58349. export class AssetsManager {
  58350. private _scene;
  58351. private _isLoading;
  58352. protected _tasks: AbstractAssetTask[];
  58353. protected _waitingTasksCount: number;
  58354. protected _totalTasksCount: number;
  58355. /**
  58356. * Callback called when all tasks are processed
  58357. */
  58358. onFinish: (tasks: AbstractAssetTask[]) => void;
  58359. /**
  58360. * Callback called when a task is successful
  58361. */
  58362. onTaskSuccess: (task: AbstractAssetTask) => void;
  58363. /**
  58364. * Callback called when a task had an error
  58365. */
  58366. onTaskError: (task: AbstractAssetTask) => void;
  58367. /**
  58368. * Callback called when a task is done (whatever the result is)
  58369. */
  58370. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58371. /**
  58372. * Observable called when all tasks are processed
  58373. */
  58374. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58375. /**
  58376. * Observable called when a task had an error
  58377. */
  58378. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58379. /**
  58380. * Observable called when all tasks were executed
  58381. */
  58382. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58383. /**
  58384. * Observable called when a task is done (whatever the result is)
  58385. */
  58386. onProgressObservable: Observable<IAssetsProgressEvent>;
  58387. /**
  58388. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58389. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58390. */
  58391. useDefaultLoadingScreen: boolean;
  58392. /**
  58393. * Creates a new AssetsManager
  58394. * @param scene defines the scene to work on
  58395. */
  58396. constructor(scene: Scene);
  58397. /**
  58398. * Add a MeshAssetTask to the list of active tasks
  58399. * @param taskName defines the name of the new task
  58400. * @param meshesNames defines the name of meshes to load
  58401. * @param rootUrl defines the root url to use to locate files
  58402. * @param sceneFilename defines the filename of the scene file
  58403. * @returns a new MeshAssetTask object
  58404. */
  58405. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58406. /**
  58407. * Add a TextFileAssetTask to the list of active tasks
  58408. * @param taskName defines the name of the new task
  58409. * @param url defines the url of the file to load
  58410. * @returns a new TextFileAssetTask object
  58411. */
  58412. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58413. /**
  58414. * Add a BinaryFileAssetTask to the list of active tasks
  58415. * @param taskName defines the name of the new task
  58416. * @param url defines the url of the file to load
  58417. * @returns a new BinaryFileAssetTask object
  58418. */
  58419. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58420. /**
  58421. * Add a ImageAssetTask to the list of active tasks
  58422. * @param taskName defines the name of the new task
  58423. * @param url defines the url of the file to load
  58424. * @returns a new ImageAssetTask object
  58425. */
  58426. addImageTask(taskName: string, url: string): ImageAssetTask;
  58427. /**
  58428. * Add a TextureAssetTask to the list of active tasks
  58429. * @param taskName defines the name of the new task
  58430. * @param url defines the url of the file to load
  58431. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58432. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58433. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58434. * @returns a new TextureAssetTask object
  58435. */
  58436. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58437. /**
  58438. * Add a CubeTextureAssetTask to the list of active tasks
  58439. * @param taskName defines the name of the new task
  58440. * @param url defines the url of the file to load
  58441. * @param extensions defines the extension to use to load the cube map (can be null)
  58442. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58443. * @param files defines the list of files to load (can be null)
  58444. * @returns a new CubeTextureAssetTask object
  58445. */
  58446. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58447. /**
  58448. *
  58449. * Add a HDRCubeTextureAssetTask 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. * @param size defines the size you want for the cubemap (can be null)
  58453. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58454. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58455. * @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)
  58456. * @param reserved Internal use only
  58457. * @returns a new HDRCubeTextureAssetTask object
  58458. */
  58459. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58460. /**
  58461. *
  58462. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58463. * @param taskName defines the name of the new task
  58464. * @param url defines the url of the file to load
  58465. * @param size defines the size you want for the cubemap (can be null)
  58466. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58467. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58468. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58469. * @returns a new EquiRectangularCubeTextureAssetTask object
  58470. */
  58471. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58472. /**
  58473. * Remove a task from the assets manager.
  58474. * @param task the task to remove
  58475. */
  58476. removeTask(task: AbstractAssetTask): void;
  58477. private _decreaseWaitingTasksCount;
  58478. private _runTask;
  58479. /**
  58480. * Reset the AssetsManager and remove all tasks
  58481. * @return the current instance of the AssetsManager
  58482. */
  58483. reset(): AssetsManager;
  58484. /**
  58485. * Start the loading process
  58486. * @return the current instance of the AssetsManager
  58487. */
  58488. load(): AssetsManager;
  58489. /**
  58490. * Start the loading process as an async operation
  58491. * @return a promise returning the list of failed tasks
  58492. */
  58493. loadAsync(): Promise<void>;
  58494. }
  58495. }
  58496. declare module "babylonjs/Misc/deferred" {
  58497. /**
  58498. * Wrapper class for promise with external resolve and reject.
  58499. */
  58500. export class Deferred<T> {
  58501. /**
  58502. * The promise associated with this deferred object.
  58503. */
  58504. readonly promise: Promise<T>;
  58505. private _resolve;
  58506. private _reject;
  58507. /**
  58508. * The resolve method of the promise associated with this deferred object.
  58509. */
  58510. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58511. /**
  58512. * The reject method of the promise associated with this deferred object.
  58513. */
  58514. readonly reject: (reason?: any) => void;
  58515. /**
  58516. * Constructor for this deferred object.
  58517. */
  58518. constructor();
  58519. }
  58520. }
  58521. declare module "babylonjs/Misc/meshExploder" {
  58522. import { Mesh } from "babylonjs/Meshes/mesh";
  58523. /**
  58524. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58525. */
  58526. export class MeshExploder {
  58527. private _centerMesh;
  58528. private _meshes;
  58529. private _meshesOrigins;
  58530. private _toCenterVectors;
  58531. private _scaledDirection;
  58532. private _newPosition;
  58533. private _centerPosition;
  58534. /**
  58535. * Explodes meshes from a center mesh.
  58536. * @param meshes The meshes to explode.
  58537. * @param centerMesh The mesh to be center of explosion.
  58538. */
  58539. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58540. private _setCenterMesh;
  58541. /**
  58542. * Get class name
  58543. * @returns "MeshExploder"
  58544. */
  58545. getClassName(): string;
  58546. /**
  58547. * "Exploded meshes"
  58548. * @returns Array of meshes with the centerMesh at index 0.
  58549. */
  58550. getMeshes(): Array<Mesh>;
  58551. /**
  58552. * Explodes meshes giving a specific direction
  58553. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58554. */
  58555. explode(direction?: number): void;
  58556. }
  58557. }
  58558. declare module "babylonjs/Misc/filesInput" {
  58559. import { Engine } from "babylonjs/Engines/engine";
  58560. import { Scene } from "babylonjs/scene";
  58561. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58562. /**
  58563. * Class used to help managing file picking and drag'n'drop
  58564. */
  58565. export class FilesInput {
  58566. /**
  58567. * List of files ready to be loaded
  58568. */
  58569. static readonly FilesToLoad: {
  58570. [key: string]: File;
  58571. };
  58572. /**
  58573. * Callback called when a file is processed
  58574. */
  58575. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58576. private _engine;
  58577. private _currentScene;
  58578. private _sceneLoadedCallback;
  58579. private _progressCallback;
  58580. private _additionalRenderLoopLogicCallback;
  58581. private _textureLoadingCallback;
  58582. private _startingProcessingFilesCallback;
  58583. private _onReloadCallback;
  58584. private _errorCallback;
  58585. private _elementToMonitor;
  58586. private _sceneFileToLoad;
  58587. private _filesToLoad;
  58588. /**
  58589. * Creates a new FilesInput
  58590. * @param engine defines the rendering engine
  58591. * @param scene defines the hosting scene
  58592. * @param sceneLoadedCallback callback called when scene is loaded
  58593. * @param progressCallback callback called to track progress
  58594. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58595. * @param textureLoadingCallback callback called when a texture is loading
  58596. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58597. * @param onReloadCallback callback called when a reload is requested
  58598. * @param errorCallback callback call if an error occurs
  58599. */
  58600. 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);
  58601. private _dragEnterHandler;
  58602. private _dragOverHandler;
  58603. private _dropHandler;
  58604. /**
  58605. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58606. * @param elementToMonitor defines the DOM element to track
  58607. */
  58608. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58609. /**
  58610. * Release all associated resources
  58611. */
  58612. dispose(): void;
  58613. private renderFunction;
  58614. private drag;
  58615. private drop;
  58616. private _traverseFolder;
  58617. private _processFiles;
  58618. /**
  58619. * Load files from a drop event
  58620. * @param event defines the drop event to use as source
  58621. */
  58622. loadFiles(event: any): void;
  58623. private _processReload;
  58624. /**
  58625. * Reload the current scene from the loaded files
  58626. */
  58627. reload(): void;
  58628. }
  58629. }
  58630. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58631. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58632. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58633. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58634. }
  58635. declare module "babylonjs/Misc/sceneOptimizer" {
  58636. import { Scene, IDisposable } from "babylonjs/scene";
  58637. import { Observable } from "babylonjs/Misc/observable";
  58638. /**
  58639. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58641. */
  58642. export class SceneOptimization {
  58643. /**
  58644. * Defines the priority of this optimization (0 by default which means first in the list)
  58645. */
  58646. priority: number;
  58647. /**
  58648. * Gets a string describing the action executed by the current optimization
  58649. * @returns description string
  58650. */
  58651. getDescription(): string;
  58652. /**
  58653. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58654. * @param scene defines the current scene where to apply this optimization
  58655. * @param optimizer defines the current optimizer
  58656. * @returns true if everything that can be done was applied
  58657. */
  58658. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58659. /**
  58660. * Creates the SceneOptimization object
  58661. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58662. * @param desc defines the description associated with the optimization
  58663. */
  58664. constructor(
  58665. /**
  58666. * Defines the priority of this optimization (0 by default which means first in the list)
  58667. */
  58668. priority?: number);
  58669. }
  58670. /**
  58671. * Defines an optimization used to reduce the size of render target textures
  58672. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58673. */
  58674. export class TextureOptimization extends SceneOptimization {
  58675. /**
  58676. * Defines the priority of this optimization (0 by default which means first in the list)
  58677. */
  58678. priority: number;
  58679. /**
  58680. * 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
  58681. */
  58682. maximumSize: number;
  58683. /**
  58684. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58685. */
  58686. step: number;
  58687. /**
  58688. * Gets a string describing the action executed by the current optimization
  58689. * @returns description string
  58690. */
  58691. getDescription(): string;
  58692. /**
  58693. * Creates the TextureOptimization object
  58694. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58695. * @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
  58696. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58697. */
  58698. constructor(
  58699. /**
  58700. * Defines the priority of this optimization (0 by default which means first in the list)
  58701. */
  58702. priority?: number,
  58703. /**
  58704. * 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
  58705. */
  58706. maximumSize?: number,
  58707. /**
  58708. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58709. */
  58710. step?: number);
  58711. /**
  58712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58713. * @param scene defines the current scene where to apply this optimization
  58714. * @param optimizer defines the current optimizer
  58715. * @returns true if everything that can be done was applied
  58716. */
  58717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58718. }
  58719. /**
  58720. * Defines an optimization used to increase or decrease the rendering resolution
  58721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58722. */
  58723. export class HardwareScalingOptimization extends SceneOptimization {
  58724. /**
  58725. * Defines the priority of this optimization (0 by default which means first in the list)
  58726. */
  58727. priority: number;
  58728. /**
  58729. * Defines the maximum scale to use (2 by default)
  58730. */
  58731. maximumScale: number;
  58732. /**
  58733. * Defines the step to use between two passes (0.5 by default)
  58734. */
  58735. step: number;
  58736. private _currentScale;
  58737. private _directionOffset;
  58738. /**
  58739. * Gets a string describing the action executed by the current optimization
  58740. * @return description string
  58741. */
  58742. getDescription(): string;
  58743. /**
  58744. * Creates the HardwareScalingOptimization object
  58745. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58746. * @param maximumScale defines the maximum scale to use (2 by default)
  58747. * @param step defines the step to use between two passes (0.5 by default)
  58748. */
  58749. constructor(
  58750. /**
  58751. * Defines the priority of this optimization (0 by default which means first in the list)
  58752. */
  58753. priority?: number,
  58754. /**
  58755. * Defines the maximum scale to use (2 by default)
  58756. */
  58757. maximumScale?: number,
  58758. /**
  58759. * Defines the step to use between two passes (0.5 by default)
  58760. */
  58761. step?: number);
  58762. /**
  58763. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58764. * @param scene defines the current scene where to apply this optimization
  58765. * @param optimizer defines the current optimizer
  58766. * @returns true if everything that can be done was applied
  58767. */
  58768. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58769. }
  58770. /**
  58771. * Defines an optimization used to remove shadows
  58772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58773. */
  58774. export class ShadowsOptimization extends SceneOptimization {
  58775. /**
  58776. * Gets a string describing the action executed by the current optimization
  58777. * @return description string
  58778. */
  58779. getDescription(): string;
  58780. /**
  58781. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58782. * @param scene defines the current scene where to apply this optimization
  58783. * @param optimizer defines the current optimizer
  58784. * @returns true if everything that can be done was applied
  58785. */
  58786. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58787. }
  58788. /**
  58789. * Defines an optimization used to turn post-processes off
  58790. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58791. */
  58792. export class PostProcessesOptimization extends SceneOptimization {
  58793. /**
  58794. * Gets a string describing the action executed by the current optimization
  58795. * @return description string
  58796. */
  58797. getDescription(): string;
  58798. /**
  58799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58800. * @param scene defines the current scene where to apply this optimization
  58801. * @param optimizer defines the current optimizer
  58802. * @returns true if everything that can be done was applied
  58803. */
  58804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58805. }
  58806. /**
  58807. * Defines an optimization used to turn lens flares off
  58808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58809. */
  58810. export class LensFlaresOptimization extends SceneOptimization {
  58811. /**
  58812. * Gets a string describing the action executed by the current optimization
  58813. * @return description string
  58814. */
  58815. getDescription(): string;
  58816. /**
  58817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58818. * @param scene defines the current scene where to apply this optimization
  58819. * @param optimizer defines the current optimizer
  58820. * @returns true if everything that can be done was applied
  58821. */
  58822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58823. }
  58824. /**
  58825. * Defines an optimization based on user defined callback.
  58826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58827. */
  58828. export class CustomOptimization extends SceneOptimization {
  58829. /**
  58830. * Callback called to apply the custom optimization.
  58831. */
  58832. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58833. /**
  58834. * Callback called to get custom description
  58835. */
  58836. onGetDescription: () => string;
  58837. /**
  58838. * Gets a string describing the action executed by the current optimization
  58839. * @returns description string
  58840. */
  58841. getDescription(): string;
  58842. /**
  58843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58844. * @param scene defines the current scene where to apply this optimization
  58845. * @param optimizer defines the current optimizer
  58846. * @returns true if everything that can be done was applied
  58847. */
  58848. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58849. }
  58850. /**
  58851. * Defines an optimization used to turn particles off
  58852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58853. */
  58854. export class ParticlesOptimization extends SceneOptimization {
  58855. /**
  58856. * Gets a string describing the action executed by the current optimization
  58857. * @return description string
  58858. */
  58859. getDescription(): string;
  58860. /**
  58861. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58862. * @param scene defines the current scene where to apply this optimization
  58863. * @param optimizer defines the current optimizer
  58864. * @returns true if everything that can be done was applied
  58865. */
  58866. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58867. }
  58868. /**
  58869. * Defines an optimization used to turn render targets off
  58870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58871. */
  58872. export class RenderTargetsOptimization extends SceneOptimization {
  58873. /**
  58874. * Gets a string describing the action executed by the current optimization
  58875. * @return description string
  58876. */
  58877. getDescription(): string;
  58878. /**
  58879. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58880. * @param scene defines the current scene where to apply this optimization
  58881. * @param optimizer defines the current optimizer
  58882. * @returns true if everything that can be done was applied
  58883. */
  58884. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58885. }
  58886. /**
  58887. * Defines an optimization used to merge meshes with compatible materials
  58888. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58889. */
  58890. export class MergeMeshesOptimization extends SceneOptimization {
  58891. private static _UpdateSelectionTree;
  58892. /**
  58893. * Gets or sets a boolean which defines if optimization octree has to be updated
  58894. */
  58895. /**
  58896. * Gets or sets a boolean which defines if optimization octree has to be updated
  58897. */
  58898. static UpdateSelectionTree: boolean;
  58899. /**
  58900. * Gets a string describing the action executed by the current optimization
  58901. * @return description string
  58902. */
  58903. getDescription(): string;
  58904. private _canBeMerged;
  58905. /**
  58906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58907. * @param scene defines the current scene where to apply this optimization
  58908. * @param optimizer defines the current optimizer
  58909. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58910. * @returns true if everything that can be done was applied
  58911. */
  58912. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58913. }
  58914. /**
  58915. * Defines a list of options used by SceneOptimizer
  58916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58917. */
  58918. export class SceneOptimizerOptions {
  58919. /**
  58920. * Defines the target frame rate to reach (60 by default)
  58921. */
  58922. targetFrameRate: number;
  58923. /**
  58924. * Defines the interval between two checkes (2000ms by default)
  58925. */
  58926. trackerDuration: number;
  58927. /**
  58928. * Gets the list of optimizations to apply
  58929. */
  58930. optimizations: SceneOptimization[];
  58931. /**
  58932. * Creates a new list of options used by SceneOptimizer
  58933. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58934. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58935. */
  58936. constructor(
  58937. /**
  58938. * Defines the target frame rate to reach (60 by default)
  58939. */
  58940. targetFrameRate?: number,
  58941. /**
  58942. * Defines the interval between two checkes (2000ms by default)
  58943. */
  58944. trackerDuration?: number);
  58945. /**
  58946. * Add a new optimization
  58947. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58948. * @returns the current SceneOptimizerOptions
  58949. */
  58950. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58951. /**
  58952. * Add a new custom optimization
  58953. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58954. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58955. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58956. * @returns the current SceneOptimizerOptions
  58957. */
  58958. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58959. /**
  58960. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58961. * @param targetFrameRate defines the target frame rate (60 by default)
  58962. * @returns a SceneOptimizerOptions object
  58963. */
  58964. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58965. /**
  58966. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58967. * @param targetFrameRate defines the target frame rate (60 by default)
  58968. * @returns a SceneOptimizerOptions object
  58969. */
  58970. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58971. /**
  58972. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58973. * @param targetFrameRate defines the target frame rate (60 by default)
  58974. * @returns a SceneOptimizerOptions object
  58975. */
  58976. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58977. }
  58978. /**
  58979. * Class used to run optimizations in order to reach a target frame rate
  58980. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58981. */
  58982. export class SceneOptimizer implements IDisposable {
  58983. private _isRunning;
  58984. private _options;
  58985. private _scene;
  58986. private _currentPriorityLevel;
  58987. private _targetFrameRate;
  58988. private _trackerDuration;
  58989. private _currentFrameRate;
  58990. private _sceneDisposeObserver;
  58991. private _improvementMode;
  58992. /**
  58993. * Defines an observable called when the optimizer reaches the target frame rate
  58994. */
  58995. onSuccessObservable: Observable<SceneOptimizer>;
  58996. /**
  58997. * Defines an observable called when the optimizer enables an optimization
  58998. */
  58999. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59000. /**
  59001. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59002. */
  59003. onFailureObservable: Observable<SceneOptimizer>;
  59004. /**
  59005. * Gets a boolean indicating if the optimizer is in improvement mode
  59006. */
  59007. readonly isInImprovementMode: boolean;
  59008. /**
  59009. * Gets the current priority level (0 at start)
  59010. */
  59011. readonly currentPriorityLevel: number;
  59012. /**
  59013. * Gets the current frame rate checked by the SceneOptimizer
  59014. */
  59015. readonly currentFrameRate: number;
  59016. /**
  59017. * Gets or sets the current target frame rate (60 by default)
  59018. */
  59019. /**
  59020. * Gets or sets the current target frame rate (60 by default)
  59021. */
  59022. targetFrameRate: number;
  59023. /**
  59024. * Gets or sets the current interval between two checks (every 2000ms by default)
  59025. */
  59026. /**
  59027. * Gets or sets the current interval between two checks (every 2000ms by default)
  59028. */
  59029. trackerDuration: number;
  59030. /**
  59031. * Gets the list of active optimizations
  59032. */
  59033. readonly optimizations: SceneOptimization[];
  59034. /**
  59035. * Creates a new SceneOptimizer
  59036. * @param scene defines the scene to work on
  59037. * @param options defines the options to use with the SceneOptimizer
  59038. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59039. * @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)
  59040. */
  59041. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59042. /**
  59043. * Stops the current optimizer
  59044. */
  59045. stop(): void;
  59046. /**
  59047. * Reset the optimizer to initial step (current priority level = 0)
  59048. */
  59049. reset(): void;
  59050. /**
  59051. * Start the optimizer. By default it will try to reach a specific framerate
  59052. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59053. */
  59054. start(): void;
  59055. private _checkCurrentState;
  59056. /**
  59057. * Release all resources
  59058. */
  59059. dispose(): void;
  59060. /**
  59061. * Helper function to create a SceneOptimizer with one single line of code
  59062. * @param scene defines the scene to work on
  59063. * @param options defines the options to use with the SceneOptimizer
  59064. * @param onSuccess defines a callback to call on success
  59065. * @param onFailure defines a callback to call on failure
  59066. * @returns the new SceneOptimizer object
  59067. */
  59068. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59069. }
  59070. }
  59071. declare module "babylonjs/Misc/sceneSerializer" {
  59072. import { Scene } from "babylonjs/scene";
  59073. /**
  59074. * Class used to serialize a scene into a string
  59075. */
  59076. export class SceneSerializer {
  59077. /**
  59078. * Clear cache used by a previous serialization
  59079. */
  59080. static ClearCache(): void;
  59081. /**
  59082. * Serialize a scene into a JSON compatible object
  59083. * @param scene defines the scene to serialize
  59084. * @returns a JSON compatible object
  59085. */
  59086. static Serialize(scene: Scene): any;
  59087. /**
  59088. * Serialize a mesh into a JSON compatible object
  59089. * @param toSerialize defines the mesh to serialize
  59090. * @param withParents defines if parents must be serialized as well
  59091. * @param withChildren defines if children must be serialized as well
  59092. * @returns a JSON compatible object
  59093. */
  59094. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59095. }
  59096. }
  59097. declare module "babylonjs/Misc/textureTools" {
  59098. import { Texture } from "babylonjs/Materials/Textures/texture";
  59099. /**
  59100. * Class used to host texture specific utilities
  59101. */
  59102. export class TextureTools {
  59103. /**
  59104. * Uses the GPU to create a copy texture rescaled at a given size
  59105. * @param texture Texture to copy from
  59106. * @param width defines the desired width
  59107. * @param height defines the desired height
  59108. * @param useBilinearMode defines if bilinear mode has to be used
  59109. * @return the generated texture
  59110. */
  59111. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59112. }
  59113. }
  59114. declare module "babylonjs/Misc/videoRecorder" {
  59115. import { Nullable } from "babylonjs/types";
  59116. import { Engine } from "babylonjs/Engines/engine";
  59117. /**
  59118. * This represents the different options avilable for the video capture.
  59119. */
  59120. export interface VideoRecorderOptions {
  59121. /** Defines the mime type of the video */
  59122. mimeType: string;
  59123. /** Defines the video the video should be recorded at */
  59124. fps: number;
  59125. /** Defines the chunk size for the recording data */
  59126. recordChunckSize: number;
  59127. /** The audio tracks to attach to the record */
  59128. audioTracks?: MediaStreamTrack[];
  59129. }
  59130. /**
  59131. * This can helps recording videos from BabylonJS.
  59132. * This is based on the available WebRTC functionalities of the browser.
  59133. *
  59134. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59135. */
  59136. export class VideoRecorder {
  59137. private static readonly _defaultOptions;
  59138. /**
  59139. * Returns wehther or not the VideoRecorder is available in your browser.
  59140. * @param engine Defines the Babylon Engine to check the support for
  59141. * @returns true if supported otherwise false
  59142. */
  59143. static IsSupported(engine: Engine): boolean;
  59144. private readonly _options;
  59145. private _canvas;
  59146. private _mediaRecorder;
  59147. private _recordedChunks;
  59148. private _fileName;
  59149. private _resolve;
  59150. private _reject;
  59151. /**
  59152. * True wether a recording is already in progress.
  59153. */
  59154. readonly isRecording: boolean;
  59155. /**
  59156. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59157. * a video file.
  59158. * @param engine Defines the BabylonJS Engine you wish to record
  59159. * @param options Defines options that can be used to customized the capture
  59160. */
  59161. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59162. /**
  59163. * Stops the current recording before the default capture timeout passed in the startRecording
  59164. * functions.
  59165. */
  59166. stopRecording(): void;
  59167. /**
  59168. * Starts recording the canvas for a max duration specified in parameters.
  59169. * @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.
  59170. * @param maxDuration Defines the maximum recording time in seconds.
  59171. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59172. * @return a promise callback at the end of the recording with the video data in Blob.
  59173. */
  59174. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59175. /**
  59176. * Releases internal resources used during the recording.
  59177. */
  59178. dispose(): void;
  59179. private _handleDataAvailable;
  59180. private _handleError;
  59181. private _handleStop;
  59182. }
  59183. }
  59184. declare module "babylonjs/Misc/screenshotTools" {
  59185. import { Camera } from "babylonjs/Cameras/camera";
  59186. import { Engine } from "babylonjs/Engines/engine";
  59187. /**
  59188. * Class containing a set of static utilities functions for screenshots
  59189. */
  59190. export class ScreenshotTools {
  59191. /**
  59192. * Captures a screenshot of the current rendering
  59193. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59194. * @param engine defines the rendering engine
  59195. * @param camera defines the source camera
  59196. * @param size This parameter can be set to a single number or to an object with the
  59197. * following (optional) properties: precision, width, height. If a single number is passed,
  59198. * it will be used for both width and height. If an object is passed, the screenshot size
  59199. * will be derived from the parameters. The precision property is a multiplier allowing
  59200. * rendering at a higher or lower resolution
  59201. * @param successCallback defines the callback receives a single parameter which contains the
  59202. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59203. * src parameter of an <img> to display it
  59204. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59205. * Check your browser for supported MIME types
  59206. */
  59207. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59208. /**
  59209. * Generates an image screenshot from the specified camera.
  59210. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59211. * @param engine The engine to use for rendering
  59212. * @param camera The camera to use for rendering
  59213. * @param size This parameter can be set to a single number or to an object with the
  59214. * following (optional) properties: precision, width, height. If a single number is passed,
  59215. * it will be used for both width and height. If an object is passed, the screenshot size
  59216. * will be derived from the parameters. The precision property is a multiplier allowing
  59217. * rendering at a higher or lower resolution
  59218. * @param successCallback The callback receives a single parameter which contains the
  59219. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59220. * src parameter of an <img> to display it
  59221. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59222. * Check your browser for supported MIME types
  59223. * @param samples Texture samples (default: 1)
  59224. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59225. * @param fileName A name for for the downloaded file.
  59226. */
  59227. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59228. }
  59229. }
  59230. declare module "babylonjs/Misc/index" {
  59231. export * from "babylonjs/Misc/andOrNotEvaluator";
  59232. export * from "babylonjs/Misc/assetsManager";
  59233. export * from "babylonjs/Misc/dds";
  59234. export * from "babylonjs/Misc/decorators";
  59235. export * from "babylonjs/Misc/deferred";
  59236. export * from "babylonjs/Misc/environmentTextureTools";
  59237. export * from "babylonjs/Misc/meshExploder";
  59238. export * from "babylonjs/Misc/filesInput";
  59239. export * from "babylonjs/Misc/HighDynamicRange/index";
  59240. export * from "babylonjs/Misc/khronosTextureContainer";
  59241. export * from "babylonjs/Misc/observable";
  59242. export * from "babylonjs/Misc/performanceMonitor";
  59243. export * from "babylonjs/Misc/promise";
  59244. export * from "babylonjs/Misc/sceneOptimizer";
  59245. export * from "babylonjs/Misc/sceneSerializer";
  59246. export * from "babylonjs/Misc/smartArray";
  59247. export * from "babylonjs/Misc/stringDictionary";
  59248. export * from "babylonjs/Misc/tags";
  59249. export * from "babylonjs/Misc/textureTools";
  59250. export * from "babylonjs/Misc/tga";
  59251. export * from "babylonjs/Misc/tools";
  59252. export * from "babylonjs/Misc/videoRecorder";
  59253. export * from "babylonjs/Misc/virtualJoystick";
  59254. export * from "babylonjs/Misc/workerPool";
  59255. export * from "babylonjs/Misc/logger";
  59256. export * from "babylonjs/Misc/typeStore";
  59257. export * from "babylonjs/Misc/filesInputStore";
  59258. export * from "babylonjs/Misc/deepCopier";
  59259. export * from "babylonjs/Misc/pivotTools";
  59260. export * from "babylonjs/Misc/precisionDate";
  59261. export * from "babylonjs/Misc/screenshotTools";
  59262. export * from "babylonjs/Misc/typeStore";
  59263. export * from "babylonjs/Misc/webRequest";
  59264. export * from "babylonjs/Misc/iInspectable";
  59265. }
  59266. declare module "babylonjs/index" {
  59267. export * from "babylonjs/abstractScene";
  59268. export * from "babylonjs/Actions/index";
  59269. export * from "babylonjs/Animations/index";
  59270. export * from "babylonjs/assetContainer";
  59271. export * from "babylonjs/Audio/index";
  59272. export * from "babylonjs/Behaviors/index";
  59273. export * from "babylonjs/Bones/index";
  59274. export * from "babylonjs/Cameras/index";
  59275. export * from "babylonjs/Collisions/index";
  59276. export * from "babylonjs/Culling/index";
  59277. export * from "babylonjs/Debug/index";
  59278. export * from "babylonjs/Engines/index";
  59279. export * from "babylonjs/Events/index";
  59280. export * from "babylonjs/Gamepads/index";
  59281. export * from "babylonjs/Gizmos/index";
  59282. export * from "babylonjs/Helpers/index";
  59283. export * from "babylonjs/Instrumentation/index";
  59284. export * from "babylonjs/Layers/index";
  59285. export * from "babylonjs/LensFlares/index";
  59286. export * from "babylonjs/Lights/index";
  59287. export * from "babylonjs/Loading/index";
  59288. export * from "babylonjs/Materials/index";
  59289. export * from "babylonjs/Maths/index";
  59290. export * from "babylonjs/Meshes/index";
  59291. export * from "babylonjs/Morph/index";
  59292. export * from "babylonjs/node";
  59293. export * from "babylonjs/Offline/index";
  59294. export * from "babylonjs/Particles/index";
  59295. export * from "babylonjs/Physics/index";
  59296. export * from "babylonjs/PostProcesses/index";
  59297. export * from "babylonjs/Probes/index";
  59298. export * from "babylonjs/Rendering/index";
  59299. export * from "babylonjs/scene";
  59300. export * from "babylonjs/sceneComponent";
  59301. export * from "babylonjs/Sprites/index";
  59302. export * from "babylonjs/States/index";
  59303. export * from "babylonjs/Misc/index";
  59304. export * from "babylonjs/types";
  59305. }
  59306. declare module "babylonjs/Animations/pathCursor" {
  59307. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59308. /**
  59309. * A cursor which tracks a point on a path
  59310. */
  59311. export class PathCursor {
  59312. private path;
  59313. /**
  59314. * Stores path cursor callbacks for when an onchange event is triggered
  59315. */
  59316. private _onchange;
  59317. /**
  59318. * The value of the path cursor
  59319. */
  59320. value: number;
  59321. /**
  59322. * The animation array of the path cursor
  59323. */
  59324. animations: Animation[];
  59325. /**
  59326. * Initializes the path cursor
  59327. * @param path The path to track
  59328. */
  59329. constructor(path: Path2);
  59330. /**
  59331. * Gets the cursor point on the path
  59332. * @returns A point on the path cursor at the cursor location
  59333. */
  59334. getPoint(): Vector3;
  59335. /**
  59336. * Moves the cursor ahead by the step amount
  59337. * @param step The amount to move the cursor forward
  59338. * @returns This path cursor
  59339. */
  59340. moveAhead(step?: number): PathCursor;
  59341. /**
  59342. * Moves the cursor behind by the step amount
  59343. * @param step The amount to move the cursor back
  59344. * @returns This path cursor
  59345. */
  59346. moveBack(step?: number): PathCursor;
  59347. /**
  59348. * Moves the cursor by the step amount
  59349. * If the step amount is greater than one, an exception is thrown
  59350. * @param step The amount to move the cursor
  59351. * @returns This path cursor
  59352. */
  59353. move(step: number): PathCursor;
  59354. /**
  59355. * Ensures that the value is limited between zero and one
  59356. * @returns This path cursor
  59357. */
  59358. private ensureLimits;
  59359. /**
  59360. * Runs onchange callbacks on change (used by the animation engine)
  59361. * @returns This path cursor
  59362. */
  59363. private raiseOnChange;
  59364. /**
  59365. * Executes a function on change
  59366. * @param f A path cursor onchange callback
  59367. * @returns This path cursor
  59368. */
  59369. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59370. }
  59371. }
  59372. declare module "babylonjs/Legacy/legacy" {
  59373. import * as Babylon from "babylonjs/index";
  59374. export * from "babylonjs/index";
  59375. }
  59376. declare module "babylonjs/Shaders/blur.fragment" {
  59377. /** @hidden */
  59378. export var blurPixelShader: {
  59379. name: string;
  59380. shader: string;
  59381. };
  59382. }
  59383. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59384. /** @hidden */
  59385. export var bones300Declaration: {
  59386. name: string;
  59387. shader: string;
  59388. };
  59389. }
  59390. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59391. /** @hidden */
  59392. export var instances300Declaration: {
  59393. name: string;
  59394. shader: string;
  59395. };
  59396. }
  59397. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59398. /** @hidden */
  59399. export var pointCloudVertexDeclaration: {
  59400. name: string;
  59401. shader: string;
  59402. };
  59403. }
  59404. // Mixins
  59405. interface Window {
  59406. mozIndexedDB: IDBFactory;
  59407. webkitIndexedDB: IDBFactory;
  59408. msIndexedDB: IDBFactory;
  59409. webkitURL: typeof URL;
  59410. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59411. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59412. WebGLRenderingContext: WebGLRenderingContext;
  59413. MSGesture: MSGesture;
  59414. CANNON: any;
  59415. AudioContext: AudioContext;
  59416. webkitAudioContext: AudioContext;
  59417. PointerEvent: any;
  59418. Math: Math;
  59419. Uint8Array: Uint8ArrayConstructor;
  59420. Float32Array: Float32ArrayConstructor;
  59421. mozURL: typeof URL;
  59422. msURL: typeof URL;
  59423. VRFrameData: any; // WebVR, from specs 1.1
  59424. DracoDecoderModule: any;
  59425. setImmediate(handler: (...args: any[]) => void): number;
  59426. }
  59427. interface HTMLCanvasElement {
  59428. requestPointerLock(): void;
  59429. msRequestPointerLock?(): void;
  59430. mozRequestPointerLock?(): void;
  59431. webkitRequestPointerLock?(): void;
  59432. /** Track wether a record is in progress */
  59433. isRecording: boolean;
  59434. /** Capture Stream method defined by some browsers */
  59435. captureStream(fps?: number): MediaStream;
  59436. }
  59437. interface CanvasRenderingContext2D {
  59438. msImageSmoothingEnabled: boolean;
  59439. }
  59440. interface MouseEvent {
  59441. mozMovementX: number;
  59442. mozMovementY: number;
  59443. webkitMovementX: number;
  59444. webkitMovementY: number;
  59445. msMovementX: number;
  59446. msMovementY: number;
  59447. }
  59448. interface Navigator {
  59449. mozGetVRDevices: (any: any) => any;
  59450. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59451. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59452. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59453. webkitGetGamepads(): Gamepad[];
  59454. msGetGamepads(): Gamepad[];
  59455. webkitGamepads(): Gamepad[];
  59456. }
  59457. interface HTMLVideoElement {
  59458. mozSrcObject: any;
  59459. }
  59460. interface Math {
  59461. fround(x: number): number;
  59462. imul(a: number, b: number): number;
  59463. }
  59464. interface WebGLRenderingContext {
  59465. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59466. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59467. vertexAttribDivisor(index: number, divisor: number): void;
  59468. createVertexArray(): any;
  59469. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59470. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59471. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59472. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59473. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59474. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59475. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59476. // Queries
  59477. createQuery(): WebGLQuery;
  59478. deleteQuery(query: WebGLQuery): void;
  59479. beginQuery(target: number, query: WebGLQuery): void;
  59480. endQuery(target: number): void;
  59481. getQueryParameter(query: WebGLQuery, pname: number): any;
  59482. getQuery(target: number, pname: number): any;
  59483. MAX_SAMPLES: number;
  59484. RGBA8: number;
  59485. READ_FRAMEBUFFER: number;
  59486. DRAW_FRAMEBUFFER: number;
  59487. UNIFORM_BUFFER: number;
  59488. HALF_FLOAT_OES: number;
  59489. RGBA16F: number;
  59490. RGBA32F: number;
  59491. R32F: number;
  59492. RG32F: number;
  59493. RGB32F: number;
  59494. R16F: number;
  59495. RG16F: number;
  59496. RGB16F: number;
  59497. RED: number;
  59498. RG: number;
  59499. R8: number;
  59500. RG8: number;
  59501. UNSIGNED_INT_24_8: number;
  59502. DEPTH24_STENCIL8: number;
  59503. /* Multiple Render Targets */
  59504. drawBuffers(buffers: number[]): void;
  59505. readBuffer(src: number): void;
  59506. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59507. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59508. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59509. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59510. // Occlusion Query
  59511. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59512. ANY_SAMPLES_PASSED: number;
  59513. QUERY_RESULT_AVAILABLE: number;
  59514. QUERY_RESULT: number;
  59515. }
  59516. interface WebGLProgram {
  59517. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59518. }
  59519. interface EXT_disjoint_timer_query {
  59520. QUERY_COUNTER_BITS_EXT: number;
  59521. TIME_ELAPSED_EXT: number;
  59522. TIMESTAMP_EXT: number;
  59523. GPU_DISJOINT_EXT: number;
  59524. QUERY_RESULT_EXT: number;
  59525. QUERY_RESULT_AVAILABLE_EXT: number;
  59526. queryCounterEXT(query: WebGLQuery, target: number): void;
  59527. createQueryEXT(): WebGLQuery;
  59528. beginQueryEXT(target: number, query: WebGLQuery): void;
  59529. endQueryEXT(target: number): void;
  59530. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59531. deleteQueryEXT(query: WebGLQuery): void;
  59532. }
  59533. interface WebGLUniformLocation {
  59534. _currentState: any;
  59535. }
  59536. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59537. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59538. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59539. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59540. interface WebGLRenderingContext {
  59541. readonly RASTERIZER_DISCARD: number;
  59542. readonly DEPTH_COMPONENT24: number;
  59543. readonly TEXTURE_3D: number;
  59544. readonly TEXTURE_2D_ARRAY: number;
  59545. readonly TEXTURE_COMPARE_FUNC: number;
  59546. readonly TEXTURE_COMPARE_MODE: number;
  59547. readonly COMPARE_REF_TO_TEXTURE: number;
  59548. readonly TEXTURE_WRAP_R: number;
  59549. readonly HALF_FLOAT: number;
  59550. readonly RGB8: number;
  59551. readonly RED_INTEGER: number;
  59552. readonly RG_INTEGER: number;
  59553. readonly RGB_INTEGER: number;
  59554. readonly RGBA_INTEGER: number;
  59555. readonly R8_SNORM: number;
  59556. readonly RG8_SNORM: number;
  59557. readonly RGB8_SNORM: number;
  59558. readonly RGBA8_SNORM: number;
  59559. readonly R8I: number;
  59560. readonly RG8I: number;
  59561. readonly RGB8I: number;
  59562. readonly RGBA8I: number;
  59563. readonly R8UI: number;
  59564. readonly RG8UI: number;
  59565. readonly RGB8UI: number;
  59566. readonly RGBA8UI: number;
  59567. readonly R16I: number;
  59568. readonly RG16I: number;
  59569. readonly RGB16I: number;
  59570. readonly RGBA16I: number;
  59571. readonly R16UI: number;
  59572. readonly RG16UI: number;
  59573. readonly RGB16UI: number;
  59574. readonly RGBA16UI: number;
  59575. readonly R32I: number;
  59576. readonly RG32I: number;
  59577. readonly RGB32I: number;
  59578. readonly RGBA32I: number;
  59579. readonly R32UI: number;
  59580. readonly RG32UI: number;
  59581. readonly RGB32UI: number;
  59582. readonly RGBA32UI: number;
  59583. readonly RGB10_A2UI: number;
  59584. readonly R11F_G11F_B10F: number;
  59585. readonly RGB9_E5: number;
  59586. readonly RGB10_A2: number;
  59587. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59588. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59589. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59590. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59591. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59592. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59593. 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;
  59594. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59595. readonly TRANSFORM_FEEDBACK: number;
  59596. readonly INTERLEAVED_ATTRIBS: number;
  59597. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59598. createTransformFeedback(): WebGLTransformFeedback;
  59599. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59600. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59601. beginTransformFeedback(primitiveMode: number): void;
  59602. endTransformFeedback(): void;
  59603. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59604. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59605. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59606. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59607. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59608. }
  59609. interface ImageBitmap {
  59610. readonly width: number;
  59611. readonly height: number;
  59612. close(): void;
  59613. }
  59614. interface WebGLQuery extends WebGLObject {
  59615. }
  59616. declare var WebGLQuery: {
  59617. prototype: WebGLQuery;
  59618. new(): WebGLQuery;
  59619. };
  59620. interface WebGLSampler extends WebGLObject {
  59621. }
  59622. declare var WebGLSampler: {
  59623. prototype: WebGLSampler;
  59624. new(): WebGLSampler;
  59625. };
  59626. interface WebGLSync extends WebGLObject {
  59627. }
  59628. declare var WebGLSync: {
  59629. prototype: WebGLSync;
  59630. new(): WebGLSync;
  59631. };
  59632. interface WebGLTransformFeedback extends WebGLObject {
  59633. }
  59634. declare var WebGLTransformFeedback: {
  59635. prototype: WebGLTransformFeedback;
  59636. new(): WebGLTransformFeedback;
  59637. };
  59638. interface WebGLVertexArrayObject extends WebGLObject {
  59639. }
  59640. declare var WebGLVertexArrayObject: {
  59641. prototype: WebGLVertexArrayObject;
  59642. new(): WebGLVertexArrayObject;
  59643. };
  59644. // Type definitions for WebVR API
  59645. // Project: https://w3c.github.io/webvr/
  59646. // Definitions by: six a <https://github.com/lostfictions>
  59647. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59648. interface VRDisplay extends EventTarget {
  59649. /**
  59650. * Dictionary of capabilities describing the VRDisplay.
  59651. */
  59652. readonly capabilities: VRDisplayCapabilities;
  59653. /**
  59654. * z-depth defining the far plane of the eye view frustum
  59655. * enables mapping of values in the render target depth
  59656. * attachment to scene coordinates. Initially set to 10000.0.
  59657. */
  59658. depthFar: number;
  59659. /**
  59660. * z-depth defining the near plane of the eye view frustum
  59661. * enables mapping of values in the render target depth
  59662. * attachment to scene coordinates. Initially set to 0.01.
  59663. */
  59664. depthNear: number;
  59665. /**
  59666. * An identifier for this distinct VRDisplay. Used as an
  59667. * association point in the Gamepad API.
  59668. */
  59669. readonly displayId: number;
  59670. /**
  59671. * A display name, a user-readable name identifying it.
  59672. */
  59673. readonly displayName: string;
  59674. readonly isConnected: boolean;
  59675. readonly isPresenting: boolean;
  59676. /**
  59677. * If this VRDisplay supports room-scale experiences, the optional
  59678. * stage attribute contains details on the room-scale parameters.
  59679. */
  59680. readonly stageParameters: VRStageParameters | null;
  59681. /**
  59682. * Passing the value returned by `requestAnimationFrame` to
  59683. * `cancelAnimationFrame` will unregister the callback.
  59684. * @param handle Define the hanle of the request to cancel
  59685. */
  59686. cancelAnimationFrame(handle: number): void;
  59687. /**
  59688. * Stops presenting to the VRDisplay.
  59689. * @returns a promise to know when it stopped
  59690. */
  59691. exitPresent(): Promise<void>;
  59692. /**
  59693. * Return the current VREyeParameters for the given eye.
  59694. * @param whichEye Define the eye we want the parameter for
  59695. * @returns the eye parameters
  59696. */
  59697. getEyeParameters(whichEye: string): VREyeParameters;
  59698. /**
  59699. * Populates the passed VRFrameData with the information required to render
  59700. * the current frame.
  59701. * @param frameData Define the data structure to populate
  59702. * @returns true if ok otherwise false
  59703. */
  59704. getFrameData(frameData: VRFrameData): boolean;
  59705. /**
  59706. * Get the layers currently being presented.
  59707. * @returns the list of VR layers
  59708. */
  59709. getLayers(): VRLayer[];
  59710. /**
  59711. * Return a VRPose containing the future predicted pose of the VRDisplay
  59712. * when the current frame will be presented. The value returned will not
  59713. * change until JavaScript has returned control to the browser.
  59714. *
  59715. * The VRPose will contain the position, orientation, velocity,
  59716. * and acceleration of each of these properties.
  59717. * @returns the pose object
  59718. */
  59719. getPose(): VRPose;
  59720. /**
  59721. * Return the current instantaneous pose of the VRDisplay, with no
  59722. * prediction applied.
  59723. * @returns the current instantaneous pose
  59724. */
  59725. getImmediatePose(): VRPose;
  59726. /**
  59727. * The callback passed to `requestAnimationFrame` will be called
  59728. * any time a new frame should be rendered. When the VRDisplay is
  59729. * presenting the callback will be called at the native refresh
  59730. * rate of the HMD. When not presenting this function acts
  59731. * identically to how window.requestAnimationFrame acts. Content should
  59732. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59733. * asynchronously from other displays and at differing refresh rates.
  59734. * @param callback Define the eaction to run next frame
  59735. * @returns the request handle it
  59736. */
  59737. requestAnimationFrame(callback: FrameRequestCallback): number;
  59738. /**
  59739. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59740. * Repeat calls while already presenting will update the VRLayers being displayed.
  59741. * @param layers Define the list of layer to present
  59742. * @returns a promise to know when the request has been fulfilled
  59743. */
  59744. requestPresent(layers: VRLayer[]): Promise<void>;
  59745. /**
  59746. * Reset the pose for this display, treating its current position and
  59747. * orientation as the "origin/zero" values. VRPose.position,
  59748. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59749. * updated when calling resetPose(). This should be called in only
  59750. * sitting-space experiences.
  59751. */
  59752. resetPose(): void;
  59753. /**
  59754. * The VRLayer provided to the VRDisplay will be captured and presented
  59755. * in the HMD. Calling this function has the same effect on the source
  59756. * canvas as any other operation that uses its source image, and canvases
  59757. * created without preserveDrawingBuffer set to true will be cleared.
  59758. * @param pose Define the pose to submit
  59759. */
  59760. submitFrame(pose?: VRPose): void;
  59761. }
  59762. declare var VRDisplay: {
  59763. prototype: VRDisplay;
  59764. new(): VRDisplay;
  59765. };
  59766. interface VRLayer {
  59767. leftBounds?: number[] | Float32Array | null;
  59768. rightBounds?: number[] | Float32Array | null;
  59769. source?: HTMLCanvasElement | null;
  59770. }
  59771. interface VRDisplayCapabilities {
  59772. readonly canPresent: boolean;
  59773. readonly hasExternalDisplay: boolean;
  59774. readonly hasOrientation: boolean;
  59775. readonly hasPosition: boolean;
  59776. readonly maxLayers: number;
  59777. }
  59778. interface VREyeParameters {
  59779. /** @deprecated */
  59780. readonly fieldOfView: VRFieldOfView;
  59781. readonly offset: Float32Array;
  59782. readonly renderHeight: number;
  59783. readonly renderWidth: number;
  59784. }
  59785. interface VRFieldOfView {
  59786. readonly downDegrees: number;
  59787. readonly leftDegrees: number;
  59788. readonly rightDegrees: number;
  59789. readonly upDegrees: number;
  59790. }
  59791. interface VRFrameData {
  59792. readonly leftProjectionMatrix: Float32Array;
  59793. readonly leftViewMatrix: Float32Array;
  59794. readonly pose: VRPose;
  59795. readonly rightProjectionMatrix: Float32Array;
  59796. readonly rightViewMatrix: Float32Array;
  59797. readonly timestamp: number;
  59798. }
  59799. interface VRPose {
  59800. readonly angularAcceleration: Float32Array | null;
  59801. readonly angularVelocity: Float32Array | null;
  59802. readonly linearAcceleration: Float32Array | null;
  59803. readonly linearVelocity: Float32Array | null;
  59804. readonly orientation: Float32Array | null;
  59805. readonly position: Float32Array | null;
  59806. readonly timestamp: number;
  59807. }
  59808. interface VRStageParameters {
  59809. sittingToStandingTransform?: Float32Array;
  59810. sizeX?: number;
  59811. sizeY?: number;
  59812. }
  59813. interface Navigator {
  59814. getVRDisplays(): Promise<VRDisplay[]>;
  59815. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59816. }
  59817. interface Window {
  59818. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59819. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59820. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59821. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59822. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59823. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59824. }
  59825. interface Gamepad {
  59826. readonly displayId: number;
  59827. }
  59828. interface XRDevice {
  59829. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59830. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59831. }
  59832. interface XRSession {
  59833. getInputSources(): Array<any>;
  59834. baseLayer: XRWebGLLayer;
  59835. requestFrameOfReference(type: string): Promise<void>;
  59836. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59837. end(): Promise<void>;
  59838. requestAnimationFrame: Function;
  59839. addEventListener: Function;
  59840. }
  59841. interface XRSessionCreationOptions {
  59842. outputContext?: WebGLRenderingContext | null;
  59843. immersive?: boolean;
  59844. environmentIntegration?: boolean;
  59845. }
  59846. interface XRLayer {
  59847. getViewport: Function;
  59848. framebufferWidth: number;
  59849. framebufferHeight: number;
  59850. }
  59851. interface XRView {
  59852. projectionMatrix: Float32Array;
  59853. }
  59854. interface XRFrame {
  59855. getDevicePose: Function;
  59856. getInputPose: Function;
  59857. views: Array<XRView>;
  59858. baseLayer: XRLayer;
  59859. }
  59860. interface XRFrameOfReference {
  59861. }
  59862. interface XRWebGLLayer extends XRLayer {
  59863. framebuffer: WebGLFramebuffer;
  59864. }
  59865. declare var XRWebGLLayer: {
  59866. prototype: XRWebGLLayer;
  59867. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59868. };
  59869. declare module "babylonjs" {
  59870. export * from "babylonjs/Legacy/legacy";
  59871. }
  59872. declare module BABYLON {
  59873. /** Alias type for value that can be null */
  59874. export type Nullable<T> = T | null;
  59875. /**
  59876. * Alias type for number that are floats
  59877. * @ignorenaming
  59878. */
  59879. export type float = number;
  59880. /**
  59881. * Alias type for number that are doubles.
  59882. * @ignorenaming
  59883. */
  59884. export type double = number;
  59885. /**
  59886. * Alias type for number that are integer
  59887. * @ignorenaming
  59888. */
  59889. export type int = number;
  59890. /** Alias type for number array or Float32Array */
  59891. export type FloatArray = number[] | Float32Array;
  59892. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59893. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59894. /**
  59895. * Alias for types that can be used by a Buffer or VertexBuffer.
  59896. */
  59897. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59898. /**
  59899. * Alias type for primitive types
  59900. * @ignorenaming
  59901. */
  59902. type Primitive = undefined | null | boolean | string | number | Function;
  59903. /**
  59904. * Type modifier to make all the properties of an object Readonly
  59905. */
  59906. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59907. /**
  59908. * Type modifier to make all the properties of an object Readonly recursively
  59909. */
  59910. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59911. /** @hidden */
  59912. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59913. }
  59914. /** @hidden */
  59915. /** @hidden */
  59916. type DeepImmutableObject<T> = {
  59917. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59918. };
  59919. }
  59920. declare module BABYLON {
  59921. /**
  59922. * Class containing a set of static utilities functions for arrays.
  59923. */
  59924. export class ArrayTools {
  59925. /**
  59926. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59927. * @param size the number of element to construct and put in the array
  59928. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59929. * @returns a new array filled with new objects
  59930. */
  59931. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59932. }
  59933. }
  59934. declare module BABYLON {
  59935. /**
  59936. * Scalar computation library
  59937. */
  59938. export class Scalar {
  59939. /**
  59940. * Two pi constants convenient for computation.
  59941. */
  59942. static TwoPi: number;
  59943. /**
  59944. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59945. * @param a number
  59946. * @param b number
  59947. * @param epsilon (default = 1.401298E-45)
  59948. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59949. */
  59950. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59951. /**
  59952. * Returns a string : the upper case translation of the number i to hexadecimal.
  59953. * @param i number
  59954. * @returns the upper case translation of the number i to hexadecimal.
  59955. */
  59956. static ToHex(i: number): string;
  59957. /**
  59958. * Returns -1 if value is negative and +1 is value is positive.
  59959. * @param value the value
  59960. * @returns the value itself if it's equal to zero.
  59961. */
  59962. static Sign(value: number): number;
  59963. /**
  59964. * Returns the value itself if it's between min and max.
  59965. * Returns min if the value is lower than min.
  59966. * Returns max if the value is greater than max.
  59967. * @param value the value to clmap
  59968. * @param min the min value to clamp to (default: 0)
  59969. * @param max the max value to clamp to (default: 1)
  59970. * @returns the clamped value
  59971. */
  59972. static Clamp(value: number, min?: number, max?: number): number;
  59973. /**
  59974. * the log2 of value.
  59975. * @param value the value to compute log2 of
  59976. * @returns the log2 of value.
  59977. */
  59978. static Log2(value: number): number;
  59979. /**
  59980. * Loops the value, so that it is never larger than length and never smaller than 0.
  59981. *
  59982. * This is similar to the modulo operator but it works with floating point numbers.
  59983. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59984. * With t = 5 and length = 2.5, the result would be 0.0.
  59985. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59986. * @param value the value
  59987. * @param length the length
  59988. * @returns the looped value
  59989. */
  59990. static Repeat(value: number, length: number): number;
  59991. /**
  59992. * Normalize the value between 0.0 and 1.0 using min and max values
  59993. * @param value value to normalize
  59994. * @param min max to normalize between
  59995. * @param max min to normalize between
  59996. * @returns the normalized value
  59997. */
  59998. static Normalize(value: number, min: number, max: number): number;
  59999. /**
  60000. * Denormalize the value from 0.0 and 1.0 using min and max values
  60001. * @param normalized value to denormalize
  60002. * @param min max to denormalize between
  60003. * @param max min to denormalize between
  60004. * @returns the denormalized value
  60005. */
  60006. static Denormalize(normalized: number, min: number, max: number): number;
  60007. /**
  60008. * Calculates the shortest difference between two given angles given in degrees.
  60009. * @param current current angle in degrees
  60010. * @param target target angle in degrees
  60011. * @returns the delta
  60012. */
  60013. static DeltaAngle(current: number, target: number): number;
  60014. /**
  60015. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60016. * @param tx value
  60017. * @param length length
  60018. * @returns The returned value will move back and forth between 0 and length
  60019. */
  60020. static PingPong(tx: number, length: number): number;
  60021. /**
  60022. * Interpolates between min and max with smoothing at the limits.
  60023. *
  60024. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60025. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60026. * @param from from
  60027. * @param to to
  60028. * @param tx value
  60029. * @returns the smooth stepped value
  60030. */
  60031. static SmoothStep(from: number, to: number, tx: number): number;
  60032. /**
  60033. * Moves a value current towards target.
  60034. *
  60035. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60036. * Negative values of maxDelta pushes the value away from target.
  60037. * @param current current value
  60038. * @param target target value
  60039. * @param maxDelta max distance to move
  60040. * @returns resulting value
  60041. */
  60042. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60043. /**
  60044. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60045. *
  60046. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60047. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60048. * @param current current value
  60049. * @param target target value
  60050. * @param maxDelta max distance to move
  60051. * @returns resulting angle
  60052. */
  60053. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60054. /**
  60055. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60056. * @param start start value
  60057. * @param end target value
  60058. * @param amount amount to lerp between
  60059. * @returns the lerped value
  60060. */
  60061. static Lerp(start: number, end: number, amount: number): number;
  60062. /**
  60063. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60064. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60065. * @param start start value
  60066. * @param end target value
  60067. * @param amount amount to lerp between
  60068. * @returns the lerped value
  60069. */
  60070. static LerpAngle(start: number, end: number, amount: number): number;
  60071. /**
  60072. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60073. * @param a start value
  60074. * @param b target value
  60075. * @param value value between a and b
  60076. * @returns the inverseLerp value
  60077. */
  60078. static InverseLerp(a: number, b: number, value: number): number;
  60079. /**
  60080. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60081. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60082. * @param value1 spline value
  60083. * @param tangent1 spline value
  60084. * @param value2 spline value
  60085. * @param tangent2 spline value
  60086. * @param amount input value
  60087. * @returns hermite result
  60088. */
  60089. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60090. /**
  60091. * Returns a random float number between and min and max values
  60092. * @param min min value of random
  60093. * @param max max value of random
  60094. * @returns random value
  60095. */
  60096. static RandomRange(min: number, max: number): number;
  60097. /**
  60098. * This function returns percentage of a number in a given range.
  60099. *
  60100. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60101. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60102. * @param number to convert to percentage
  60103. * @param min min range
  60104. * @param max max range
  60105. * @returns the percentage
  60106. */
  60107. static RangeToPercent(number: number, min: number, max: number): number;
  60108. /**
  60109. * This function returns number that corresponds to the percentage in a given range.
  60110. *
  60111. * PercentToRange(0.34,0,100) will return 34.
  60112. * @param percent to convert to number
  60113. * @param min min range
  60114. * @param max max range
  60115. * @returns the number
  60116. */
  60117. static PercentToRange(percent: number, min: number, max: number): number;
  60118. /**
  60119. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60120. * @param angle The angle to normalize in radian.
  60121. * @return The converted angle.
  60122. */
  60123. static NormalizeRadians(angle: number): number;
  60124. }
  60125. }
  60126. declare module BABYLON {
  60127. /**
  60128. * Constant used to convert a value to gamma space
  60129. * @ignorenaming
  60130. */
  60131. export const ToGammaSpace: number;
  60132. /**
  60133. * Constant used to convert a value to linear space
  60134. * @ignorenaming
  60135. */
  60136. export const ToLinearSpace = 2.2;
  60137. /**
  60138. * Constant used to define the minimal number value in Babylon.js
  60139. * @ignorenaming
  60140. */
  60141. let Epsilon: number;
  60142. /**
  60143. * Class used to hold a RBG color
  60144. */
  60145. export class Color3 {
  60146. /**
  60147. * Defines the red component (between 0 and 1, default is 0)
  60148. */
  60149. r: number;
  60150. /**
  60151. * Defines the green component (between 0 and 1, default is 0)
  60152. */
  60153. g: number;
  60154. /**
  60155. * Defines the blue component (between 0 and 1, default is 0)
  60156. */
  60157. b: number;
  60158. /**
  60159. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60160. * @param r defines the red component (between 0 and 1, default is 0)
  60161. * @param g defines the green component (between 0 and 1, default is 0)
  60162. * @param b defines the blue component (between 0 and 1, default is 0)
  60163. */
  60164. constructor(
  60165. /**
  60166. * Defines the red component (between 0 and 1, default is 0)
  60167. */
  60168. r?: number,
  60169. /**
  60170. * Defines the green component (between 0 and 1, default is 0)
  60171. */
  60172. g?: number,
  60173. /**
  60174. * Defines the blue component (between 0 and 1, default is 0)
  60175. */
  60176. b?: number);
  60177. /**
  60178. * Creates a string with the Color3 current values
  60179. * @returns the string representation of the Color3 object
  60180. */
  60181. toString(): string;
  60182. /**
  60183. * Returns the string "Color3"
  60184. * @returns "Color3"
  60185. */
  60186. getClassName(): string;
  60187. /**
  60188. * Compute the Color3 hash code
  60189. * @returns an unique number that can be used to hash Color3 objects
  60190. */
  60191. getHashCode(): number;
  60192. /**
  60193. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60194. * @param array defines the array where to store the r,g,b components
  60195. * @param index defines an optional index in the target array to define where to start storing values
  60196. * @returns the current Color3 object
  60197. */
  60198. toArray(array: FloatArray, index?: number): Color3;
  60199. /**
  60200. * Returns a new Color4 object from the current Color3 and the given alpha
  60201. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60202. * @returns a new Color4 object
  60203. */
  60204. toColor4(alpha?: number): Color4;
  60205. /**
  60206. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60207. * @returns the new array
  60208. */
  60209. asArray(): number[];
  60210. /**
  60211. * Returns the luminance value
  60212. * @returns a float value
  60213. */
  60214. toLuminance(): number;
  60215. /**
  60216. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60217. * @param otherColor defines the second operand
  60218. * @returns the new Color3 object
  60219. */
  60220. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60221. /**
  60222. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60223. * @param otherColor defines the second operand
  60224. * @param result defines the Color3 object where to store the result
  60225. * @returns the current Color3
  60226. */
  60227. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60228. /**
  60229. * Determines equality between Color3 objects
  60230. * @param otherColor defines the second operand
  60231. * @returns true if the rgb values are equal to the given ones
  60232. */
  60233. equals(otherColor: DeepImmutable<Color3>): boolean;
  60234. /**
  60235. * Determines equality between the current Color3 object and a set of r,b,g values
  60236. * @param r defines the red component to check
  60237. * @param g defines the green component to check
  60238. * @param b defines the blue component to check
  60239. * @returns true if the rgb values are equal to the given ones
  60240. */
  60241. equalsFloats(r: number, g: number, b: number): boolean;
  60242. /**
  60243. * Multiplies in place each rgb value by scale
  60244. * @param scale defines the scaling factor
  60245. * @returns the updated Color3
  60246. */
  60247. scale(scale: number): Color3;
  60248. /**
  60249. * Multiplies the rgb values by scale and stores the result into "result"
  60250. * @param scale defines the scaling factor
  60251. * @param result defines the Color3 object where to store the result
  60252. * @returns the unmodified current Color3
  60253. */
  60254. scaleToRef(scale: number, result: Color3): Color3;
  60255. /**
  60256. * Scale the current Color3 values by a factor and add the result to a given Color3
  60257. * @param scale defines the scale factor
  60258. * @param result defines color to store the result into
  60259. * @returns the unmodified current Color3
  60260. */
  60261. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60262. /**
  60263. * Clamps the rgb values by the min and max values and stores the result into "result"
  60264. * @param min defines minimum clamping value (default is 0)
  60265. * @param max defines maximum clamping value (default is 1)
  60266. * @param result defines color to store the result into
  60267. * @returns the original Color3
  60268. */
  60269. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60270. /**
  60271. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60272. * @param otherColor defines the second operand
  60273. * @returns the new Color3
  60274. */
  60275. add(otherColor: DeepImmutable<Color3>): Color3;
  60276. /**
  60277. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60278. * @param otherColor defines the second operand
  60279. * @param result defines Color3 object to store the result into
  60280. * @returns the unmodified current Color3
  60281. */
  60282. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60283. /**
  60284. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60285. * @param otherColor defines the second operand
  60286. * @returns the new Color3
  60287. */
  60288. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60289. /**
  60290. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60291. * @param otherColor defines the second operand
  60292. * @param result defines Color3 object to store the result into
  60293. * @returns the unmodified current Color3
  60294. */
  60295. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60296. /**
  60297. * Copy the current object
  60298. * @returns a new Color3 copied the current one
  60299. */
  60300. clone(): Color3;
  60301. /**
  60302. * Copies the rgb values from the source in the current Color3
  60303. * @param source defines the source Color3 object
  60304. * @returns the updated Color3 object
  60305. */
  60306. copyFrom(source: DeepImmutable<Color3>): Color3;
  60307. /**
  60308. * Updates the Color3 rgb values from the given floats
  60309. * @param r defines the red component to read from
  60310. * @param g defines the green component to read from
  60311. * @param b defines the blue component to read from
  60312. * @returns the current Color3 object
  60313. */
  60314. copyFromFloats(r: number, g: number, b: number): Color3;
  60315. /**
  60316. * Updates the Color3 rgb values from the given floats
  60317. * @param r defines the red component to read from
  60318. * @param g defines the green component to read from
  60319. * @param b defines the blue component to read from
  60320. * @returns the current Color3 object
  60321. */
  60322. set(r: number, g: number, b: number): Color3;
  60323. /**
  60324. * Compute the Color3 hexadecimal code as a string
  60325. * @returns a string containing the hexadecimal representation of the Color3 object
  60326. */
  60327. toHexString(): string;
  60328. /**
  60329. * Computes a new Color3 converted from the current one to linear space
  60330. * @returns a new Color3 object
  60331. */
  60332. toLinearSpace(): Color3;
  60333. /**
  60334. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60335. * @param convertedColor defines the Color3 object where to store the linear space version
  60336. * @returns the unmodified Color3
  60337. */
  60338. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60339. /**
  60340. * Computes a new Color3 converted from the current one to gamma space
  60341. * @returns a new Color3 object
  60342. */
  60343. toGammaSpace(): Color3;
  60344. /**
  60345. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60346. * @param convertedColor defines the Color3 object where to store the gamma space version
  60347. * @returns the unmodified Color3
  60348. */
  60349. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60350. private static _BlackReadOnly;
  60351. /**
  60352. * Creates a new Color3 from the string containing valid hexadecimal values
  60353. * @param hex defines a string containing valid hexadecimal values
  60354. * @returns a new Color3 object
  60355. */
  60356. static FromHexString(hex: string): Color3;
  60357. /**
  60358. * Creates a new Color3 from the starting index of the given array
  60359. * @param array defines the source array
  60360. * @param offset defines an offset in the source array
  60361. * @returns a new Color3 object
  60362. */
  60363. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60364. /**
  60365. * Creates a new Color3 from integer values (< 256)
  60366. * @param r defines the red component to read from (value between 0 and 255)
  60367. * @param g defines the green component to read from (value between 0 and 255)
  60368. * @param b defines the blue component to read from (value between 0 and 255)
  60369. * @returns a new Color3 object
  60370. */
  60371. static FromInts(r: number, g: number, b: number): Color3;
  60372. /**
  60373. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60374. * @param start defines the start Color3 value
  60375. * @param end defines the end Color3 value
  60376. * @param amount defines the gradient value between start and end
  60377. * @returns a new Color3 object
  60378. */
  60379. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60380. /**
  60381. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60382. * @param left defines the start value
  60383. * @param right defines the end value
  60384. * @param amount defines the gradient factor
  60385. * @param result defines the Color3 object where to store the result
  60386. */
  60387. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60388. /**
  60389. * Returns a Color3 value containing a red color
  60390. * @returns a new Color3 object
  60391. */
  60392. static Red(): Color3;
  60393. /**
  60394. * Returns a Color3 value containing a green color
  60395. * @returns a new Color3 object
  60396. */
  60397. static Green(): Color3;
  60398. /**
  60399. * Returns a Color3 value containing a blue color
  60400. * @returns a new Color3 object
  60401. */
  60402. static Blue(): Color3;
  60403. /**
  60404. * Returns a Color3 value containing a black color
  60405. * @returns a new Color3 object
  60406. */
  60407. static Black(): Color3;
  60408. /**
  60409. * Gets a Color3 value containing a black color that must not be updated
  60410. */
  60411. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60412. /**
  60413. * Returns a Color3 value containing a white color
  60414. * @returns a new Color3 object
  60415. */
  60416. static White(): Color3;
  60417. /**
  60418. * Returns a Color3 value containing a purple color
  60419. * @returns a new Color3 object
  60420. */
  60421. static Purple(): Color3;
  60422. /**
  60423. * Returns a Color3 value containing a magenta color
  60424. * @returns a new Color3 object
  60425. */
  60426. static Magenta(): Color3;
  60427. /**
  60428. * Returns a Color3 value containing a yellow color
  60429. * @returns a new Color3 object
  60430. */
  60431. static Yellow(): Color3;
  60432. /**
  60433. * Returns a Color3 value containing a gray color
  60434. * @returns a new Color3 object
  60435. */
  60436. static Gray(): Color3;
  60437. /**
  60438. * Returns a Color3 value containing a teal color
  60439. * @returns a new Color3 object
  60440. */
  60441. static Teal(): Color3;
  60442. /**
  60443. * Returns a Color3 value containing a random color
  60444. * @returns a new Color3 object
  60445. */
  60446. static Random(): Color3;
  60447. }
  60448. /**
  60449. * Class used to hold a RBGA color
  60450. */
  60451. export class Color4 {
  60452. /**
  60453. * Defines the red component (between 0 and 1, default is 0)
  60454. */
  60455. r: number;
  60456. /**
  60457. * Defines the green component (between 0 and 1, default is 0)
  60458. */
  60459. g: number;
  60460. /**
  60461. * Defines the blue component (between 0 and 1, default is 0)
  60462. */
  60463. b: number;
  60464. /**
  60465. * Defines the alpha component (between 0 and 1, default is 1)
  60466. */
  60467. a: number;
  60468. /**
  60469. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60470. * @param r defines the red component (between 0 and 1, default is 0)
  60471. * @param g defines the green component (between 0 and 1, default is 0)
  60472. * @param b defines the blue component (between 0 and 1, default is 0)
  60473. * @param a defines the alpha component (between 0 and 1, default is 1)
  60474. */
  60475. constructor(
  60476. /**
  60477. * Defines the red component (between 0 and 1, default is 0)
  60478. */
  60479. r?: number,
  60480. /**
  60481. * Defines the green component (between 0 and 1, default is 0)
  60482. */
  60483. g?: number,
  60484. /**
  60485. * Defines the blue component (between 0 and 1, default is 0)
  60486. */
  60487. b?: number,
  60488. /**
  60489. * Defines the alpha component (between 0 and 1, default is 1)
  60490. */
  60491. a?: number);
  60492. /**
  60493. * Adds in place the given Color4 values to the current Color4 object
  60494. * @param right defines the second operand
  60495. * @returns the current updated Color4 object
  60496. */
  60497. addInPlace(right: DeepImmutable<Color4>): Color4;
  60498. /**
  60499. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60500. * @returns the new array
  60501. */
  60502. asArray(): number[];
  60503. /**
  60504. * Stores from the starting index in the given array the Color4 successive values
  60505. * @param array defines the array where to store the r,g,b components
  60506. * @param index defines an optional index in the target array to define where to start storing values
  60507. * @returns the current Color4 object
  60508. */
  60509. toArray(array: number[], index?: number): Color4;
  60510. /**
  60511. * Determines equality between Color4 objects
  60512. * @param otherColor defines the second operand
  60513. * @returns true if the rgba values are equal to the given ones
  60514. */
  60515. equals(otherColor: DeepImmutable<Color4>): boolean;
  60516. /**
  60517. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60518. * @param right defines the second operand
  60519. * @returns a new Color4 object
  60520. */
  60521. add(right: DeepImmutable<Color4>): Color4;
  60522. /**
  60523. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60524. * @param right defines the second operand
  60525. * @returns a new Color4 object
  60526. */
  60527. subtract(right: DeepImmutable<Color4>): Color4;
  60528. /**
  60529. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60530. * @param right defines the second operand
  60531. * @param result defines the Color4 object where to store the result
  60532. * @returns the current Color4 object
  60533. */
  60534. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60535. /**
  60536. * Creates a new Color4 with the current Color4 values multiplied by scale
  60537. * @param scale defines the scaling factor to apply
  60538. * @returns a new Color4 object
  60539. */
  60540. scale(scale: number): Color4;
  60541. /**
  60542. * Multiplies the current Color4 values by scale and stores the result in "result"
  60543. * @param scale defines the scaling factor to apply
  60544. * @param result defines the Color4 object where to store the result
  60545. * @returns the current unmodified Color4
  60546. */
  60547. scaleToRef(scale: number, result: Color4): Color4;
  60548. /**
  60549. * Scale the current Color4 values by a factor and add the result to a given Color4
  60550. * @param scale defines the scale factor
  60551. * @param result defines the Color4 object where to store the result
  60552. * @returns the unmodified current Color4
  60553. */
  60554. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60555. /**
  60556. * Clamps the rgb values by the min and max values and stores the result into "result"
  60557. * @param min defines minimum clamping value (default is 0)
  60558. * @param max defines maximum clamping value (default is 1)
  60559. * @param result defines color to store the result into.
  60560. * @returns the cuurent Color4
  60561. */
  60562. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60563. /**
  60564. * Multipy an Color4 value by another and return a new Color4 object
  60565. * @param color defines the Color4 value to multiply by
  60566. * @returns a new Color4 object
  60567. */
  60568. multiply(color: Color4): Color4;
  60569. /**
  60570. * Multipy a Color4 value by another and push the result in a reference value
  60571. * @param color defines the Color4 value to multiply by
  60572. * @param result defines the Color4 to fill the result in
  60573. * @returns the result Color4
  60574. */
  60575. multiplyToRef(color: Color4, result: Color4): Color4;
  60576. /**
  60577. * Creates a string with the Color4 current values
  60578. * @returns the string representation of the Color4 object
  60579. */
  60580. toString(): string;
  60581. /**
  60582. * Returns the string "Color4"
  60583. * @returns "Color4"
  60584. */
  60585. getClassName(): string;
  60586. /**
  60587. * Compute the Color4 hash code
  60588. * @returns an unique number that can be used to hash Color4 objects
  60589. */
  60590. getHashCode(): number;
  60591. /**
  60592. * Creates a new Color4 copied from the current one
  60593. * @returns a new Color4 object
  60594. */
  60595. clone(): Color4;
  60596. /**
  60597. * Copies the given Color4 values into the current one
  60598. * @param source defines the source Color4 object
  60599. * @returns the current updated Color4 object
  60600. */
  60601. copyFrom(source: Color4): Color4;
  60602. /**
  60603. * Copies the given float values into the current one
  60604. * @param r defines the red component to read from
  60605. * @param g defines the green component to read from
  60606. * @param b defines the blue component to read from
  60607. * @param a defines the alpha component to read from
  60608. * @returns the current updated Color4 object
  60609. */
  60610. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60611. /**
  60612. * Copies the given float values into the current one
  60613. * @param r defines the red component to read from
  60614. * @param g defines the green component to read from
  60615. * @param b defines the blue component to read from
  60616. * @param a defines the alpha component to read from
  60617. * @returns the current updated Color4 object
  60618. */
  60619. set(r: number, g: number, b: number, a: number): Color4;
  60620. /**
  60621. * Compute the Color4 hexadecimal code as a string
  60622. * @returns a string containing the hexadecimal representation of the Color4 object
  60623. */
  60624. toHexString(): string;
  60625. /**
  60626. * Computes a new Color4 converted from the current one to linear space
  60627. * @returns a new Color4 object
  60628. */
  60629. toLinearSpace(): Color4;
  60630. /**
  60631. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60632. * @param convertedColor defines the Color4 object where to store the linear space version
  60633. * @returns the unmodified Color4
  60634. */
  60635. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60636. /**
  60637. * Computes a new Color4 converted from the current one to gamma space
  60638. * @returns a new Color4 object
  60639. */
  60640. toGammaSpace(): Color4;
  60641. /**
  60642. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60643. * @param convertedColor defines the Color4 object where to store the gamma space version
  60644. * @returns the unmodified Color4
  60645. */
  60646. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60647. /**
  60648. * Creates a new Color4 from the string containing valid hexadecimal values
  60649. * @param hex defines a string containing valid hexadecimal values
  60650. * @returns a new Color4 object
  60651. */
  60652. static FromHexString(hex: string): Color4;
  60653. /**
  60654. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60655. * @param left defines the start value
  60656. * @param right defines the end value
  60657. * @param amount defines the gradient factor
  60658. * @returns a new Color4 object
  60659. */
  60660. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60661. /**
  60662. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60663. * @param left defines the start value
  60664. * @param right defines the end value
  60665. * @param amount defines the gradient factor
  60666. * @param result defines the Color4 object where to store data
  60667. */
  60668. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60669. /**
  60670. * Creates a new Color4 from a Color3 and an alpha value
  60671. * @param color3 defines the source Color3 to read from
  60672. * @param alpha defines the alpha component (1.0 by default)
  60673. * @returns a new Color4 object
  60674. */
  60675. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60676. /**
  60677. * Creates a new Color4 from the starting index element of the given array
  60678. * @param array defines the source array to read from
  60679. * @param offset defines the offset in the source array
  60680. * @returns a new Color4 object
  60681. */
  60682. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60683. /**
  60684. * Creates a new Color3 from integer values (< 256)
  60685. * @param r defines the red component to read from (value between 0 and 255)
  60686. * @param g defines the green component to read from (value between 0 and 255)
  60687. * @param b defines the blue component to read from (value between 0 and 255)
  60688. * @param a defines the alpha component to read from (value between 0 and 255)
  60689. * @returns a new Color3 object
  60690. */
  60691. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60692. /**
  60693. * Check the content of a given array and convert it to an array containing RGBA data
  60694. * If the original array was already containing count * 4 values then it is returned directly
  60695. * @param colors defines the array to check
  60696. * @param count defines the number of RGBA data to expect
  60697. * @returns an array containing count * 4 values (RGBA)
  60698. */
  60699. static CheckColors4(colors: number[], count: number): number[];
  60700. }
  60701. /**
  60702. * Class representing a vector containing 2 coordinates
  60703. */
  60704. export class Vector2 {
  60705. /** defines the first coordinate */
  60706. x: number;
  60707. /** defines the second coordinate */
  60708. y: number;
  60709. /**
  60710. * Creates a new Vector2 from the given x and y coordinates
  60711. * @param x defines the first coordinate
  60712. * @param y defines the second coordinate
  60713. */
  60714. constructor(
  60715. /** defines the first coordinate */
  60716. x?: number,
  60717. /** defines the second coordinate */
  60718. y?: number);
  60719. /**
  60720. * Gets a string with the Vector2 coordinates
  60721. * @returns a string with the Vector2 coordinates
  60722. */
  60723. toString(): string;
  60724. /**
  60725. * Gets class name
  60726. * @returns the string "Vector2"
  60727. */
  60728. getClassName(): string;
  60729. /**
  60730. * Gets current vector hash code
  60731. * @returns the Vector2 hash code as a number
  60732. */
  60733. getHashCode(): number;
  60734. /**
  60735. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60736. * @param array defines the source array
  60737. * @param index defines the offset in source array
  60738. * @returns the current Vector2
  60739. */
  60740. toArray(array: FloatArray, index?: number): Vector2;
  60741. /**
  60742. * Copy the current vector to an array
  60743. * @returns a new array with 2 elements: the Vector2 coordinates.
  60744. */
  60745. asArray(): number[];
  60746. /**
  60747. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60748. * @param source defines the source Vector2
  60749. * @returns the current updated Vector2
  60750. */
  60751. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60752. /**
  60753. * Sets the Vector2 coordinates with the given floats
  60754. * @param x defines the first coordinate
  60755. * @param y defines the second coordinate
  60756. * @returns the current updated Vector2
  60757. */
  60758. copyFromFloats(x: number, y: number): Vector2;
  60759. /**
  60760. * Sets the Vector2 coordinates with the given floats
  60761. * @param x defines the first coordinate
  60762. * @param y defines the second coordinate
  60763. * @returns the current updated Vector2
  60764. */
  60765. set(x: number, y: number): Vector2;
  60766. /**
  60767. * Add another vector with the current one
  60768. * @param otherVector defines the other vector
  60769. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60770. */
  60771. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60772. /**
  60773. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60774. * @param otherVector defines the other vector
  60775. * @param result defines the target vector
  60776. * @returns the unmodified current Vector2
  60777. */
  60778. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60779. /**
  60780. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60781. * @param otherVector defines the other vector
  60782. * @returns the current updated Vector2
  60783. */
  60784. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60785. /**
  60786. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60787. * @param otherVector defines the other vector
  60788. * @returns a new Vector2
  60789. */
  60790. addVector3(otherVector: Vector3): Vector2;
  60791. /**
  60792. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60793. * @param otherVector defines the other vector
  60794. * @returns a new Vector2
  60795. */
  60796. subtract(otherVector: Vector2): Vector2;
  60797. /**
  60798. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60799. * @param otherVector defines the other vector
  60800. * @param result defines the target vector
  60801. * @returns the unmodified current Vector2
  60802. */
  60803. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60804. /**
  60805. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60806. * @param otherVector defines the other vector
  60807. * @returns the current updated Vector2
  60808. */
  60809. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60810. /**
  60811. * Multiplies in place the current Vector2 coordinates by the given ones
  60812. * @param otherVector defines the other vector
  60813. * @returns the current updated Vector2
  60814. */
  60815. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60816. /**
  60817. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60818. * @param otherVector defines the other vector
  60819. * @returns a new Vector2
  60820. */
  60821. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60822. /**
  60823. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60824. * @param otherVector defines the other vector
  60825. * @param result defines the target vector
  60826. * @returns the unmodified current Vector2
  60827. */
  60828. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60829. /**
  60830. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60831. * @param x defines the first coordinate
  60832. * @param y defines the second coordinate
  60833. * @returns a new Vector2
  60834. */
  60835. multiplyByFloats(x: number, y: number): Vector2;
  60836. /**
  60837. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60838. * @param otherVector defines the other vector
  60839. * @returns a new Vector2
  60840. */
  60841. divide(otherVector: Vector2): Vector2;
  60842. /**
  60843. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60844. * @param otherVector defines the other vector
  60845. * @param result defines the target vector
  60846. * @returns the unmodified current Vector2
  60847. */
  60848. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60849. /**
  60850. * Divides the current Vector2 coordinates by the given ones
  60851. * @param otherVector defines the other vector
  60852. * @returns the current updated Vector2
  60853. */
  60854. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60855. /**
  60856. * Gets a new Vector2 with current Vector2 negated coordinates
  60857. * @returns a new Vector2
  60858. */
  60859. negate(): Vector2;
  60860. /**
  60861. * Multiply the Vector2 coordinates by scale
  60862. * @param scale defines the scaling factor
  60863. * @returns the current updated Vector2
  60864. */
  60865. scaleInPlace(scale: number): Vector2;
  60866. /**
  60867. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60868. * @param scale defines the scaling factor
  60869. * @returns a new Vector2
  60870. */
  60871. scale(scale: number): Vector2;
  60872. /**
  60873. * Scale the current Vector2 values by a factor to a given Vector2
  60874. * @param scale defines the scale factor
  60875. * @param result defines the Vector2 object where to store the result
  60876. * @returns the unmodified current Vector2
  60877. */
  60878. scaleToRef(scale: number, result: Vector2): Vector2;
  60879. /**
  60880. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60881. * @param scale defines the scale factor
  60882. * @param result defines the Vector2 object where to store the result
  60883. * @returns the unmodified current Vector2
  60884. */
  60885. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60886. /**
  60887. * Gets a boolean if two vectors are equals
  60888. * @param otherVector defines the other vector
  60889. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60890. */
  60891. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60892. /**
  60893. * Gets a boolean if two vectors are equals (using an epsilon value)
  60894. * @param otherVector defines the other vector
  60895. * @param epsilon defines the minimal distance to consider equality
  60896. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60897. */
  60898. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60899. /**
  60900. * Gets a new Vector2 from current Vector2 floored values
  60901. * @returns a new Vector2
  60902. */
  60903. floor(): Vector2;
  60904. /**
  60905. * Gets a new Vector2 from current Vector2 floored values
  60906. * @returns a new Vector2
  60907. */
  60908. fract(): Vector2;
  60909. /**
  60910. * Gets the length of the vector
  60911. * @returns the vector length (float)
  60912. */
  60913. length(): number;
  60914. /**
  60915. * Gets the vector squared length
  60916. * @returns the vector squared length (float)
  60917. */
  60918. lengthSquared(): number;
  60919. /**
  60920. * Normalize the vector
  60921. * @returns the current updated Vector2
  60922. */
  60923. normalize(): Vector2;
  60924. /**
  60925. * Gets a new Vector2 copied from the Vector2
  60926. * @returns a new Vector2
  60927. */
  60928. clone(): Vector2;
  60929. /**
  60930. * Gets a new Vector2(0, 0)
  60931. * @returns a new Vector2
  60932. */
  60933. static Zero(): Vector2;
  60934. /**
  60935. * Gets a new Vector2(1, 1)
  60936. * @returns a new Vector2
  60937. */
  60938. static One(): Vector2;
  60939. /**
  60940. * Gets a new Vector2 set from the given index element of the given array
  60941. * @param array defines the data source
  60942. * @param offset defines the offset in the data source
  60943. * @returns a new Vector2
  60944. */
  60945. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60946. /**
  60947. * Sets "result" from the given index element of the given array
  60948. * @param array defines the data source
  60949. * @param offset defines the offset in the data source
  60950. * @param result defines the target vector
  60951. */
  60952. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60953. /**
  60954. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60955. * @param value1 defines 1st point of control
  60956. * @param value2 defines 2nd point of control
  60957. * @param value3 defines 3rd point of control
  60958. * @param value4 defines 4th point of control
  60959. * @param amount defines the interpolation factor
  60960. * @returns a new Vector2
  60961. */
  60962. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60963. /**
  60964. * 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".
  60965. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60966. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60967. * @param value defines the value to clamp
  60968. * @param min defines the lower limit
  60969. * @param max defines the upper limit
  60970. * @returns a new Vector2
  60971. */
  60972. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60973. /**
  60974. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60975. * @param value1 defines the 1st control point
  60976. * @param tangent1 defines the outgoing tangent
  60977. * @param value2 defines the 2nd control point
  60978. * @param tangent2 defines the incoming tangent
  60979. * @param amount defines the interpolation factor
  60980. * @returns a new Vector2
  60981. */
  60982. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60983. /**
  60984. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60985. * @param start defines the start vector
  60986. * @param end defines the end vector
  60987. * @param amount defines the interpolation factor
  60988. * @returns a new Vector2
  60989. */
  60990. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60991. /**
  60992. * Gets the dot product of the vector "left" and the vector "right"
  60993. * @param left defines first vector
  60994. * @param right defines second vector
  60995. * @returns the dot product (float)
  60996. */
  60997. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60998. /**
  60999. * Returns a new Vector2 equal to the normalized given vector
  61000. * @param vector defines the vector to normalize
  61001. * @returns a new Vector2
  61002. */
  61003. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61004. /**
  61005. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61006. * @param left defines 1st vector
  61007. * @param right defines 2nd vector
  61008. * @returns a new Vector2
  61009. */
  61010. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61011. /**
  61012. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61013. * @param left defines 1st vector
  61014. * @param right defines 2nd vector
  61015. * @returns a new Vector2
  61016. */
  61017. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61018. /**
  61019. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61020. * @param vector defines the vector to transform
  61021. * @param transformation defines the matrix to apply
  61022. * @returns a new Vector2
  61023. */
  61024. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61025. /**
  61026. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61027. * @param vector defines the vector to transform
  61028. * @param transformation defines the matrix to apply
  61029. * @param result defines the target vector
  61030. */
  61031. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61032. /**
  61033. * Determines if a given vector is included in a triangle
  61034. * @param p defines the vector to test
  61035. * @param p0 defines 1st triangle point
  61036. * @param p1 defines 2nd triangle point
  61037. * @param p2 defines 3rd triangle point
  61038. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61039. */
  61040. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61041. /**
  61042. * Gets the distance between the vectors "value1" and "value2"
  61043. * @param value1 defines first vector
  61044. * @param value2 defines second vector
  61045. * @returns the distance between vectors
  61046. */
  61047. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61048. /**
  61049. * Returns the squared distance between the vectors "value1" and "value2"
  61050. * @param value1 defines first vector
  61051. * @param value2 defines second vector
  61052. * @returns the squared distance between vectors
  61053. */
  61054. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61055. /**
  61056. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61057. * @param value1 defines first vector
  61058. * @param value2 defines second vector
  61059. * @returns a new Vector2
  61060. */
  61061. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61062. /**
  61063. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61064. * @param p defines the middle point
  61065. * @param segA defines one point of the segment
  61066. * @param segB defines the other point of the segment
  61067. * @returns the shortest distance
  61068. */
  61069. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61070. }
  61071. /**
  61072. * Classed used to store (x,y,z) vector representation
  61073. * A Vector3 is the main object used in 3D geometry
  61074. * It can represent etiher the coordinates of a point the space, either a direction
  61075. * Reminder: js uses a left handed forward facing system
  61076. */
  61077. export class Vector3 {
  61078. /**
  61079. * Defines the first coordinates (on X axis)
  61080. */
  61081. x: number;
  61082. /**
  61083. * Defines the second coordinates (on Y axis)
  61084. */
  61085. y: number;
  61086. /**
  61087. * Defines the third coordinates (on Z axis)
  61088. */
  61089. z: number;
  61090. private static _UpReadOnly;
  61091. /**
  61092. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61093. * @param x defines the first coordinates (on X axis)
  61094. * @param y defines the second coordinates (on Y axis)
  61095. * @param z defines the third coordinates (on Z axis)
  61096. */
  61097. constructor(
  61098. /**
  61099. * Defines the first coordinates (on X axis)
  61100. */
  61101. x?: number,
  61102. /**
  61103. * Defines the second coordinates (on Y axis)
  61104. */
  61105. y?: number,
  61106. /**
  61107. * Defines the third coordinates (on Z axis)
  61108. */
  61109. z?: number);
  61110. /**
  61111. * Creates a string representation of the Vector3
  61112. * @returns a string with the Vector3 coordinates.
  61113. */
  61114. toString(): string;
  61115. /**
  61116. * Gets the class name
  61117. * @returns the string "Vector3"
  61118. */
  61119. getClassName(): string;
  61120. /**
  61121. * Creates the Vector3 hash code
  61122. * @returns a number which tends to be unique between Vector3 instances
  61123. */
  61124. getHashCode(): number;
  61125. /**
  61126. * Creates an array containing three elements : the coordinates of the Vector3
  61127. * @returns a new array of numbers
  61128. */
  61129. asArray(): number[];
  61130. /**
  61131. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61132. * @param array defines the destination array
  61133. * @param index defines the offset in the destination array
  61134. * @returns the current Vector3
  61135. */
  61136. toArray(array: FloatArray, index?: number): Vector3;
  61137. /**
  61138. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61139. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61140. */
  61141. toQuaternion(): Quaternion;
  61142. /**
  61143. * Adds the given vector to the current Vector3
  61144. * @param otherVector defines the second operand
  61145. * @returns the current updated Vector3
  61146. */
  61147. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61148. /**
  61149. * Adds the given coordinates to the current Vector3
  61150. * @param x defines the x coordinate of the operand
  61151. * @param y defines the y coordinate of the operand
  61152. * @param z defines the z coordinate of the operand
  61153. * @returns the current updated Vector3
  61154. */
  61155. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61156. /**
  61157. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61158. * @param otherVector defines the second operand
  61159. * @returns the resulting Vector3
  61160. */
  61161. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61162. /**
  61163. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61164. * @param otherVector defines the second operand
  61165. * @param result defines the Vector3 object where to store the result
  61166. * @returns the current Vector3
  61167. */
  61168. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61169. /**
  61170. * Subtract the given vector from the current Vector3
  61171. * @param otherVector defines the second operand
  61172. * @returns the current updated Vector3
  61173. */
  61174. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61175. /**
  61176. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61177. * @param otherVector defines the second operand
  61178. * @returns the resulting Vector3
  61179. */
  61180. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61181. /**
  61182. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61183. * @param otherVector defines the second operand
  61184. * @param result defines the Vector3 object where to store the result
  61185. * @returns the current Vector3
  61186. */
  61187. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61188. /**
  61189. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61190. * @param x defines the x coordinate of the operand
  61191. * @param y defines the y coordinate of the operand
  61192. * @param z defines the z coordinate of the operand
  61193. * @returns the resulting Vector3
  61194. */
  61195. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61196. /**
  61197. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61198. * @param x defines the x coordinate of the operand
  61199. * @param y defines the y coordinate of the operand
  61200. * @param z defines the z coordinate of the operand
  61201. * @param result defines the Vector3 object where to store the result
  61202. * @returns the current Vector3
  61203. */
  61204. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61205. /**
  61206. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61207. * @returns a new Vector3
  61208. */
  61209. negate(): Vector3;
  61210. /**
  61211. * Multiplies the Vector3 coordinates by the float "scale"
  61212. * @param scale defines the multiplier factor
  61213. * @returns the current updated Vector3
  61214. */
  61215. scaleInPlace(scale: number): Vector3;
  61216. /**
  61217. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61218. * @param scale defines the multiplier factor
  61219. * @returns a new Vector3
  61220. */
  61221. scale(scale: number): Vector3;
  61222. /**
  61223. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61224. * @param scale defines the multiplier factor
  61225. * @param result defines the Vector3 object where to store the result
  61226. * @returns the current Vector3
  61227. */
  61228. scaleToRef(scale: number, result: Vector3): Vector3;
  61229. /**
  61230. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61231. * @param scale defines the scale factor
  61232. * @param result defines the Vector3 object where to store the result
  61233. * @returns the unmodified current Vector3
  61234. */
  61235. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61236. /**
  61237. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61238. * @param otherVector defines the second operand
  61239. * @returns true if both vectors are equals
  61240. */
  61241. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61242. /**
  61243. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61244. * @param otherVector defines the second operand
  61245. * @param epsilon defines the minimal distance to define values as equals
  61246. * @returns true if both vectors are distant less than epsilon
  61247. */
  61248. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61249. /**
  61250. * Returns true if the current Vector3 coordinates equals the given floats
  61251. * @param x defines the x coordinate of the operand
  61252. * @param y defines the y coordinate of the operand
  61253. * @param z defines the z coordinate of the operand
  61254. * @returns true if both vectors are equals
  61255. */
  61256. equalsToFloats(x: number, y: number, z: number): boolean;
  61257. /**
  61258. * Multiplies the current Vector3 coordinates by the given ones
  61259. * @param otherVector defines the second operand
  61260. * @returns the current updated Vector3
  61261. */
  61262. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61263. /**
  61264. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61265. * @param otherVector defines the second operand
  61266. * @returns the new Vector3
  61267. */
  61268. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61269. /**
  61270. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61271. * @param otherVector defines the second operand
  61272. * @param result defines the Vector3 object where to store the result
  61273. * @returns the current Vector3
  61274. */
  61275. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61276. /**
  61277. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61278. * @param x defines the x coordinate of the operand
  61279. * @param y defines the y coordinate of the operand
  61280. * @param z defines the z coordinate of the operand
  61281. * @returns the new Vector3
  61282. */
  61283. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61284. /**
  61285. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61286. * @param otherVector defines the second operand
  61287. * @returns the new Vector3
  61288. */
  61289. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61290. /**
  61291. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61292. * @param otherVector defines the second operand
  61293. * @param result defines the Vector3 object where to store the result
  61294. * @returns the current Vector3
  61295. */
  61296. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61297. /**
  61298. * Divides the current Vector3 coordinates by the given ones.
  61299. * @param otherVector defines the second operand
  61300. * @returns the current updated Vector3
  61301. */
  61302. divideInPlace(otherVector: Vector3): Vector3;
  61303. /**
  61304. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61305. * @param other defines the second operand
  61306. * @returns the current updated Vector3
  61307. */
  61308. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61309. /**
  61310. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61311. * @param other defines the second operand
  61312. * @returns the current updated Vector3
  61313. */
  61314. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61315. /**
  61316. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61317. * @param x defines the x coordinate of the operand
  61318. * @param y defines the y coordinate of the operand
  61319. * @param z defines the z coordinate of the operand
  61320. * @returns the current updated Vector3
  61321. */
  61322. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61323. /**
  61324. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61325. * @param x defines the x coordinate of the operand
  61326. * @param y defines the y coordinate of the operand
  61327. * @param z defines the z coordinate of the operand
  61328. * @returns the current updated Vector3
  61329. */
  61330. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61331. /**
  61332. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61333. * Check if is non uniform within a certain amount of decimal places to account for this
  61334. * @param epsilon the amount the values can differ
  61335. * @returns if the the vector is non uniform to a certain number of decimal places
  61336. */
  61337. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61338. /**
  61339. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61340. */
  61341. readonly isNonUniform: boolean;
  61342. /**
  61343. * Gets a new Vector3 from current Vector3 floored values
  61344. * @returns a new Vector3
  61345. */
  61346. floor(): Vector3;
  61347. /**
  61348. * Gets a new Vector3 from current Vector3 floored values
  61349. * @returns a new Vector3
  61350. */
  61351. fract(): Vector3;
  61352. /**
  61353. * Gets the length of the Vector3
  61354. * @returns the length of the Vecto3
  61355. */
  61356. length(): number;
  61357. /**
  61358. * Gets the squared length of the Vector3
  61359. * @returns squared length of the Vector3
  61360. */
  61361. lengthSquared(): number;
  61362. /**
  61363. * Normalize the current Vector3.
  61364. * Please note that this is an in place operation.
  61365. * @returns the current updated Vector3
  61366. */
  61367. normalize(): Vector3;
  61368. /**
  61369. * Reorders the x y z properties of the vector in place
  61370. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61371. * @returns the current updated vector
  61372. */
  61373. reorderInPlace(order: string): this;
  61374. /**
  61375. * Rotates the vector around 0,0,0 by a quaternion
  61376. * @param quaternion the rotation quaternion
  61377. * @param result vector to store the result
  61378. * @returns the resulting vector
  61379. */
  61380. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61381. /**
  61382. * Rotates a vector around a given point
  61383. * @param quaternion the rotation quaternion
  61384. * @param point the point to rotate around
  61385. * @param result vector to store the result
  61386. * @returns the resulting vector
  61387. */
  61388. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61389. /**
  61390. * Normalize the current Vector3 with the given input length.
  61391. * Please note that this is an in place operation.
  61392. * @param len the length of the vector
  61393. * @returns the current updated Vector3
  61394. */
  61395. normalizeFromLength(len: number): Vector3;
  61396. /**
  61397. * Normalize the current Vector3 to a new vector
  61398. * @returns the new Vector3
  61399. */
  61400. normalizeToNew(): Vector3;
  61401. /**
  61402. * Normalize the current Vector3 to the reference
  61403. * @param reference define the Vector3 to update
  61404. * @returns the updated Vector3
  61405. */
  61406. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61407. /**
  61408. * Creates a new Vector3 copied from the current Vector3
  61409. * @returns the new Vector3
  61410. */
  61411. clone(): Vector3;
  61412. /**
  61413. * Copies the given vector coordinates to the current Vector3 ones
  61414. * @param source defines the source Vector3
  61415. * @returns the current updated Vector3
  61416. */
  61417. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61418. /**
  61419. * Copies the given floats to the current Vector3 coordinates
  61420. * @param x defines the x coordinate of the operand
  61421. * @param y defines the y coordinate of the operand
  61422. * @param z defines the z coordinate of the operand
  61423. * @returns the current updated Vector3
  61424. */
  61425. copyFromFloats(x: number, y: number, z: number): Vector3;
  61426. /**
  61427. * Copies the given floats to the current Vector3 coordinates
  61428. * @param x defines the x coordinate of the operand
  61429. * @param y defines the y coordinate of the operand
  61430. * @param z defines the z coordinate of the operand
  61431. * @returns the current updated Vector3
  61432. */
  61433. set(x: number, y: number, z: number): Vector3;
  61434. /**
  61435. * Copies the given float to the current Vector3 coordinates
  61436. * @param v defines the x, y and z coordinates of the operand
  61437. * @returns the current updated Vector3
  61438. */
  61439. setAll(v: number): Vector3;
  61440. /**
  61441. * Get the clip factor between two vectors
  61442. * @param vector0 defines the first operand
  61443. * @param vector1 defines the second operand
  61444. * @param axis defines the axis to use
  61445. * @param size defines the size along the axis
  61446. * @returns the clip factor
  61447. */
  61448. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61449. /**
  61450. * Get angle between two vectors
  61451. * @param vector0 angle between vector0 and vector1
  61452. * @param vector1 angle between vector0 and vector1
  61453. * @param normal direction of the normal
  61454. * @return the angle between vector0 and vector1
  61455. */
  61456. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61457. /**
  61458. * Returns a new Vector3 set from the index "offset" of the given array
  61459. * @param array defines the source array
  61460. * @param offset defines the offset in the source array
  61461. * @returns the new Vector3
  61462. */
  61463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61464. /**
  61465. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61466. * This function is deprecated. Use FromArray instead
  61467. * @param array defines the source array
  61468. * @param offset defines the offset in the source array
  61469. * @returns the new Vector3
  61470. */
  61471. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61472. /**
  61473. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61474. * @param array defines the source array
  61475. * @param offset defines the offset in the source array
  61476. * @param result defines the Vector3 where to store the result
  61477. */
  61478. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61479. /**
  61480. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61481. * This function is deprecated. Use FromArrayToRef instead.
  61482. * @param array defines the source array
  61483. * @param offset defines the offset in the source array
  61484. * @param result defines the Vector3 where to store the result
  61485. */
  61486. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61487. /**
  61488. * Sets the given vector "result" with the given floats.
  61489. * @param x defines the x coordinate of the source
  61490. * @param y defines the y coordinate of the source
  61491. * @param z defines the z coordinate of the source
  61492. * @param result defines the Vector3 where to store the result
  61493. */
  61494. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61495. /**
  61496. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61497. * @returns a new empty Vector3
  61498. */
  61499. static Zero(): Vector3;
  61500. /**
  61501. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61502. * @returns a new unit Vector3
  61503. */
  61504. static One(): Vector3;
  61505. /**
  61506. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61507. * @returns a new up Vector3
  61508. */
  61509. static Up(): Vector3;
  61510. /**
  61511. * Gets a up Vector3 that must not be updated
  61512. */
  61513. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61514. /**
  61515. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61516. * @returns a new down Vector3
  61517. */
  61518. static Down(): Vector3;
  61519. /**
  61520. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61521. * @returns a new forward Vector3
  61522. */
  61523. static Forward(): Vector3;
  61524. /**
  61525. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61526. * @returns a new forward Vector3
  61527. */
  61528. static Backward(): Vector3;
  61529. /**
  61530. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61531. * @returns a new right Vector3
  61532. */
  61533. static Right(): Vector3;
  61534. /**
  61535. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61536. * @returns a new left Vector3
  61537. */
  61538. static Left(): Vector3;
  61539. /**
  61540. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61541. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61542. * @param vector defines the Vector3 to transform
  61543. * @param transformation defines the transformation matrix
  61544. * @returns the transformed Vector3
  61545. */
  61546. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61547. /**
  61548. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61549. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61550. * @param vector defines the Vector3 to transform
  61551. * @param transformation defines the transformation matrix
  61552. * @param result defines the Vector3 where to store the result
  61553. */
  61554. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61555. /**
  61556. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61557. * This method computes tranformed coordinates only, not transformed direction vectors
  61558. * @param x define the x coordinate of the source vector
  61559. * @param y define the y coordinate of the source vector
  61560. * @param z define the z coordinate of the source vector
  61561. * @param transformation defines the transformation matrix
  61562. * @param result defines the Vector3 where to store the result
  61563. */
  61564. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61565. /**
  61566. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61567. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61568. * @param vector defines the Vector3 to transform
  61569. * @param transformation defines the transformation matrix
  61570. * @returns the new Vector3
  61571. */
  61572. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61573. /**
  61574. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61575. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61576. * @param vector defines the Vector3 to transform
  61577. * @param transformation defines the transformation matrix
  61578. * @param result defines the Vector3 where to store the result
  61579. */
  61580. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61581. /**
  61582. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61583. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61584. * @param x define the x coordinate of the source vector
  61585. * @param y define the y coordinate of the source vector
  61586. * @param z define the z coordinate of the source vector
  61587. * @param transformation defines the transformation matrix
  61588. * @param result defines the Vector3 where to store the result
  61589. */
  61590. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61591. /**
  61592. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61593. * @param value1 defines the first control point
  61594. * @param value2 defines the second control point
  61595. * @param value3 defines the third control point
  61596. * @param value4 defines the fourth control point
  61597. * @param amount defines the amount on the spline to use
  61598. * @returns the new Vector3
  61599. */
  61600. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61601. /**
  61602. * 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"
  61603. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61604. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61605. * @param value defines the current value
  61606. * @param min defines the lower range value
  61607. * @param max defines the upper range value
  61608. * @returns the new Vector3
  61609. */
  61610. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61611. /**
  61612. * 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"
  61613. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61614. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61615. * @param value defines the current value
  61616. * @param min defines the lower range value
  61617. * @param max defines the upper range value
  61618. * @param result defines the Vector3 where to store the result
  61619. */
  61620. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61621. /**
  61622. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61623. * @param value1 defines the first control point
  61624. * @param tangent1 defines the first tangent vector
  61625. * @param value2 defines the second control point
  61626. * @param tangent2 defines the second tangent vector
  61627. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61628. * @returns the new Vector3
  61629. */
  61630. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61631. /**
  61632. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61633. * @param start defines the start value
  61634. * @param end defines the end value
  61635. * @param amount max defines amount between both (between 0 and 1)
  61636. * @returns the new Vector3
  61637. */
  61638. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61639. /**
  61640. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61641. * @param start defines the start value
  61642. * @param end defines the end value
  61643. * @param amount max defines amount between both (between 0 and 1)
  61644. * @param result defines the Vector3 where to store the result
  61645. */
  61646. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61647. /**
  61648. * Returns the dot product (float) between the vectors "left" and "right"
  61649. * @param left defines the left operand
  61650. * @param right defines the right operand
  61651. * @returns the dot product
  61652. */
  61653. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61654. /**
  61655. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61656. * The cross product is then orthogonal to both "left" and "right"
  61657. * @param left defines the left operand
  61658. * @param right defines the right operand
  61659. * @returns the cross product
  61660. */
  61661. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61662. /**
  61663. * Sets the given vector "result" with the cross product of "left" and "right"
  61664. * The cross product is then orthogonal to both "left" and "right"
  61665. * @param left defines the left operand
  61666. * @param right defines the right operand
  61667. * @param result defines the Vector3 where to store the result
  61668. */
  61669. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61670. /**
  61671. * Returns a new Vector3 as the normalization of the given vector
  61672. * @param vector defines the Vector3 to normalize
  61673. * @returns the new Vector3
  61674. */
  61675. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61676. /**
  61677. * Sets the given vector "result" with the normalization of the given first vector
  61678. * @param vector defines the Vector3 to normalize
  61679. * @param result defines the Vector3 where to store the result
  61680. */
  61681. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61682. /**
  61683. * Project a Vector3 onto screen space
  61684. * @param vector defines the Vector3 to project
  61685. * @param world defines the world matrix to use
  61686. * @param transform defines the transform (view x projection) matrix to use
  61687. * @param viewport defines the screen viewport to use
  61688. * @returns the new Vector3
  61689. */
  61690. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61691. /** @hidden */
  61692. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61693. /**
  61694. * Unproject from screen space to object space
  61695. * @param source defines the screen space Vector3 to use
  61696. * @param viewportWidth defines the current width of the viewport
  61697. * @param viewportHeight defines the current height of the viewport
  61698. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61699. * @param transform defines the transform (view x projection) matrix to use
  61700. * @returns the new Vector3
  61701. */
  61702. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61703. /**
  61704. * Unproject from screen space to object space
  61705. * @param source defines the screen space Vector3 to use
  61706. * @param viewportWidth defines the current width of the viewport
  61707. * @param viewportHeight defines the current height of the viewport
  61708. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61709. * @param view defines the view matrix to use
  61710. * @param projection defines the projection matrix to use
  61711. * @returns the new Vector3
  61712. */
  61713. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61714. /**
  61715. * Unproject from screen space to object space
  61716. * @param source defines the screen space Vector3 to use
  61717. * @param viewportWidth defines the current width of the viewport
  61718. * @param viewportHeight defines the current height of the viewport
  61719. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61720. * @param view defines the view matrix to use
  61721. * @param projection defines the projection matrix to use
  61722. * @param result defines the Vector3 where to store the result
  61723. */
  61724. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61725. /**
  61726. * Unproject from screen space to object space
  61727. * @param sourceX defines the screen space x coordinate to use
  61728. * @param sourceY defines the screen space y coordinate to use
  61729. * @param sourceZ defines the screen space z coordinate to use
  61730. * @param viewportWidth defines the current width of the viewport
  61731. * @param viewportHeight defines the current height of the viewport
  61732. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61733. * @param view defines the view matrix to use
  61734. * @param projection defines the projection matrix to use
  61735. * @param result defines the Vector3 where to store the result
  61736. */
  61737. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61738. /**
  61739. * Gets the minimal coordinate values between two Vector3
  61740. * @param left defines the first operand
  61741. * @param right defines the second operand
  61742. * @returns the new Vector3
  61743. */
  61744. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61745. /**
  61746. * Gets the maximal coordinate values between two Vector3
  61747. * @param left defines the first operand
  61748. * @param right defines the second operand
  61749. * @returns the new Vector3
  61750. */
  61751. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61752. /**
  61753. * Returns the distance between the vectors "value1" and "value2"
  61754. * @param value1 defines the first operand
  61755. * @param value2 defines the second operand
  61756. * @returns the distance
  61757. */
  61758. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61759. /**
  61760. * Returns the squared distance between the vectors "value1" and "value2"
  61761. * @param value1 defines the first operand
  61762. * @param value2 defines the second operand
  61763. * @returns the squared distance
  61764. */
  61765. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61766. /**
  61767. * Returns a new Vector3 located at the center between "value1" and "value2"
  61768. * @param value1 defines the first operand
  61769. * @param value2 defines the second operand
  61770. * @returns the new Vector3
  61771. */
  61772. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61773. /**
  61774. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61775. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61776. * to something in order to rotate it from its local system to the given target system
  61777. * Note: axis1, axis2 and axis3 are normalized during this operation
  61778. * @param axis1 defines the first axis
  61779. * @param axis2 defines the second axis
  61780. * @param axis3 defines the third axis
  61781. * @returns a new Vector3
  61782. */
  61783. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61784. /**
  61785. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61786. * @param axis1 defines the first axis
  61787. * @param axis2 defines the second axis
  61788. * @param axis3 defines the third axis
  61789. * @param ref defines the Vector3 where to store the result
  61790. */
  61791. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61792. }
  61793. /**
  61794. * Vector4 class created for EulerAngle class conversion to Quaternion
  61795. */
  61796. export class Vector4 {
  61797. /** x value of the vector */
  61798. x: number;
  61799. /** y value of the vector */
  61800. y: number;
  61801. /** z value of the vector */
  61802. z: number;
  61803. /** w value of the vector */
  61804. w: number;
  61805. /**
  61806. * Creates a Vector4 object from the given floats.
  61807. * @param x x value of the vector
  61808. * @param y y value of the vector
  61809. * @param z z value of the vector
  61810. * @param w w value of the vector
  61811. */
  61812. constructor(
  61813. /** x value of the vector */
  61814. x: number,
  61815. /** y value of the vector */
  61816. y: number,
  61817. /** z value of the vector */
  61818. z: number,
  61819. /** w value of the vector */
  61820. w: number);
  61821. /**
  61822. * Returns the string with the Vector4 coordinates.
  61823. * @returns a string containing all the vector values
  61824. */
  61825. toString(): string;
  61826. /**
  61827. * Returns the string "Vector4".
  61828. * @returns "Vector4"
  61829. */
  61830. getClassName(): string;
  61831. /**
  61832. * Returns the Vector4 hash code.
  61833. * @returns a unique hash code
  61834. */
  61835. getHashCode(): number;
  61836. /**
  61837. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61838. * @returns the resulting array
  61839. */
  61840. asArray(): number[];
  61841. /**
  61842. * Populates the given array from the given index with the Vector4 coordinates.
  61843. * @param array array to populate
  61844. * @param index index of the array to start at (default: 0)
  61845. * @returns the Vector4.
  61846. */
  61847. toArray(array: FloatArray, index?: number): Vector4;
  61848. /**
  61849. * Adds the given vector to the current Vector4.
  61850. * @param otherVector the vector to add
  61851. * @returns the updated Vector4.
  61852. */
  61853. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61854. /**
  61855. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61856. * @param otherVector the vector to add
  61857. * @returns the resulting vector
  61858. */
  61859. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61860. /**
  61861. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61862. * @param otherVector the vector to add
  61863. * @param result the vector to store the result
  61864. * @returns the current Vector4.
  61865. */
  61866. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61867. /**
  61868. * Subtract in place the given vector from the current Vector4.
  61869. * @param otherVector the vector to subtract
  61870. * @returns the updated Vector4.
  61871. */
  61872. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61873. /**
  61874. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61875. * @param otherVector the vector to add
  61876. * @returns the new vector with the result
  61877. */
  61878. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61879. /**
  61880. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61881. * @param otherVector the vector to subtract
  61882. * @param result the vector to store the result
  61883. * @returns the current Vector4.
  61884. */
  61885. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61886. /**
  61887. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61888. */
  61889. /**
  61890. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61891. * @param x value to subtract
  61892. * @param y value to subtract
  61893. * @param z value to subtract
  61894. * @param w value to subtract
  61895. * @returns new vector containing the result
  61896. */
  61897. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61898. /**
  61899. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61900. * @param x value to subtract
  61901. * @param y value to subtract
  61902. * @param z value to subtract
  61903. * @param w value to subtract
  61904. * @param result the vector to store the result in
  61905. * @returns the current Vector4.
  61906. */
  61907. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61908. /**
  61909. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61910. * @returns a new vector with the negated values
  61911. */
  61912. negate(): Vector4;
  61913. /**
  61914. * Multiplies the current Vector4 coordinates by scale (float).
  61915. * @param scale the number to scale with
  61916. * @returns the updated Vector4.
  61917. */
  61918. scaleInPlace(scale: number): Vector4;
  61919. /**
  61920. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61921. * @param scale the number to scale with
  61922. * @returns a new vector with the result
  61923. */
  61924. scale(scale: number): Vector4;
  61925. /**
  61926. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61927. * @param scale the number to scale with
  61928. * @param result a vector to store the result in
  61929. * @returns the current Vector4.
  61930. */
  61931. scaleToRef(scale: number, result: Vector4): Vector4;
  61932. /**
  61933. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61934. * @param scale defines the scale factor
  61935. * @param result defines the Vector4 object where to store the result
  61936. * @returns the unmodified current Vector4
  61937. */
  61938. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61939. /**
  61940. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61941. * @param otherVector the vector to compare against
  61942. * @returns true if they are equal
  61943. */
  61944. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61945. /**
  61946. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61947. * @param otherVector vector to compare against
  61948. * @param epsilon (Default: very small number)
  61949. * @returns true if they are equal
  61950. */
  61951. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61952. /**
  61953. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61954. * @param x x value to compare against
  61955. * @param y y value to compare against
  61956. * @param z z value to compare against
  61957. * @param w w value to compare against
  61958. * @returns true if equal
  61959. */
  61960. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61961. /**
  61962. * Multiplies in place the current Vector4 by the given one.
  61963. * @param otherVector vector to multiple with
  61964. * @returns the updated Vector4.
  61965. */
  61966. multiplyInPlace(otherVector: Vector4): Vector4;
  61967. /**
  61968. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61969. * @param otherVector vector to multiple with
  61970. * @returns resulting new vector
  61971. */
  61972. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61973. /**
  61974. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61975. * @param otherVector vector to multiple with
  61976. * @param result vector to store the result
  61977. * @returns the current Vector4.
  61978. */
  61979. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61980. /**
  61981. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61982. * @param x x value multiply with
  61983. * @param y y value multiply with
  61984. * @param z z value multiply with
  61985. * @param w w value multiply with
  61986. * @returns resulting new vector
  61987. */
  61988. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61989. /**
  61990. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61991. * @param otherVector vector to devide with
  61992. * @returns resulting new vector
  61993. */
  61994. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61995. /**
  61996. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61997. * @param otherVector vector to devide with
  61998. * @param result vector to store the result
  61999. * @returns the current Vector4.
  62000. */
  62001. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62002. /**
  62003. * Divides the current Vector3 coordinates by the given ones.
  62004. * @param otherVector vector to devide with
  62005. * @returns the updated Vector3.
  62006. */
  62007. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62008. /**
  62009. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62010. * @param other defines the second operand
  62011. * @returns the current updated Vector4
  62012. */
  62013. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62014. /**
  62015. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62016. * @param other defines the second operand
  62017. * @returns the current updated Vector4
  62018. */
  62019. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62020. /**
  62021. * Gets a new Vector4 from current Vector4 floored values
  62022. * @returns a new Vector4
  62023. */
  62024. floor(): Vector4;
  62025. /**
  62026. * Gets a new Vector4 from current Vector3 floored values
  62027. * @returns a new Vector4
  62028. */
  62029. fract(): Vector4;
  62030. /**
  62031. * Returns the Vector4 length (float).
  62032. * @returns the length
  62033. */
  62034. length(): number;
  62035. /**
  62036. * Returns the Vector4 squared length (float).
  62037. * @returns the length squared
  62038. */
  62039. lengthSquared(): number;
  62040. /**
  62041. * Normalizes in place the Vector4.
  62042. * @returns the updated Vector4.
  62043. */
  62044. normalize(): Vector4;
  62045. /**
  62046. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62047. * @returns this converted to a new vector3
  62048. */
  62049. toVector3(): Vector3;
  62050. /**
  62051. * Returns a new Vector4 copied from the current one.
  62052. * @returns the new cloned vector
  62053. */
  62054. clone(): Vector4;
  62055. /**
  62056. * Updates the current Vector4 with the given one coordinates.
  62057. * @param source the source vector to copy from
  62058. * @returns the updated Vector4.
  62059. */
  62060. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62061. /**
  62062. * Updates the current Vector4 coordinates with the given floats.
  62063. * @param x float to copy from
  62064. * @param y float to copy from
  62065. * @param z float to copy from
  62066. * @param w float to copy from
  62067. * @returns the updated Vector4.
  62068. */
  62069. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62070. /**
  62071. * Updates the current Vector4 coordinates with the given floats.
  62072. * @param x float to set from
  62073. * @param y float to set from
  62074. * @param z float to set from
  62075. * @param w float to set from
  62076. * @returns the updated Vector4.
  62077. */
  62078. set(x: number, y: number, z: number, w: number): Vector4;
  62079. /**
  62080. * Copies the given float to the current Vector3 coordinates
  62081. * @param v defines the x, y, z and w coordinates of the operand
  62082. * @returns the current updated Vector3
  62083. */
  62084. setAll(v: number): Vector4;
  62085. /**
  62086. * Returns a new Vector4 set from the starting index of the given array.
  62087. * @param array the array to pull values from
  62088. * @param offset the offset into the array to start at
  62089. * @returns the new vector
  62090. */
  62091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62092. /**
  62093. * Updates the given vector "result" from the starting index of the given array.
  62094. * @param array the array to pull values from
  62095. * @param offset the offset into the array to start at
  62096. * @param result the vector to store the result in
  62097. */
  62098. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62099. /**
  62100. * Updates the given vector "result" from the starting index of the given Float32Array.
  62101. * @param array the array to pull values from
  62102. * @param offset the offset into the array to start at
  62103. * @param result the vector to store the result in
  62104. */
  62105. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62106. /**
  62107. * Updates the given vector "result" coordinates from the given floats.
  62108. * @param x float to set from
  62109. * @param y float to set from
  62110. * @param z float to set from
  62111. * @param w float to set from
  62112. * @param result the vector to the floats in
  62113. */
  62114. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62115. /**
  62116. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62117. * @returns the new vector
  62118. */
  62119. static Zero(): Vector4;
  62120. /**
  62121. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62122. * @returns the new vector
  62123. */
  62124. static One(): Vector4;
  62125. /**
  62126. * Returns a new normalized Vector4 from the given one.
  62127. * @param vector the vector to normalize
  62128. * @returns the vector
  62129. */
  62130. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62131. /**
  62132. * Updates the given vector "result" from the normalization of the given one.
  62133. * @param vector the vector to normalize
  62134. * @param result the vector to store the result in
  62135. */
  62136. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62137. /**
  62138. * Returns a vector with the minimum values from the left and right vectors
  62139. * @param left left vector to minimize
  62140. * @param right right vector to minimize
  62141. * @returns a new vector with the minimum of the left and right vector values
  62142. */
  62143. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62144. /**
  62145. * Returns a vector with the maximum values from the left and right vectors
  62146. * @param left left vector to maximize
  62147. * @param right right vector to maximize
  62148. * @returns a new vector with the maximum of the left and right vector values
  62149. */
  62150. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62151. /**
  62152. * Returns the distance (float) between the vectors "value1" and "value2".
  62153. * @param value1 value to calulate the distance between
  62154. * @param value2 value to calulate the distance between
  62155. * @return the distance between the two vectors
  62156. */
  62157. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62158. /**
  62159. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62160. * @param value1 value to calulate the distance between
  62161. * @param value2 value to calulate the distance between
  62162. * @return the distance between the two vectors squared
  62163. */
  62164. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62165. /**
  62166. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62167. * @param value1 value to calulate the center between
  62168. * @param value2 value to calulate the center between
  62169. * @return the center between the two vectors
  62170. */
  62171. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62172. /**
  62173. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62174. * This methods computes transformed normalized direction vectors only.
  62175. * @param vector the vector to transform
  62176. * @param transformation the transformation matrix to apply
  62177. * @returns the new vector
  62178. */
  62179. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62180. /**
  62181. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62182. * This methods computes transformed normalized direction vectors only.
  62183. * @param vector the vector to transform
  62184. * @param transformation the transformation matrix to apply
  62185. * @param result the vector to store the result in
  62186. */
  62187. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62188. /**
  62189. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62190. * This methods computes transformed normalized direction vectors only.
  62191. * @param x value to transform
  62192. * @param y value to transform
  62193. * @param z value to transform
  62194. * @param w value to transform
  62195. * @param transformation the transformation matrix to apply
  62196. * @param result the vector to store the results in
  62197. */
  62198. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62199. /**
  62200. * Creates a new Vector4 from a Vector3
  62201. * @param source defines the source data
  62202. * @param w defines the 4th component (default is 0)
  62203. * @returns a new Vector4
  62204. */
  62205. static FromVector3(source: Vector3, w?: number): Vector4;
  62206. }
  62207. /**
  62208. * Interface for the size containing width and height
  62209. */
  62210. export interface ISize {
  62211. /**
  62212. * Width
  62213. */
  62214. width: number;
  62215. /**
  62216. * Heighht
  62217. */
  62218. height: number;
  62219. }
  62220. /**
  62221. * Size containing widht and height
  62222. */
  62223. export class Size implements ISize {
  62224. /**
  62225. * Width
  62226. */
  62227. width: number;
  62228. /**
  62229. * Height
  62230. */
  62231. height: number;
  62232. /**
  62233. * Creates a Size object from the given width and height (floats).
  62234. * @param width width of the new size
  62235. * @param height height of the new size
  62236. */
  62237. constructor(width: number, height: number);
  62238. /**
  62239. * Returns a string with the Size width and height
  62240. * @returns a string with the Size width and height
  62241. */
  62242. toString(): string;
  62243. /**
  62244. * "Size"
  62245. * @returns the string "Size"
  62246. */
  62247. getClassName(): string;
  62248. /**
  62249. * Returns the Size hash code.
  62250. * @returns a hash code for a unique width and height
  62251. */
  62252. getHashCode(): number;
  62253. /**
  62254. * Updates the current size from the given one.
  62255. * @param src the given size
  62256. */
  62257. copyFrom(src: Size): void;
  62258. /**
  62259. * Updates in place the current Size from the given floats.
  62260. * @param width width of the new size
  62261. * @param height height of the new size
  62262. * @returns the updated Size.
  62263. */
  62264. copyFromFloats(width: number, height: number): Size;
  62265. /**
  62266. * Updates in place the current Size from the given floats.
  62267. * @param width width to set
  62268. * @param height height to set
  62269. * @returns the updated Size.
  62270. */
  62271. set(width: number, height: number): Size;
  62272. /**
  62273. * Multiplies the width and height by numbers
  62274. * @param w factor to multiple the width by
  62275. * @param h factor to multiple the height by
  62276. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62277. */
  62278. multiplyByFloats(w: number, h: number): Size;
  62279. /**
  62280. * Clones the size
  62281. * @returns a new Size copied from the given one.
  62282. */
  62283. clone(): Size;
  62284. /**
  62285. * True if the current Size and the given one width and height are strictly equal.
  62286. * @param other the other size to compare against
  62287. * @returns True if the current Size and the given one width and height are strictly equal.
  62288. */
  62289. equals(other: Size): boolean;
  62290. /**
  62291. * The surface of the Size : width * height (float).
  62292. */
  62293. readonly surface: number;
  62294. /**
  62295. * Create a new size of zero
  62296. * @returns a new Size set to (0.0, 0.0)
  62297. */
  62298. static Zero(): Size;
  62299. /**
  62300. * Sums the width and height of two sizes
  62301. * @param otherSize size to add to this size
  62302. * @returns a new Size set as the addition result of the current Size and the given one.
  62303. */
  62304. add(otherSize: Size): Size;
  62305. /**
  62306. * Subtracts the width and height of two
  62307. * @param otherSize size to subtract to this size
  62308. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62309. */
  62310. subtract(otherSize: Size): Size;
  62311. /**
  62312. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62313. * @param start starting size to lerp between
  62314. * @param end end size to lerp between
  62315. * @param amount amount to lerp between the start and end values
  62316. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62317. */
  62318. static Lerp(start: Size, end: Size, amount: number): Size;
  62319. }
  62320. /**
  62321. * Class used to store quaternion data
  62322. * @see https://en.wikipedia.org/wiki/Quaternion
  62323. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62324. */
  62325. export class Quaternion {
  62326. /** defines the first component (0 by default) */
  62327. x: number;
  62328. /** defines the second component (0 by default) */
  62329. y: number;
  62330. /** defines the third component (0 by default) */
  62331. z: number;
  62332. /** defines the fourth component (1.0 by default) */
  62333. w: number;
  62334. /**
  62335. * Creates a new Quaternion from the given floats
  62336. * @param x defines the first component (0 by default)
  62337. * @param y defines the second component (0 by default)
  62338. * @param z defines the third component (0 by default)
  62339. * @param w defines the fourth component (1.0 by default)
  62340. */
  62341. constructor(
  62342. /** defines the first component (0 by default) */
  62343. x?: number,
  62344. /** defines the second component (0 by default) */
  62345. y?: number,
  62346. /** defines the third component (0 by default) */
  62347. z?: number,
  62348. /** defines the fourth component (1.0 by default) */
  62349. w?: number);
  62350. /**
  62351. * Gets a string representation for the current quaternion
  62352. * @returns a string with the Quaternion coordinates
  62353. */
  62354. toString(): string;
  62355. /**
  62356. * Gets the class name of the quaternion
  62357. * @returns the string "Quaternion"
  62358. */
  62359. getClassName(): string;
  62360. /**
  62361. * Gets a hash code for this quaternion
  62362. * @returns the quaternion hash code
  62363. */
  62364. getHashCode(): number;
  62365. /**
  62366. * Copy the quaternion to an array
  62367. * @returns a new array populated with 4 elements from the quaternion coordinates
  62368. */
  62369. asArray(): number[];
  62370. /**
  62371. * Check if two quaternions are equals
  62372. * @param otherQuaternion defines the second operand
  62373. * @return true if the current quaternion and the given one coordinates are strictly equals
  62374. */
  62375. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62376. /**
  62377. * Clone the current quaternion
  62378. * @returns a new quaternion copied from the current one
  62379. */
  62380. clone(): Quaternion;
  62381. /**
  62382. * Copy a quaternion to the current one
  62383. * @param other defines the other quaternion
  62384. * @returns the updated current quaternion
  62385. */
  62386. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62387. /**
  62388. * Updates the current quaternion with the given float coordinates
  62389. * @param x defines the x coordinate
  62390. * @param y defines the y coordinate
  62391. * @param z defines the z coordinate
  62392. * @param w defines the w coordinate
  62393. * @returns the updated current quaternion
  62394. */
  62395. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62396. /**
  62397. * Updates the current quaternion from the given float coordinates
  62398. * @param x defines the x coordinate
  62399. * @param y defines the y coordinate
  62400. * @param z defines the z coordinate
  62401. * @param w defines the w coordinate
  62402. * @returns the updated current quaternion
  62403. */
  62404. set(x: number, y: number, z: number, w: number): Quaternion;
  62405. /**
  62406. * Adds two quaternions
  62407. * @param other defines the second operand
  62408. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62409. */
  62410. add(other: DeepImmutable<Quaternion>): Quaternion;
  62411. /**
  62412. * Add a quaternion to the current one
  62413. * @param other defines the quaternion to add
  62414. * @returns the current quaternion
  62415. */
  62416. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62417. /**
  62418. * Subtract two quaternions
  62419. * @param other defines the second operand
  62420. * @returns a new quaternion as the subtraction result of the given one from the current one
  62421. */
  62422. subtract(other: Quaternion): Quaternion;
  62423. /**
  62424. * Multiplies the current quaternion by a scale factor
  62425. * @param value defines the scale factor
  62426. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62427. */
  62428. scale(value: number): Quaternion;
  62429. /**
  62430. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62431. * @param scale defines the scale factor
  62432. * @param result defines the Quaternion object where to store the result
  62433. * @returns the unmodified current quaternion
  62434. */
  62435. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62436. /**
  62437. * Multiplies in place the current quaternion by a scale factor
  62438. * @param value defines the scale factor
  62439. * @returns the current modified quaternion
  62440. */
  62441. scaleInPlace(value: number): Quaternion;
  62442. /**
  62443. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62444. * @param scale defines the scale factor
  62445. * @param result defines the Quaternion object where to store the result
  62446. * @returns the unmodified current quaternion
  62447. */
  62448. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62449. /**
  62450. * Multiplies two quaternions
  62451. * @param q1 defines the second operand
  62452. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62453. */
  62454. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62455. /**
  62456. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62457. * @param q1 defines the second operand
  62458. * @param result defines the target quaternion
  62459. * @returns the current quaternion
  62460. */
  62461. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62462. /**
  62463. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62464. * @param q1 defines the second operand
  62465. * @returns the currentupdated quaternion
  62466. */
  62467. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62468. /**
  62469. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62470. * @param ref defines the target quaternion
  62471. * @returns the current quaternion
  62472. */
  62473. conjugateToRef(ref: Quaternion): Quaternion;
  62474. /**
  62475. * Conjugates in place (1-q) the current quaternion
  62476. * @returns the current updated quaternion
  62477. */
  62478. conjugateInPlace(): Quaternion;
  62479. /**
  62480. * Conjugates in place (1-q) the current quaternion
  62481. * @returns a new quaternion
  62482. */
  62483. conjugate(): Quaternion;
  62484. /**
  62485. * Gets length of current quaternion
  62486. * @returns the quaternion length (float)
  62487. */
  62488. length(): number;
  62489. /**
  62490. * Normalize in place the current quaternion
  62491. * @returns the current updated quaternion
  62492. */
  62493. normalize(): Quaternion;
  62494. /**
  62495. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62496. * @param order is a reserved parameter and is ignore for now
  62497. * @returns a new Vector3 containing the Euler angles
  62498. */
  62499. toEulerAngles(order?: string): Vector3;
  62500. /**
  62501. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62502. * @param result defines the vector which will be filled with the Euler angles
  62503. * @param order is a reserved parameter and is ignore for now
  62504. * @returns the current unchanged quaternion
  62505. */
  62506. toEulerAnglesToRef(result: Vector3): Quaternion;
  62507. /**
  62508. * Updates the given rotation matrix with the current quaternion values
  62509. * @param result defines the target matrix
  62510. * @returns the current unchanged quaternion
  62511. */
  62512. toRotationMatrix(result: Matrix): Quaternion;
  62513. /**
  62514. * Updates the current quaternion from the given rotation matrix values
  62515. * @param matrix defines the source matrix
  62516. * @returns the current updated quaternion
  62517. */
  62518. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62519. /**
  62520. * Creates a new quaternion from a rotation matrix
  62521. * @param matrix defines the source matrix
  62522. * @returns a new quaternion created from the given rotation matrix values
  62523. */
  62524. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62525. /**
  62526. * Updates the given quaternion with the given rotation matrix values
  62527. * @param matrix defines the source matrix
  62528. * @param result defines the target quaternion
  62529. */
  62530. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62531. /**
  62532. * Returns the dot product (float) between the quaternions "left" and "right"
  62533. * @param left defines the left operand
  62534. * @param right defines the right operand
  62535. * @returns the dot product
  62536. */
  62537. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62538. /**
  62539. * Checks if the two quaternions are close to each other
  62540. * @param quat0 defines the first quaternion to check
  62541. * @param quat1 defines the second quaternion to check
  62542. * @returns true if the two quaternions are close to each other
  62543. */
  62544. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62545. /**
  62546. * Creates an empty quaternion
  62547. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62548. */
  62549. static Zero(): Quaternion;
  62550. /**
  62551. * Inverse a given quaternion
  62552. * @param q defines the source quaternion
  62553. * @returns a new quaternion as the inverted current quaternion
  62554. */
  62555. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62556. /**
  62557. * Inverse a given quaternion
  62558. * @param q defines the source quaternion
  62559. * @param result the quaternion the result will be stored in
  62560. * @returns the result quaternion
  62561. */
  62562. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62563. /**
  62564. * Creates an identity quaternion
  62565. * @returns the identity quaternion
  62566. */
  62567. static Identity(): Quaternion;
  62568. /**
  62569. * Gets a boolean indicating if the given quaternion is identity
  62570. * @param quaternion defines the quaternion to check
  62571. * @returns true if the quaternion is identity
  62572. */
  62573. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62574. /**
  62575. * Creates a quaternion from a rotation around an axis
  62576. * @param axis defines the axis to use
  62577. * @param angle defines the angle to use
  62578. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62579. */
  62580. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62581. /**
  62582. * Creates a rotation around an axis and stores it into the given quaternion
  62583. * @param axis defines the axis to use
  62584. * @param angle defines the angle to use
  62585. * @param result defines the target quaternion
  62586. * @returns the target quaternion
  62587. */
  62588. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62589. /**
  62590. * Creates a new quaternion from data stored into an array
  62591. * @param array defines the data source
  62592. * @param offset defines the offset in the source array where the data starts
  62593. * @returns a new quaternion
  62594. */
  62595. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62596. /**
  62597. * Create a quaternion from Euler rotation angles
  62598. * @param x Pitch
  62599. * @param y Yaw
  62600. * @param z Roll
  62601. * @returns the new Quaternion
  62602. */
  62603. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62604. /**
  62605. * Updates a quaternion from Euler rotation angles
  62606. * @param x Pitch
  62607. * @param y Yaw
  62608. * @param z Roll
  62609. * @param result the quaternion to store the result
  62610. * @returns the updated quaternion
  62611. */
  62612. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62613. /**
  62614. * Create a quaternion from Euler rotation vector
  62615. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62616. * @returns the new Quaternion
  62617. */
  62618. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62619. /**
  62620. * Updates a quaternion from Euler rotation vector
  62621. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62622. * @param result the quaternion to store the result
  62623. * @returns the updated quaternion
  62624. */
  62625. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62626. /**
  62627. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62628. * @param yaw defines the rotation around Y axis
  62629. * @param pitch defines the rotation around X axis
  62630. * @param roll defines the rotation around Z axis
  62631. * @returns the new quaternion
  62632. */
  62633. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62634. /**
  62635. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62636. * @param yaw defines the rotation around Y axis
  62637. * @param pitch defines the rotation around X axis
  62638. * @param roll defines the rotation around Z axis
  62639. * @param result defines the target quaternion
  62640. */
  62641. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62642. /**
  62643. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62644. * @param alpha defines the rotation around first axis
  62645. * @param beta defines the rotation around second axis
  62646. * @param gamma defines the rotation around third axis
  62647. * @returns the new quaternion
  62648. */
  62649. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62650. /**
  62651. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62652. * @param alpha defines the rotation around first axis
  62653. * @param beta defines the rotation around second axis
  62654. * @param gamma defines the rotation around third axis
  62655. * @param result defines the target quaternion
  62656. */
  62657. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62658. /**
  62659. * 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)
  62660. * @param axis1 defines the first axis
  62661. * @param axis2 defines the second axis
  62662. * @param axis3 defines the third axis
  62663. * @returns the new quaternion
  62664. */
  62665. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62666. /**
  62667. * 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
  62668. * @param axis1 defines the first axis
  62669. * @param axis2 defines the second axis
  62670. * @param axis3 defines the third axis
  62671. * @param ref defines the target quaternion
  62672. */
  62673. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62674. /**
  62675. * Interpolates between two quaternions
  62676. * @param left defines first quaternion
  62677. * @param right defines second quaternion
  62678. * @param amount defines the gradient to use
  62679. * @returns the new interpolated quaternion
  62680. */
  62681. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62682. /**
  62683. * Interpolates between two quaternions and stores it into a target quaternion
  62684. * @param left defines first quaternion
  62685. * @param right defines second quaternion
  62686. * @param amount defines the gradient to use
  62687. * @param result defines the target quaternion
  62688. */
  62689. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62690. /**
  62691. * Interpolate between two quaternions using Hermite interpolation
  62692. * @param value1 defines first quaternion
  62693. * @param tangent1 defines the incoming tangent
  62694. * @param value2 defines second quaternion
  62695. * @param tangent2 defines the outgoing tangent
  62696. * @param amount defines the target quaternion
  62697. * @returns the new interpolated quaternion
  62698. */
  62699. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62700. }
  62701. /**
  62702. * Class used to store matrix data (4x4)
  62703. */
  62704. export class Matrix {
  62705. private static _updateFlagSeed;
  62706. private static _identityReadOnly;
  62707. private _isIdentity;
  62708. private _isIdentityDirty;
  62709. private _isIdentity3x2;
  62710. private _isIdentity3x2Dirty;
  62711. /**
  62712. * Gets the update flag of the matrix which is an unique number for the matrix.
  62713. * It will be incremented every time the matrix data change.
  62714. * You can use it to speed the comparison between two versions of the same matrix.
  62715. */
  62716. updateFlag: number;
  62717. private readonly _m;
  62718. /**
  62719. * Gets the internal data of the matrix
  62720. */
  62721. readonly m: DeepImmutable<Float32Array>;
  62722. /** @hidden */
  62723. _markAsUpdated(): void;
  62724. /** @hidden */
  62725. private _updateIdentityStatus;
  62726. /**
  62727. * Creates an empty matrix (filled with zeros)
  62728. */
  62729. constructor();
  62730. /**
  62731. * Check if the current matrix is identity
  62732. * @returns true is the matrix is the identity matrix
  62733. */
  62734. isIdentity(): boolean;
  62735. /**
  62736. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62737. * @returns true is the matrix is the identity matrix
  62738. */
  62739. isIdentityAs3x2(): boolean;
  62740. /**
  62741. * Gets the determinant of the matrix
  62742. * @returns the matrix determinant
  62743. */
  62744. determinant(): number;
  62745. /**
  62746. * Returns the matrix as a Float32Array
  62747. * @returns the matrix underlying array
  62748. */
  62749. toArray(): DeepImmutable<Float32Array>;
  62750. /**
  62751. * Returns the matrix as a Float32Array
  62752. * @returns the matrix underlying array.
  62753. */
  62754. asArray(): DeepImmutable<Float32Array>;
  62755. /**
  62756. * Inverts the current matrix in place
  62757. * @returns the current inverted matrix
  62758. */
  62759. invert(): Matrix;
  62760. /**
  62761. * Sets all the matrix elements to zero
  62762. * @returns the current matrix
  62763. */
  62764. reset(): Matrix;
  62765. /**
  62766. * Adds the current matrix with a second one
  62767. * @param other defines the matrix to add
  62768. * @returns a new matrix as the addition of the current matrix and the given one
  62769. */
  62770. add(other: DeepImmutable<Matrix>): Matrix;
  62771. /**
  62772. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62773. * @param other defines the matrix to add
  62774. * @param result defines the target matrix
  62775. * @returns the current matrix
  62776. */
  62777. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62778. /**
  62779. * Adds in place the given matrix to the current matrix
  62780. * @param other defines the second operand
  62781. * @returns the current updated matrix
  62782. */
  62783. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62784. /**
  62785. * Sets the given matrix to the current inverted Matrix
  62786. * @param other defines the target matrix
  62787. * @returns the unmodified current matrix
  62788. */
  62789. invertToRef(other: Matrix): Matrix;
  62790. /**
  62791. * add a value at the specified position in the current Matrix
  62792. * @param index the index of the value within the matrix. between 0 and 15.
  62793. * @param value the value to be added
  62794. * @returns the current updated matrix
  62795. */
  62796. addAtIndex(index: number, value: number): Matrix;
  62797. /**
  62798. * mutiply the specified position in the current Matrix by a value
  62799. * @param index the index of the value within the matrix. between 0 and 15.
  62800. * @param value the value to be added
  62801. * @returns the current updated matrix
  62802. */
  62803. multiplyAtIndex(index: number, value: number): Matrix;
  62804. /**
  62805. * Inserts the translation vector (using 3 floats) in the current matrix
  62806. * @param x defines the 1st component of the translation
  62807. * @param y defines the 2nd component of the translation
  62808. * @param z defines the 3rd component of the translation
  62809. * @returns the current updated matrix
  62810. */
  62811. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62812. /**
  62813. * Adds the translation vector (using 3 floats) in the current matrix
  62814. * @param x defines the 1st component of the translation
  62815. * @param y defines the 2nd component of the translation
  62816. * @param z defines the 3rd component of the translation
  62817. * @returns the current updated matrix
  62818. */
  62819. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62820. /**
  62821. * Inserts the translation vector in the current matrix
  62822. * @param vector3 defines the translation to insert
  62823. * @returns the current updated matrix
  62824. */
  62825. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62826. /**
  62827. * Gets the translation value of the current matrix
  62828. * @returns a new Vector3 as the extracted translation from the matrix
  62829. */
  62830. getTranslation(): Vector3;
  62831. /**
  62832. * Fill a Vector3 with the extracted translation from the matrix
  62833. * @param result defines the Vector3 where to store the translation
  62834. * @returns the current matrix
  62835. */
  62836. getTranslationToRef(result: Vector3): Matrix;
  62837. /**
  62838. * Remove rotation and scaling part from the matrix
  62839. * @returns the updated matrix
  62840. */
  62841. removeRotationAndScaling(): Matrix;
  62842. /**
  62843. * Multiply two matrices
  62844. * @param other defines the second operand
  62845. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62846. */
  62847. multiply(other: DeepImmutable<Matrix>): Matrix;
  62848. /**
  62849. * Copy the current matrix from the given one
  62850. * @param other defines the source matrix
  62851. * @returns the current updated matrix
  62852. */
  62853. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62854. /**
  62855. * Populates the given array from the starting index with the current matrix values
  62856. * @param array defines the target array
  62857. * @param offset defines the offset in the target array where to start storing values
  62858. * @returns the current matrix
  62859. */
  62860. copyToArray(array: Float32Array, offset?: number): Matrix;
  62861. /**
  62862. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62863. * @param other defines the second operand
  62864. * @param result defines the matrix where to store the multiplication
  62865. * @returns the current matrix
  62866. */
  62867. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62868. /**
  62869. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62870. * @param other defines the second operand
  62871. * @param result defines the array where to store the multiplication
  62872. * @param offset defines the offset in the target array where to start storing values
  62873. * @returns the current matrix
  62874. */
  62875. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62876. /**
  62877. * Check equality between this matrix and a second one
  62878. * @param value defines the second matrix to compare
  62879. * @returns true is the current matrix and the given one values are strictly equal
  62880. */
  62881. equals(value: DeepImmutable<Matrix>): boolean;
  62882. /**
  62883. * Clone the current matrix
  62884. * @returns a new matrix from the current matrix
  62885. */
  62886. clone(): Matrix;
  62887. /**
  62888. * Returns the name of the current matrix class
  62889. * @returns the string "Matrix"
  62890. */
  62891. getClassName(): string;
  62892. /**
  62893. * Gets the hash code of the current matrix
  62894. * @returns the hash code
  62895. */
  62896. getHashCode(): number;
  62897. /**
  62898. * Decomposes the current Matrix into a translation, rotation and scaling components
  62899. * @param scale defines the scale vector3 given as a reference to update
  62900. * @param rotation defines the rotation quaternion given as a reference to update
  62901. * @param translation defines the translation vector3 given as a reference to update
  62902. * @returns true if operation was successful
  62903. */
  62904. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62905. /**
  62906. * Gets specific row of the matrix
  62907. * @param index defines the number of the row to get
  62908. * @returns the index-th row of the current matrix as a new Vector4
  62909. */
  62910. getRow(index: number): Nullable<Vector4>;
  62911. /**
  62912. * Sets the index-th row of the current matrix to the vector4 values
  62913. * @param index defines the number of the row to set
  62914. * @param row defines the target vector4
  62915. * @returns the updated current matrix
  62916. */
  62917. setRow(index: number, row: Vector4): Matrix;
  62918. /**
  62919. * Compute the transpose of the matrix
  62920. * @returns the new transposed matrix
  62921. */
  62922. transpose(): Matrix;
  62923. /**
  62924. * Compute the transpose of the matrix and store it in a given matrix
  62925. * @param result defines the target matrix
  62926. * @returns the current matrix
  62927. */
  62928. transposeToRef(result: Matrix): Matrix;
  62929. /**
  62930. * Sets the index-th row of the current matrix with the given 4 x float values
  62931. * @param index defines the row index
  62932. * @param x defines the x component to set
  62933. * @param y defines the y component to set
  62934. * @param z defines the z component to set
  62935. * @param w defines the w component to set
  62936. * @returns the updated current matrix
  62937. */
  62938. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62939. /**
  62940. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62941. * @param scale defines the scale factor
  62942. * @returns a new matrix
  62943. */
  62944. scale(scale: number): Matrix;
  62945. /**
  62946. * Scale the current matrix values by a factor to a given result matrix
  62947. * @param scale defines the scale factor
  62948. * @param result defines the matrix to store the result
  62949. * @returns the current matrix
  62950. */
  62951. scaleToRef(scale: number, result: Matrix): Matrix;
  62952. /**
  62953. * Scale the current matrix values by a factor and add the result to a given matrix
  62954. * @param scale defines the scale factor
  62955. * @param result defines the Matrix to store the result
  62956. * @returns the current matrix
  62957. */
  62958. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62959. /**
  62960. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62961. * @param ref matrix to store the result
  62962. */
  62963. toNormalMatrix(ref: Matrix): void;
  62964. /**
  62965. * Gets only rotation part of the current matrix
  62966. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62967. */
  62968. getRotationMatrix(): Matrix;
  62969. /**
  62970. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62971. * @param result defines the target matrix to store data to
  62972. * @returns the current matrix
  62973. */
  62974. getRotationMatrixToRef(result: Matrix): Matrix;
  62975. /**
  62976. * Toggles model matrix from being right handed to left handed in place and vice versa
  62977. */
  62978. toggleModelMatrixHandInPlace(): void;
  62979. /**
  62980. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62981. */
  62982. toggleProjectionMatrixHandInPlace(): void;
  62983. /**
  62984. * Creates a matrix from an array
  62985. * @param array defines the source array
  62986. * @param offset defines an offset in the source array
  62987. * @returns a new Matrix set from the starting index of the given array
  62988. */
  62989. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62990. /**
  62991. * Copy the content of an array into a given matrix
  62992. * @param array defines the source array
  62993. * @param offset defines an offset in the source array
  62994. * @param result defines the target matrix
  62995. */
  62996. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62997. /**
  62998. * Stores an array into a matrix after having multiplied each component by a given factor
  62999. * @param array defines the source array
  63000. * @param offset defines the offset in the source array
  63001. * @param scale defines the scaling factor
  63002. * @param result defines the target matrix
  63003. */
  63004. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63005. /**
  63006. * Gets an identity matrix that must not be updated
  63007. */
  63008. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63009. /**
  63010. * Stores a list of values (16) inside a given matrix
  63011. * @param initialM11 defines 1st value of 1st row
  63012. * @param initialM12 defines 2nd value of 1st row
  63013. * @param initialM13 defines 3rd value of 1st row
  63014. * @param initialM14 defines 4th value of 1st row
  63015. * @param initialM21 defines 1st value of 2nd row
  63016. * @param initialM22 defines 2nd value of 2nd row
  63017. * @param initialM23 defines 3rd value of 2nd row
  63018. * @param initialM24 defines 4th value of 2nd row
  63019. * @param initialM31 defines 1st value of 3rd row
  63020. * @param initialM32 defines 2nd value of 3rd row
  63021. * @param initialM33 defines 3rd value of 3rd row
  63022. * @param initialM34 defines 4th value of 3rd row
  63023. * @param initialM41 defines 1st value of 4th row
  63024. * @param initialM42 defines 2nd value of 4th row
  63025. * @param initialM43 defines 3rd value of 4th row
  63026. * @param initialM44 defines 4th value of 4th row
  63027. * @param result defines the target matrix
  63028. */
  63029. 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;
  63030. /**
  63031. * Creates new matrix from a list of values (16)
  63032. * @param initialM11 defines 1st value of 1st row
  63033. * @param initialM12 defines 2nd value of 1st row
  63034. * @param initialM13 defines 3rd value of 1st row
  63035. * @param initialM14 defines 4th value of 1st row
  63036. * @param initialM21 defines 1st value of 2nd row
  63037. * @param initialM22 defines 2nd value of 2nd row
  63038. * @param initialM23 defines 3rd value of 2nd row
  63039. * @param initialM24 defines 4th value of 2nd row
  63040. * @param initialM31 defines 1st value of 3rd row
  63041. * @param initialM32 defines 2nd value of 3rd row
  63042. * @param initialM33 defines 3rd value of 3rd row
  63043. * @param initialM34 defines 4th value of 3rd row
  63044. * @param initialM41 defines 1st value of 4th row
  63045. * @param initialM42 defines 2nd value of 4th row
  63046. * @param initialM43 defines 3rd value of 4th row
  63047. * @param initialM44 defines 4th value of 4th row
  63048. * @returns the new matrix
  63049. */
  63050. 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;
  63051. /**
  63052. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63053. * @param scale defines the scale vector3
  63054. * @param rotation defines the rotation quaternion
  63055. * @param translation defines the translation vector3
  63056. * @returns a new matrix
  63057. */
  63058. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63059. /**
  63060. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63061. * @param scale defines the scale vector3
  63062. * @param rotation defines the rotation quaternion
  63063. * @param translation defines the translation vector3
  63064. * @param result defines the target matrix
  63065. */
  63066. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63067. /**
  63068. * Creates a new identity matrix
  63069. * @returns a new identity matrix
  63070. */
  63071. static Identity(): Matrix;
  63072. /**
  63073. * Creates a new identity matrix and stores the result in a given matrix
  63074. * @param result defines the target matrix
  63075. */
  63076. static IdentityToRef(result: Matrix): void;
  63077. /**
  63078. * Creates a new zero matrix
  63079. * @returns a new zero matrix
  63080. */
  63081. static Zero(): Matrix;
  63082. /**
  63083. * Creates a new rotation matrix for "angle" radians around the X axis
  63084. * @param angle defines the angle (in radians) to use
  63085. * @return the new matrix
  63086. */
  63087. static RotationX(angle: number): Matrix;
  63088. /**
  63089. * Creates a new matrix as the invert of a given matrix
  63090. * @param source defines the source matrix
  63091. * @returns the new matrix
  63092. */
  63093. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63094. /**
  63095. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63096. * @param angle defines the angle (in radians) to use
  63097. * @param result defines the target matrix
  63098. */
  63099. static RotationXToRef(angle: number, result: Matrix): void;
  63100. /**
  63101. * Creates a new rotation matrix for "angle" radians around the Y axis
  63102. * @param angle defines the angle (in radians) to use
  63103. * @return the new matrix
  63104. */
  63105. static RotationY(angle: number): Matrix;
  63106. /**
  63107. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63108. * @param angle defines the angle (in radians) to use
  63109. * @param result defines the target matrix
  63110. */
  63111. static RotationYToRef(angle: number, result: Matrix): void;
  63112. /**
  63113. * Creates a new rotation matrix for "angle" radians around the Z axis
  63114. * @param angle defines the angle (in radians) to use
  63115. * @return the new matrix
  63116. */
  63117. static RotationZ(angle: number): Matrix;
  63118. /**
  63119. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63120. * @param angle defines the angle (in radians) to use
  63121. * @param result defines the target matrix
  63122. */
  63123. static RotationZToRef(angle: number, result: Matrix): void;
  63124. /**
  63125. * Creates a new rotation matrix for "angle" radians around the given axis
  63126. * @param axis defines the axis to use
  63127. * @param angle defines the angle (in radians) to use
  63128. * @return the new matrix
  63129. */
  63130. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63131. /**
  63132. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63133. * @param axis defines the axis to use
  63134. * @param angle defines the angle (in radians) to use
  63135. * @param result defines the target matrix
  63136. */
  63137. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63138. /**
  63139. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63140. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63141. * @param from defines the vector to align
  63142. * @param to defines the vector to align to
  63143. * @param result defines the target matrix
  63144. */
  63145. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63146. /**
  63147. * Creates a rotation matrix
  63148. * @param yaw defines the yaw angle in radians (Y axis)
  63149. * @param pitch defines the pitch angle in radians (X axis)
  63150. * @param roll defines the roll angle in radians (X axis)
  63151. * @returns the new rotation matrix
  63152. */
  63153. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63154. /**
  63155. * Creates a rotation matrix and stores it in a given matrix
  63156. * @param yaw defines the yaw angle in radians (Y axis)
  63157. * @param pitch defines the pitch angle in radians (X axis)
  63158. * @param roll defines the roll angle in radians (X axis)
  63159. * @param result defines the target matrix
  63160. */
  63161. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63162. /**
  63163. * Creates a scaling matrix
  63164. * @param x defines the scale factor on X axis
  63165. * @param y defines the scale factor on Y axis
  63166. * @param z defines the scale factor on Z axis
  63167. * @returns the new matrix
  63168. */
  63169. static Scaling(x: number, y: number, z: number): Matrix;
  63170. /**
  63171. * Creates a scaling matrix and stores it in a given matrix
  63172. * @param x defines the scale factor on X axis
  63173. * @param y defines the scale factor on Y axis
  63174. * @param z defines the scale factor on Z axis
  63175. * @param result defines the target matrix
  63176. */
  63177. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63178. /**
  63179. * Creates a translation matrix
  63180. * @param x defines the translation on X axis
  63181. * @param y defines the translation on Y axis
  63182. * @param z defines the translationon Z axis
  63183. * @returns the new matrix
  63184. */
  63185. static Translation(x: number, y: number, z: number): Matrix;
  63186. /**
  63187. * Creates a translation matrix and stores it in a given matrix
  63188. * @param x defines the translation on X axis
  63189. * @param y defines the translation on Y axis
  63190. * @param z defines the translationon Z axis
  63191. * @param result defines the target matrix
  63192. */
  63193. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63194. /**
  63195. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63196. * @param startValue defines the start value
  63197. * @param endValue defines the end value
  63198. * @param gradient defines the gradient factor
  63199. * @returns the new matrix
  63200. */
  63201. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63202. /**
  63203. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63204. * @param startValue defines the start value
  63205. * @param endValue defines the end value
  63206. * @param gradient defines the gradient factor
  63207. * @param result defines the Matrix object where to store data
  63208. */
  63209. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63210. /**
  63211. * Builds a new matrix whose values are computed by:
  63212. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63213. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63214. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63215. * @param startValue defines the first matrix
  63216. * @param endValue defines the second matrix
  63217. * @param gradient defines the gradient between the two matrices
  63218. * @returns the new matrix
  63219. */
  63220. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63221. /**
  63222. * Update a matrix to values which are computed by:
  63223. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63224. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63225. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63226. * @param startValue defines the first matrix
  63227. * @param endValue defines the second matrix
  63228. * @param gradient defines the gradient between the two matrices
  63229. * @param result defines the target matrix
  63230. */
  63231. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63232. /**
  63233. * 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"
  63234. * This function works in left handed mode
  63235. * @param eye defines the final position of the entity
  63236. * @param target defines where the entity should look at
  63237. * @param up defines the up vector for the entity
  63238. * @returns the new matrix
  63239. */
  63240. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63241. /**
  63242. * 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".
  63243. * This function works in left handed mode
  63244. * @param eye defines the final position of the entity
  63245. * @param target defines where the entity should look at
  63246. * @param up defines the up vector for the entity
  63247. * @param result defines the target matrix
  63248. */
  63249. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63250. /**
  63251. * 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"
  63252. * This function works in right handed mode
  63253. * @param eye defines the final position of the entity
  63254. * @param target defines where the entity should look at
  63255. * @param up defines the up vector for the entity
  63256. * @returns the new matrix
  63257. */
  63258. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63259. /**
  63260. * 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".
  63261. * This function works in right handed mode
  63262. * @param eye defines the final position of the entity
  63263. * @param target defines where the entity should look at
  63264. * @param up defines the up vector for the entity
  63265. * @param result defines the target matrix
  63266. */
  63267. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63268. /**
  63269. * Create a left-handed orthographic projection matrix
  63270. * @param width defines the viewport width
  63271. * @param height defines the viewport height
  63272. * @param znear defines the near clip plane
  63273. * @param zfar defines the far clip plane
  63274. * @returns a new matrix as a left-handed orthographic projection matrix
  63275. */
  63276. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63277. /**
  63278. * Store a left-handed orthographic projection to a given matrix
  63279. * @param width defines the viewport width
  63280. * @param height defines the viewport height
  63281. * @param znear defines the near clip plane
  63282. * @param zfar defines the far clip plane
  63283. * @param result defines the target matrix
  63284. */
  63285. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63286. /**
  63287. * Create a left-handed orthographic projection matrix
  63288. * @param left defines the viewport left coordinate
  63289. * @param right defines the viewport right coordinate
  63290. * @param bottom defines the viewport bottom coordinate
  63291. * @param top defines the viewport top coordinate
  63292. * @param znear defines the near clip plane
  63293. * @param zfar defines the far clip plane
  63294. * @returns a new matrix as a left-handed orthographic projection matrix
  63295. */
  63296. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63297. /**
  63298. * Stores a left-handed orthographic projection into a given matrix
  63299. * @param left defines the viewport left coordinate
  63300. * @param right defines the viewport right coordinate
  63301. * @param bottom defines the viewport bottom coordinate
  63302. * @param top defines the viewport top coordinate
  63303. * @param znear defines the near clip plane
  63304. * @param zfar defines the far clip plane
  63305. * @param result defines the target matrix
  63306. */
  63307. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63308. /**
  63309. * Creates a right-handed orthographic projection matrix
  63310. * @param left defines the viewport left coordinate
  63311. * @param right defines the viewport right coordinate
  63312. * @param bottom defines the viewport bottom coordinate
  63313. * @param top defines the viewport top coordinate
  63314. * @param znear defines the near clip plane
  63315. * @param zfar defines the far clip plane
  63316. * @returns a new matrix as a right-handed orthographic projection matrix
  63317. */
  63318. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63319. /**
  63320. * Stores a right-handed orthographic projection into a given matrix
  63321. * @param left defines the viewport left coordinate
  63322. * @param right defines the viewport right coordinate
  63323. * @param bottom defines the viewport bottom coordinate
  63324. * @param top defines the viewport top coordinate
  63325. * @param znear defines the near clip plane
  63326. * @param zfar defines the far clip plane
  63327. * @param result defines the target matrix
  63328. */
  63329. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63330. /**
  63331. * Creates a left-handed perspective projection matrix
  63332. * @param width defines the viewport width
  63333. * @param height defines the viewport height
  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 perspective projection matrix
  63337. */
  63338. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63339. /**
  63340. * Creates a left-handed perspective projection matrix
  63341. * @param fov defines the horizontal field of view
  63342. * @param aspect defines the aspect ratio
  63343. * @param znear defines the near clip plane
  63344. * @param zfar defines the far clip plane
  63345. * @returns a new matrix as a left-handed perspective projection matrix
  63346. */
  63347. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63348. /**
  63349. * Stores a left-handed perspective projection into a given matrix
  63350. * @param fov defines the horizontal field of view
  63351. * @param aspect defines the aspect ratio
  63352. * @param znear defines the near clip plane
  63353. * @param zfar defines the far clip plane
  63354. * @param result defines the target matrix
  63355. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63356. */
  63357. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63358. /**
  63359. * Creates a right-handed perspective projection matrix
  63360. * @param fov defines the horizontal field of view
  63361. * @param aspect defines the aspect ratio
  63362. * @param znear defines the near clip plane
  63363. * @param zfar defines the far clip plane
  63364. * @returns a new matrix as a right-handed perspective projection matrix
  63365. */
  63366. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63367. /**
  63368. * Stores a right-handed perspective projection into a given matrix
  63369. * @param fov defines the horizontal field of view
  63370. * @param aspect defines the aspect ratio
  63371. * @param znear defines the near clip plane
  63372. * @param zfar defines the far clip plane
  63373. * @param result defines the target matrix
  63374. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63375. */
  63376. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63377. /**
  63378. * Stores a perspective projection for WebVR info a given matrix
  63379. * @param fov defines the field of view
  63380. * @param znear defines the near clip plane
  63381. * @param zfar defines the far clip plane
  63382. * @param result defines the target matrix
  63383. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63384. */
  63385. static PerspectiveFovWebVRToRef(fov: {
  63386. upDegrees: number;
  63387. downDegrees: number;
  63388. leftDegrees: number;
  63389. rightDegrees: number;
  63390. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63391. /**
  63392. * Computes a complete transformation matrix
  63393. * @param viewport defines the viewport to use
  63394. * @param world defines the world matrix
  63395. * @param view defines the view matrix
  63396. * @param projection defines the projection matrix
  63397. * @param zmin defines the near clip plane
  63398. * @param zmax defines the far clip plane
  63399. * @returns the transformation matrix
  63400. */
  63401. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63402. /**
  63403. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63404. * @param matrix defines the matrix to use
  63405. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63406. */
  63407. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63408. /**
  63409. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63410. * @param matrix defines the matrix to use
  63411. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63412. */
  63413. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63414. /**
  63415. * Compute the transpose of a given matrix
  63416. * @param matrix defines the matrix to transpose
  63417. * @returns the new matrix
  63418. */
  63419. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63420. /**
  63421. * Compute the transpose of a matrix and store it in a target matrix
  63422. * @param matrix defines the matrix to transpose
  63423. * @param result defines the target matrix
  63424. */
  63425. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63426. /**
  63427. * Computes a reflection matrix from a plane
  63428. * @param plane defines the reflection plane
  63429. * @returns a new matrix
  63430. */
  63431. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63432. /**
  63433. * Computes a reflection matrix from a plane
  63434. * @param plane defines the reflection plane
  63435. * @param result defines the target matrix
  63436. */
  63437. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63438. /**
  63439. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63440. * @param xaxis defines the value of the 1st axis
  63441. * @param yaxis defines the value of the 2nd axis
  63442. * @param zaxis defines the value of the 3rd axis
  63443. * @param result defines the target matrix
  63444. */
  63445. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63446. /**
  63447. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63448. * @param quat defines the quaternion to use
  63449. * @param result defines the target matrix
  63450. */
  63451. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63452. }
  63453. /**
  63454. * Represens a plane by the equation ax + by + cz + d = 0
  63455. */
  63456. export class Plane {
  63457. /**
  63458. * Normal of the plane (a,b,c)
  63459. */
  63460. normal: Vector3;
  63461. /**
  63462. * d component of the plane
  63463. */
  63464. d: number;
  63465. /**
  63466. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63467. * @param a a component of the plane
  63468. * @param b b component of the plane
  63469. * @param c c component of the plane
  63470. * @param d d component of the plane
  63471. */
  63472. constructor(a: number, b: number, c: number, d: number);
  63473. /**
  63474. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63475. */
  63476. asArray(): number[];
  63477. /**
  63478. * @returns a new plane copied from the current Plane.
  63479. */
  63480. clone(): Plane;
  63481. /**
  63482. * @returns the string "Plane".
  63483. */
  63484. getClassName(): string;
  63485. /**
  63486. * @returns the Plane hash code.
  63487. */
  63488. getHashCode(): number;
  63489. /**
  63490. * Normalize the current Plane in place.
  63491. * @returns the updated Plane.
  63492. */
  63493. normalize(): Plane;
  63494. /**
  63495. * Applies a transformation the plane and returns the result
  63496. * @param transformation the transformation matrix to be applied to the plane
  63497. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63498. */
  63499. transform(transformation: DeepImmutable<Matrix>): Plane;
  63500. /**
  63501. * Calcualtte the dot product between the point and the plane normal
  63502. * @param point point to calculate the dot product with
  63503. * @returns the dot product (float) of the point coordinates and the plane normal.
  63504. */
  63505. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63506. /**
  63507. * Updates the current Plane from the plane defined by the three given points.
  63508. * @param point1 one of the points used to contruct the plane
  63509. * @param point2 one of the points used to contruct the plane
  63510. * @param point3 one of the points used to contruct the plane
  63511. * @returns the updated Plane.
  63512. */
  63513. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63514. /**
  63515. * Checks if the plane is facing a given direction
  63516. * @param direction the direction to check if the plane is facing
  63517. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63518. * @returns True is the vector "direction" is the same side than the plane normal.
  63519. */
  63520. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63521. /**
  63522. * Calculates the distance to a point
  63523. * @param point point to calculate distance to
  63524. * @returns the signed distance (float) from the given point to the Plane.
  63525. */
  63526. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63527. /**
  63528. * Creates a plane from an array
  63529. * @param array the array to create a plane from
  63530. * @returns a new Plane from the given array.
  63531. */
  63532. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63533. /**
  63534. * Creates a plane from three points
  63535. * @param point1 point used to create the plane
  63536. * @param point2 point used to create the plane
  63537. * @param point3 point used to create the plane
  63538. * @returns a new Plane defined by the three given points.
  63539. */
  63540. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63541. /**
  63542. * Creates a plane from an origin point and a normal
  63543. * @param origin origin of the plane to be constructed
  63544. * @param normal normal of the plane to be constructed
  63545. * @returns a new Plane the normal vector to this plane at the given origin point.
  63546. * Note : the vector "normal" is updated because normalized.
  63547. */
  63548. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63549. /**
  63550. * Calculates the distance from a plane and a point
  63551. * @param origin origin of the plane to be constructed
  63552. * @param normal normal of the plane to be constructed
  63553. * @param point point to calculate distance to
  63554. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63555. */
  63556. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63557. }
  63558. /**
  63559. * Class used to represent a viewport on screen
  63560. */
  63561. export class Viewport {
  63562. /** viewport left coordinate */
  63563. x: number;
  63564. /** viewport top coordinate */
  63565. y: number;
  63566. /**viewport width */
  63567. width: number;
  63568. /** viewport height */
  63569. height: number;
  63570. /**
  63571. * Creates a Viewport object located at (x, y) and sized (width, height)
  63572. * @param x defines viewport left coordinate
  63573. * @param y defines viewport top coordinate
  63574. * @param width defines the viewport width
  63575. * @param height defines the viewport height
  63576. */
  63577. constructor(
  63578. /** viewport left coordinate */
  63579. x: number,
  63580. /** viewport top coordinate */
  63581. y: number,
  63582. /**viewport width */
  63583. width: number,
  63584. /** viewport height */
  63585. height: number);
  63586. /**
  63587. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63588. * @param renderWidth defines the rendering width
  63589. * @param renderHeight defines the rendering height
  63590. * @returns a new Viewport
  63591. */
  63592. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63593. /**
  63594. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63595. * @param renderWidth defines the rendering width
  63596. * @param renderHeight defines the rendering height
  63597. * @param ref defines the target viewport
  63598. * @returns the current viewport
  63599. */
  63600. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63601. /**
  63602. * Returns a new Viewport copied from the current one
  63603. * @returns a new Viewport
  63604. */
  63605. clone(): Viewport;
  63606. }
  63607. /**
  63608. * Reprasents a camera frustum
  63609. */
  63610. export class Frustum {
  63611. /**
  63612. * Gets the planes representing the frustum
  63613. * @param transform matrix to be applied to the returned planes
  63614. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63615. */
  63616. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63617. /**
  63618. * Gets the near frustum plane transformed by the transform matrix
  63619. * @param transform transformation matrix to be applied to the resulting frustum plane
  63620. * @param frustumPlane the resuling frustum plane
  63621. */
  63622. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63623. /**
  63624. * Gets the far frustum plane transformed by the transform matrix
  63625. * @param transform transformation matrix to be applied to the resulting frustum plane
  63626. * @param frustumPlane the resuling frustum plane
  63627. */
  63628. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63629. /**
  63630. * Gets the left frustum plane transformed by the transform matrix
  63631. * @param transform transformation matrix to be applied to the resulting frustum plane
  63632. * @param frustumPlane the resuling frustum plane
  63633. */
  63634. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63635. /**
  63636. * Gets the right frustum plane transformed by the transform matrix
  63637. * @param transform transformation matrix to be applied to the resulting frustum plane
  63638. * @param frustumPlane the resuling frustum plane
  63639. */
  63640. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63641. /**
  63642. * Gets the top frustum plane transformed by the transform matrix
  63643. * @param transform transformation matrix to be applied to the resulting frustum plane
  63644. * @param frustumPlane the resuling frustum plane
  63645. */
  63646. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63647. /**
  63648. * Gets the bottom frustum plane transformed by the transform matrix
  63649. * @param transform transformation matrix to be applied to the resulting frustum plane
  63650. * @param frustumPlane the resuling frustum plane
  63651. */
  63652. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63653. /**
  63654. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63655. * @param transform transformation matrix to be applied to the resulting frustum planes
  63656. * @param frustumPlanes the resuling frustum planes
  63657. */
  63658. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63659. }
  63660. /** Defines supported spaces */
  63661. export enum Space {
  63662. /** Local (object) space */
  63663. LOCAL = 0,
  63664. /** World space */
  63665. WORLD = 1,
  63666. /** Bone space */
  63667. BONE = 2
  63668. }
  63669. /** Defines the 3 main axes */
  63670. export class Axis {
  63671. /** X axis */
  63672. static X: Vector3;
  63673. /** Y axis */
  63674. static Y: Vector3;
  63675. /** Z axis */
  63676. static Z: Vector3;
  63677. }
  63678. /** Class used to represent a Bezier curve */
  63679. export class BezierCurve {
  63680. /**
  63681. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63682. * @param t defines the time
  63683. * @param x1 defines the left coordinate on X axis
  63684. * @param y1 defines the left coordinate on Y axis
  63685. * @param x2 defines the right coordinate on X axis
  63686. * @param y2 defines the right coordinate on Y axis
  63687. * @returns the interpolated value
  63688. */
  63689. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63690. }
  63691. /**
  63692. * Defines potential orientation for back face culling
  63693. */
  63694. export enum Orientation {
  63695. /**
  63696. * Clockwise
  63697. */
  63698. CW = 0,
  63699. /** Counter clockwise */
  63700. CCW = 1
  63701. }
  63702. /**
  63703. * Defines angle representation
  63704. */
  63705. export class Angle {
  63706. private _radians;
  63707. /**
  63708. * Creates an Angle object of "radians" radians (float).
  63709. * @param radians the angle in radians
  63710. */
  63711. constructor(radians: number);
  63712. /**
  63713. * Get value in degrees
  63714. * @returns the Angle value in degrees (float)
  63715. */
  63716. degrees(): number;
  63717. /**
  63718. * Get value in radians
  63719. * @returns the Angle value in radians (float)
  63720. */
  63721. radians(): number;
  63722. /**
  63723. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63724. * @param a defines first vector
  63725. * @param b defines second vector
  63726. * @returns a new Angle
  63727. */
  63728. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63729. /**
  63730. * Gets a new Angle object from the given float in radians
  63731. * @param radians defines the angle value in radians
  63732. * @returns a new Angle
  63733. */
  63734. static FromRadians(radians: number): Angle;
  63735. /**
  63736. * Gets a new Angle object from the given float in degrees
  63737. * @param degrees defines the angle value in degrees
  63738. * @returns a new Angle
  63739. */
  63740. static FromDegrees(degrees: number): Angle;
  63741. }
  63742. /**
  63743. * This represents an arc in a 2d space.
  63744. */
  63745. export class Arc2 {
  63746. /** Defines the start point of the arc */
  63747. startPoint: Vector2;
  63748. /** Defines the mid point of the arc */
  63749. midPoint: Vector2;
  63750. /** Defines the end point of the arc */
  63751. endPoint: Vector2;
  63752. /**
  63753. * Defines the center point of the arc.
  63754. */
  63755. centerPoint: Vector2;
  63756. /**
  63757. * Defines the radius of the arc.
  63758. */
  63759. radius: number;
  63760. /**
  63761. * Defines the angle of the arc (from mid point to end point).
  63762. */
  63763. angle: Angle;
  63764. /**
  63765. * Defines the start angle of the arc (from start point to middle point).
  63766. */
  63767. startAngle: Angle;
  63768. /**
  63769. * Defines the orientation of the arc (clock wise/counter clock wise).
  63770. */
  63771. orientation: Orientation;
  63772. /**
  63773. * Creates an Arc object from the three given points : start, middle and end.
  63774. * @param startPoint Defines the start point of the arc
  63775. * @param midPoint Defines the midlle point of the arc
  63776. * @param endPoint Defines the end point of the arc
  63777. */
  63778. constructor(
  63779. /** Defines the start point of the arc */
  63780. startPoint: Vector2,
  63781. /** Defines the mid point of the arc */
  63782. midPoint: Vector2,
  63783. /** Defines the end point of the arc */
  63784. endPoint: Vector2);
  63785. }
  63786. /**
  63787. * Represents a 2D path made up of multiple 2D points
  63788. */
  63789. export class Path2 {
  63790. private _points;
  63791. private _length;
  63792. /**
  63793. * If the path start and end point are the same
  63794. */
  63795. closed: boolean;
  63796. /**
  63797. * Creates a Path2 object from the starting 2D coordinates x and y.
  63798. * @param x the starting points x value
  63799. * @param y the starting points y value
  63800. */
  63801. constructor(x: number, y: number);
  63802. /**
  63803. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63804. * @param x the added points x value
  63805. * @param y the added points y value
  63806. * @returns the updated Path2.
  63807. */
  63808. addLineTo(x: number, y: number): Path2;
  63809. /**
  63810. * 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.
  63811. * @param midX middle point x value
  63812. * @param midY middle point y value
  63813. * @param endX end point x value
  63814. * @param endY end point y value
  63815. * @param numberOfSegments (default: 36)
  63816. * @returns the updated Path2.
  63817. */
  63818. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63819. /**
  63820. * Closes the Path2.
  63821. * @returns the Path2.
  63822. */
  63823. close(): Path2;
  63824. /**
  63825. * Gets the sum of the distance between each sequential point in the path
  63826. * @returns the Path2 total length (float).
  63827. */
  63828. length(): number;
  63829. /**
  63830. * Gets the points which construct the path
  63831. * @returns the Path2 internal array of points.
  63832. */
  63833. getPoints(): Vector2[];
  63834. /**
  63835. * Retreives the point at the distance aways from the starting point
  63836. * @param normalizedLengthPosition the length along the path to retreive the point from
  63837. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63838. */
  63839. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63840. /**
  63841. * Creates a new path starting from an x and y position
  63842. * @param x starting x value
  63843. * @param y starting y value
  63844. * @returns a new Path2 starting at the coordinates (x, y).
  63845. */
  63846. static StartingAt(x: number, y: number): Path2;
  63847. }
  63848. /**
  63849. * Represents a 3D path made up of multiple 3D points
  63850. */
  63851. export class Path3D {
  63852. /**
  63853. * an array of Vector3, the curve axis of the Path3D
  63854. */
  63855. path: Vector3[];
  63856. private _curve;
  63857. private _distances;
  63858. private _tangents;
  63859. private _normals;
  63860. private _binormals;
  63861. private _raw;
  63862. /**
  63863. * new Path3D(path, normal, raw)
  63864. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63865. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63866. * @param path an array of Vector3, the curve axis of the Path3D
  63867. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63868. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63869. */
  63870. constructor(
  63871. /**
  63872. * an array of Vector3, the curve axis of the Path3D
  63873. */
  63874. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63875. /**
  63876. * Returns the Path3D array of successive Vector3 designing its curve.
  63877. * @returns the Path3D array of successive Vector3 designing its curve.
  63878. */
  63879. getCurve(): Vector3[];
  63880. /**
  63881. * Returns an array populated with tangent vectors on each Path3D curve point.
  63882. * @returns an array populated with tangent vectors on each Path3D curve point.
  63883. */
  63884. getTangents(): Vector3[];
  63885. /**
  63886. * Returns an array populated with normal vectors on each Path3D curve point.
  63887. * @returns an array populated with normal vectors on each Path3D curve point.
  63888. */
  63889. getNormals(): Vector3[];
  63890. /**
  63891. * Returns an array populated with binormal vectors on each Path3D curve point.
  63892. * @returns an array populated with binormal vectors on each Path3D curve point.
  63893. */
  63894. getBinormals(): Vector3[];
  63895. /**
  63896. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63897. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63898. */
  63899. getDistances(): number[];
  63900. /**
  63901. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63902. * @param path path which all values are copied into the curves points
  63903. * @param firstNormal which should be projected onto the curve
  63904. * @returns the same object updated.
  63905. */
  63906. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63907. private _compute;
  63908. private _getFirstNonNullVector;
  63909. private _getLastNonNullVector;
  63910. private _normalVector;
  63911. }
  63912. /**
  63913. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63914. * A Curve3 is designed from a series of successive Vector3.
  63915. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63916. */
  63917. export class Curve3 {
  63918. private _points;
  63919. private _length;
  63920. /**
  63921. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63922. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63923. * @param v1 (Vector3) the control point
  63924. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63925. * @param nbPoints (integer) the wanted number of points in the curve
  63926. * @returns the created Curve3
  63927. */
  63928. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63929. /**
  63930. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63931. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63932. * @param v1 (Vector3) the first control point
  63933. * @param v2 (Vector3) the second control point
  63934. * @param v3 (Vector3) the end point of the Cubic Bezier
  63935. * @param nbPoints (integer) the wanted number of points in the curve
  63936. * @returns the created Curve3
  63937. */
  63938. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63939. /**
  63940. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63941. * @param p1 (Vector3) the origin point of the Hermite Spline
  63942. * @param t1 (Vector3) the tangent vector at the origin point
  63943. * @param p2 (Vector3) the end point of the Hermite Spline
  63944. * @param t2 (Vector3) the tangent vector at the end point
  63945. * @param nbPoints (integer) the wanted number of points in the curve
  63946. * @returns the created Curve3
  63947. */
  63948. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63949. /**
  63950. * Returns a Curve3 object along a CatmullRom Spline curve :
  63951. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63952. * @param nbPoints (integer) the wanted number of points between each curve control points
  63953. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63954. * @returns the created Curve3
  63955. */
  63956. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63957. /**
  63958. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63959. * A Curve3 is designed from a series of successive Vector3.
  63960. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63961. * @param points points which make up the curve
  63962. */
  63963. constructor(points: Vector3[]);
  63964. /**
  63965. * @returns the Curve3 stored array of successive Vector3
  63966. */
  63967. getPoints(): Vector3[];
  63968. /**
  63969. * @returns the computed length (float) of the curve.
  63970. */
  63971. length(): number;
  63972. /**
  63973. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63974. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63975. * curveA and curveB keep unchanged.
  63976. * @param curve the curve to continue from this curve
  63977. * @returns the newly constructed curve
  63978. */
  63979. continue(curve: DeepImmutable<Curve3>): Curve3;
  63980. private _computeLength;
  63981. }
  63982. /**
  63983. * Contains position and normal vectors for a vertex
  63984. */
  63985. export class PositionNormalVertex {
  63986. /** the position of the vertex (defaut: 0,0,0) */
  63987. position: Vector3;
  63988. /** the normal of the vertex (defaut: 0,1,0) */
  63989. normal: Vector3;
  63990. /**
  63991. * Creates a PositionNormalVertex
  63992. * @param position the position of the vertex (defaut: 0,0,0)
  63993. * @param normal the normal of the vertex (defaut: 0,1,0)
  63994. */
  63995. constructor(
  63996. /** the position of the vertex (defaut: 0,0,0) */
  63997. position?: Vector3,
  63998. /** the normal of the vertex (defaut: 0,1,0) */
  63999. normal?: Vector3);
  64000. /**
  64001. * Clones the PositionNormalVertex
  64002. * @returns the cloned PositionNormalVertex
  64003. */
  64004. clone(): PositionNormalVertex;
  64005. }
  64006. /**
  64007. * Contains position, normal and uv vectors for a vertex
  64008. */
  64009. export class PositionNormalTextureVertex {
  64010. /** the position of the vertex (defaut: 0,0,0) */
  64011. position: Vector3;
  64012. /** the normal of the vertex (defaut: 0,1,0) */
  64013. normal: Vector3;
  64014. /** the uv of the vertex (default: 0,0) */
  64015. uv: Vector2;
  64016. /**
  64017. * Creates a PositionNormalTextureVertex
  64018. * @param position the position of the vertex (defaut: 0,0,0)
  64019. * @param normal the normal of the vertex (defaut: 0,1,0)
  64020. * @param uv the uv of the vertex (default: 0,0)
  64021. */
  64022. constructor(
  64023. /** the position of the vertex (defaut: 0,0,0) */
  64024. position?: Vector3,
  64025. /** the normal of the vertex (defaut: 0,1,0) */
  64026. normal?: Vector3,
  64027. /** the uv of the vertex (default: 0,0) */
  64028. uv?: Vector2);
  64029. /**
  64030. * Clones the PositionNormalTextureVertex
  64031. * @returns the cloned PositionNormalTextureVertex
  64032. */
  64033. clone(): PositionNormalTextureVertex;
  64034. }
  64035. /**
  64036. * @hidden
  64037. */
  64038. export class Tmp {
  64039. static Color3: Color3[];
  64040. static Color4: Color4[];
  64041. static Vector2: Vector2[];
  64042. static Vector3: Vector3[];
  64043. static Vector4: Vector4[];
  64044. static Quaternion: Quaternion[];
  64045. static Matrix: Matrix[];
  64046. }
  64047. }
  64048. declare module BABYLON {
  64049. /**
  64050. * Class used to enable access to offline support
  64051. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64052. */
  64053. export interface IOfflineProvider {
  64054. /**
  64055. * Gets a boolean indicating if scene must be saved in the database
  64056. */
  64057. enableSceneOffline: boolean;
  64058. /**
  64059. * Gets a boolean indicating if textures must be saved in the database
  64060. */
  64061. enableTexturesOffline: boolean;
  64062. /**
  64063. * Open the offline support and make it available
  64064. * @param successCallback defines the callback to call on success
  64065. * @param errorCallback defines the callback to call on error
  64066. */
  64067. open(successCallback: () => void, errorCallback: () => void): void;
  64068. /**
  64069. * Loads an image from the offline support
  64070. * @param url defines the url to load from
  64071. * @param image defines the target DOM image
  64072. */
  64073. loadImage(url: string, image: HTMLImageElement): void;
  64074. /**
  64075. * Loads a file from offline support
  64076. * @param url defines the URL to load from
  64077. * @param sceneLoaded defines a callback to call on success
  64078. * @param progressCallBack defines a callback to call when progress changed
  64079. * @param errorCallback defines a callback to call on error
  64080. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64081. */
  64082. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64083. }
  64084. }
  64085. declare module BABYLON {
  64086. /**
  64087. * A class serves as a medium between the observable and its observers
  64088. */
  64089. export class EventState {
  64090. /**
  64091. * Create a new EventState
  64092. * @param mask defines the mask associated with this state
  64093. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64094. * @param target defines the original target of the state
  64095. * @param currentTarget defines the current target of the state
  64096. */
  64097. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64098. /**
  64099. * Initialize the current event state
  64100. * @param mask defines the mask associated with this state
  64101. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64102. * @param target defines the original target of the state
  64103. * @param currentTarget defines the current target of the state
  64104. * @returns the current event state
  64105. */
  64106. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64107. /**
  64108. * An Observer can set this property to true to prevent subsequent observers of being notified
  64109. */
  64110. skipNextObservers: boolean;
  64111. /**
  64112. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64113. */
  64114. mask: number;
  64115. /**
  64116. * The object that originally notified the event
  64117. */
  64118. target?: any;
  64119. /**
  64120. * The current object in the bubbling phase
  64121. */
  64122. currentTarget?: any;
  64123. /**
  64124. * This will be populated with the return value of the last function that was executed.
  64125. * If it is the first function in the callback chain it will be the event data.
  64126. */
  64127. lastReturnValue?: any;
  64128. }
  64129. /**
  64130. * Represent an Observer registered to a given Observable object.
  64131. */
  64132. export class Observer<T> {
  64133. /**
  64134. * Defines the callback to call when the observer is notified
  64135. */
  64136. callback: (eventData: T, eventState: EventState) => void;
  64137. /**
  64138. * Defines the mask of the observer (used to filter notifications)
  64139. */
  64140. mask: number;
  64141. /**
  64142. * Defines the current scope used to restore the JS context
  64143. */
  64144. scope: any;
  64145. /** @hidden */
  64146. _willBeUnregistered: boolean;
  64147. /**
  64148. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64149. */
  64150. unregisterOnNextCall: boolean;
  64151. /**
  64152. * Creates a new observer
  64153. * @param callback defines the callback to call when the observer is notified
  64154. * @param mask defines the mask of the observer (used to filter notifications)
  64155. * @param scope defines the current scope used to restore the JS context
  64156. */
  64157. constructor(
  64158. /**
  64159. * Defines the callback to call when the observer is notified
  64160. */
  64161. callback: (eventData: T, eventState: EventState) => void,
  64162. /**
  64163. * Defines the mask of the observer (used to filter notifications)
  64164. */
  64165. mask: number,
  64166. /**
  64167. * Defines the current scope used to restore the JS context
  64168. */
  64169. scope?: any);
  64170. }
  64171. /**
  64172. * Represent a list of observers registered to multiple Observables object.
  64173. */
  64174. export class MultiObserver<T> {
  64175. private _observers;
  64176. private _observables;
  64177. /**
  64178. * Release associated resources
  64179. */
  64180. dispose(): void;
  64181. /**
  64182. * Raise a callback when one of the observable will notify
  64183. * @param observables defines a list of observables to watch
  64184. * @param callback defines the callback to call on notification
  64185. * @param mask defines the mask used to filter notifications
  64186. * @param scope defines the current scope used to restore the JS context
  64187. * @returns the new MultiObserver
  64188. */
  64189. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64190. }
  64191. /**
  64192. * The Observable class is a simple implementation of the Observable pattern.
  64193. *
  64194. * 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.
  64195. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64196. * 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).
  64197. * 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.
  64198. */
  64199. export class Observable<T> {
  64200. private _observers;
  64201. private _eventState;
  64202. private _onObserverAdded;
  64203. /**
  64204. * Creates a new observable
  64205. * @param onObserverAdded defines a callback to call when a new observer is added
  64206. */
  64207. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64208. /**
  64209. * Create a new Observer with the specified callback
  64210. * @param callback the callback that will be executed for that Observer
  64211. * @param mask the mask used to filter observers
  64212. * @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.
  64213. * @param scope optional scope for the callback to be called from
  64214. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64215. * @returns the new observer created for the callback
  64216. */
  64217. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64218. /**
  64219. * Create a new Observer with the specified callback and unregisters after the next notification
  64220. * @param callback the callback that will be executed for that Observer
  64221. * @returns the new observer created for the callback
  64222. */
  64223. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64224. /**
  64225. * Remove an Observer from the Observable object
  64226. * @param observer the instance of the Observer to remove
  64227. * @returns false if it doesn't belong to this Observable
  64228. */
  64229. remove(observer: Nullable<Observer<T>>): boolean;
  64230. /**
  64231. * Remove a callback from the Observable object
  64232. * @param callback the callback to remove
  64233. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64234. * @returns false if it doesn't belong to this Observable
  64235. */
  64236. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64237. private _deferUnregister;
  64238. private _remove;
  64239. /**
  64240. * Moves the observable to the top of the observer list making it get called first when notified
  64241. * @param observer the observer to move
  64242. */
  64243. makeObserverTopPriority(observer: Observer<T>): void;
  64244. /**
  64245. * Moves the observable to the bottom of the observer list making it get called last when notified
  64246. * @param observer the observer to move
  64247. */
  64248. makeObserverBottomPriority(observer: Observer<T>): void;
  64249. /**
  64250. * Notify all Observers by calling their respective callback with the given data
  64251. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64252. * @param eventData defines the data to send to all observers
  64253. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64254. * @param target defines the original target of the state
  64255. * @param currentTarget defines the current target of the state
  64256. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64257. */
  64258. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64259. /**
  64260. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64261. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64262. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64263. * and it is crucial that all callbacks will be executed.
  64264. * The order of the callbacks is kept, callbacks are not executed parallel.
  64265. *
  64266. * @param eventData The data to be sent to each callback
  64267. * @param mask is used to filter observers defaults to -1
  64268. * @param target defines the callback target (see EventState)
  64269. * @param currentTarget defines he current object in the bubbling phase
  64270. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64271. */
  64272. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64273. /**
  64274. * Notify a specific observer
  64275. * @param observer defines the observer to notify
  64276. * @param eventData defines the data to be sent to each callback
  64277. * @param mask is used to filter observers defaults to -1
  64278. */
  64279. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64280. /**
  64281. * Gets a boolean indicating if the observable has at least one observer
  64282. * @returns true is the Observable has at least one Observer registered
  64283. */
  64284. hasObservers(): boolean;
  64285. /**
  64286. * Clear the list of observers
  64287. */
  64288. clear(): void;
  64289. /**
  64290. * Clone the current observable
  64291. * @returns a new observable
  64292. */
  64293. clone(): Observable<T>;
  64294. /**
  64295. * Does this observable handles observer registered with a given mask
  64296. * @param mask defines the mask to be tested
  64297. * @return whether or not one observer registered with the given mask is handeled
  64298. **/
  64299. hasSpecificMask(mask?: number): boolean;
  64300. }
  64301. }
  64302. declare module BABYLON {
  64303. /**
  64304. * Class used to help managing file picking and drag'n'drop
  64305. * File Storage
  64306. */
  64307. export class FilesInputStore {
  64308. /**
  64309. * List of files ready to be loaded
  64310. */
  64311. static FilesToLoad: {
  64312. [key: string]: File;
  64313. };
  64314. }
  64315. }
  64316. declare module BABYLON {
  64317. /** Defines the cross module used constants to avoid circular dependncies */
  64318. export class Constants {
  64319. /** Defines that alpha blending is disabled */
  64320. static readonly ALPHA_DISABLE: number;
  64321. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64322. static readonly ALPHA_ADD: number;
  64323. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64324. static readonly ALPHA_COMBINE: number;
  64325. /** Defines that alpha blending to DEST - SRC * DEST */
  64326. static readonly ALPHA_SUBTRACT: number;
  64327. /** Defines that alpha blending to SRC * DEST */
  64328. static readonly ALPHA_MULTIPLY: number;
  64329. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64330. static readonly ALPHA_MAXIMIZED: number;
  64331. /** Defines that alpha blending to SRC + DEST */
  64332. static readonly ALPHA_ONEONE: number;
  64333. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64334. static readonly ALPHA_PREMULTIPLIED: number;
  64335. /**
  64336. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64337. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64338. */
  64339. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64340. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64341. static readonly ALPHA_INTERPOLATE: number;
  64342. /**
  64343. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64344. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64345. */
  64346. static readonly ALPHA_SCREENMODE: number;
  64347. /** Defines that the ressource is not delayed*/
  64348. static readonly DELAYLOADSTATE_NONE: number;
  64349. /** Defines that the ressource was successfully delay loaded */
  64350. static readonly DELAYLOADSTATE_LOADED: number;
  64351. /** Defines that the ressource is currently delay loading */
  64352. static readonly DELAYLOADSTATE_LOADING: number;
  64353. /** Defines that the ressource is delayed and has not started loading */
  64354. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64356. static readonly NEVER: number;
  64357. /** 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 */
  64358. static readonly ALWAYS: number;
  64359. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64360. static readonly LESS: number;
  64361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64362. static readonly EQUAL: number;
  64363. /** 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 */
  64364. static readonly LEQUAL: number;
  64365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64366. static readonly GREATER: number;
  64367. /** 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 */
  64368. static readonly GEQUAL: number;
  64369. /** 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 */
  64370. static readonly NOTEQUAL: number;
  64371. /** Passed to stencilOperation to specify that stencil value must be kept */
  64372. static readonly KEEP: number;
  64373. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64374. static readonly REPLACE: number;
  64375. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64376. static readonly INCR: number;
  64377. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64378. static readonly DECR: number;
  64379. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64380. static readonly INVERT: number;
  64381. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64382. static readonly INCR_WRAP: number;
  64383. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64384. static readonly DECR_WRAP: number;
  64385. /** Texture is not repeating outside of 0..1 UVs */
  64386. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64387. /** Texture is repeating outside of 0..1 UVs */
  64388. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64389. /** Texture is repeating and mirrored */
  64390. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64391. /** ALPHA */
  64392. static readonly TEXTUREFORMAT_ALPHA: number;
  64393. /** LUMINANCE */
  64394. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64395. /** LUMINANCE_ALPHA */
  64396. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64397. /** RGB */
  64398. static readonly TEXTUREFORMAT_RGB: number;
  64399. /** RGBA */
  64400. static readonly TEXTUREFORMAT_RGBA: number;
  64401. /** RED */
  64402. static readonly TEXTUREFORMAT_RED: number;
  64403. /** RED (2nd reference) */
  64404. static readonly TEXTUREFORMAT_R: number;
  64405. /** RG */
  64406. static readonly TEXTUREFORMAT_RG: number;
  64407. /** RED_INTEGER */
  64408. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64409. /** RED_INTEGER (2nd reference) */
  64410. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64411. /** RG_INTEGER */
  64412. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64413. /** RGB_INTEGER */
  64414. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64415. /** RGBA_INTEGER */
  64416. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64417. /** UNSIGNED_BYTE */
  64418. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64419. /** UNSIGNED_BYTE (2nd reference) */
  64420. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64421. /** FLOAT */
  64422. static readonly TEXTURETYPE_FLOAT: number;
  64423. /** HALF_FLOAT */
  64424. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64425. /** BYTE */
  64426. static readonly TEXTURETYPE_BYTE: number;
  64427. /** SHORT */
  64428. static readonly TEXTURETYPE_SHORT: number;
  64429. /** UNSIGNED_SHORT */
  64430. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64431. /** INT */
  64432. static readonly TEXTURETYPE_INT: number;
  64433. /** UNSIGNED_INT */
  64434. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64435. /** UNSIGNED_SHORT_4_4_4_4 */
  64436. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64437. /** UNSIGNED_SHORT_5_5_5_1 */
  64438. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64439. /** UNSIGNED_SHORT_5_6_5 */
  64440. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64441. /** UNSIGNED_INT_2_10_10_10_REV */
  64442. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64443. /** UNSIGNED_INT_24_8 */
  64444. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64445. /** UNSIGNED_INT_10F_11F_11F_REV */
  64446. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64447. /** UNSIGNED_INT_5_9_9_9_REV */
  64448. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64449. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64450. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64451. /** nearest is mag = nearest and min = nearest and mip = linear */
  64452. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64453. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64454. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64455. /** Trilinear is mag = linear and min = linear and mip = linear */
  64456. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64457. /** nearest is mag = nearest and min = nearest and mip = linear */
  64458. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64459. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64460. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64461. /** Trilinear is mag = linear and min = linear and mip = linear */
  64462. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64463. /** mag = nearest and min = nearest and mip = nearest */
  64464. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64465. /** mag = nearest and min = linear and mip = nearest */
  64466. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64467. /** mag = nearest and min = linear and mip = linear */
  64468. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64469. /** mag = nearest and min = linear and mip = none */
  64470. static readonly TEXTURE_NEAREST_LINEAR: number;
  64471. /** mag = nearest and min = nearest and mip = none */
  64472. static readonly TEXTURE_NEAREST_NEAREST: number;
  64473. /** mag = linear and min = nearest and mip = nearest */
  64474. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64475. /** mag = linear and min = nearest and mip = linear */
  64476. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64477. /** mag = linear and min = linear and mip = none */
  64478. static readonly TEXTURE_LINEAR_LINEAR: number;
  64479. /** mag = linear and min = nearest and mip = none */
  64480. static readonly TEXTURE_LINEAR_NEAREST: number;
  64481. /** Explicit coordinates mode */
  64482. static readonly TEXTURE_EXPLICIT_MODE: number;
  64483. /** Spherical coordinates mode */
  64484. static readonly TEXTURE_SPHERICAL_MODE: number;
  64485. /** Planar coordinates mode */
  64486. static readonly TEXTURE_PLANAR_MODE: number;
  64487. /** Cubic coordinates mode */
  64488. static readonly TEXTURE_CUBIC_MODE: number;
  64489. /** Projection coordinates mode */
  64490. static readonly TEXTURE_PROJECTION_MODE: number;
  64491. /** Skybox coordinates mode */
  64492. static readonly TEXTURE_SKYBOX_MODE: number;
  64493. /** Inverse Cubic coordinates mode */
  64494. static readonly TEXTURE_INVCUBIC_MODE: number;
  64495. /** Equirectangular coordinates mode */
  64496. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64497. /** Equirectangular Fixed coordinates mode */
  64498. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64499. /** Equirectangular Fixed Mirrored coordinates mode */
  64500. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64501. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64502. static readonly SCALEMODE_FLOOR: number;
  64503. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64504. static readonly SCALEMODE_NEAREST: number;
  64505. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64506. static readonly SCALEMODE_CEILING: number;
  64507. /**
  64508. * The dirty texture flag value
  64509. */
  64510. static readonly MATERIAL_TextureDirtyFlag: number;
  64511. /**
  64512. * The dirty light flag value
  64513. */
  64514. static readonly MATERIAL_LightDirtyFlag: number;
  64515. /**
  64516. * The dirty fresnel flag value
  64517. */
  64518. static readonly MATERIAL_FresnelDirtyFlag: number;
  64519. /**
  64520. * The dirty attribute flag value
  64521. */
  64522. static readonly MATERIAL_AttributesDirtyFlag: number;
  64523. /**
  64524. * The dirty misc flag value
  64525. */
  64526. static readonly MATERIAL_MiscDirtyFlag: number;
  64527. /**
  64528. * The all dirty flag value
  64529. */
  64530. static readonly MATERIAL_AllDirtyFlag: number;
  64531. /**
  64532. * Returns the triangle fill mode
  64533. */
  64534. static readonly MATERIAL_TriangleFillMode: number;
  64535. /**
  64536. * Returns the wireframe mode
  64537. */
  64538. static readonly MATERIAL_WireFrameFillMode: number;
  64539. /**
  64540. * Returns the point fill mode
  64541. */
  64542. static readonly MATERIAL_PointFillMode: number;
  64543. /**
  64544. * Returns the point list draw mode
  64545. */
  64546. static readonly MATERIAL_PointListDrawMode: number;
  64547. /**
  64548. * Returns the line list draw mode
  64549. */
  64550. static readonly MATERIAL_LineListDrawMode: number;
  64551. /**
  64552. * Returns the line loop draw mode
  64553. */
  64554. static readonly MATERIAL_LineLoopDrawMode: number;
  64555. /**
  64556. * Returns the line strip draw mode
  64557. */
  64558. static readonly MATERIAL_LineStripDrawMode: number;
  64559. /**
  64560. * Returns the triangle strip draw mode
  64561. */
  64562. static readonly MATERIAL_TriangleStripDrawMode: number;
  64563. /**
  64564. * Returns the triangle fan draw mode
  64565. */
  64566. static readonly MATERIAL_TriangleFanDrawMode: number;
  64567. /**
  64568. * Stores the clock-wise side orientation
  64569. */
  64570. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64571. /**
  64572. * Stores the counter clock-wise side orientation
  64573. */
  64574. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64575. /**
  64576. * Nothing
  64577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64578. */
  64579. static readonly ACTION_NothingTrigger: number;
  64580. /**
  64581. * On pick
  64582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64583. */
  64584. static readonly ACTION_OnPickTrigger: number;
  64585. /**
  64586. * On left pick
  64587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64588. */
  64589. static readonly ACTION_OnLeftPickTrigger: number;
  64590. /**
  64591. * On right pick
  64592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64593. */
  64594. static readonly ACTION_OnRightPickTrigger: number;
  64595. /**
  64596. * On center pick
  64597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64598. */
  64599. static readonly ACTION_OnCenterPickTrigger: number;
  64600. /**
  64601. * On pick down
  64602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64603. */
  64604. static readonly ACTION_OnPickDownTrigger: number;
  64605. /**
  64606. * On double pick
  64607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64608. */
  64609. static readonly ACTION_OnDoublePickTrigger: number;
  64610. /**
  64611. * On pick up
  64612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64613. */
  64614. static readonly ACTION_OnPickUpTrigger: number;
  64615. /**
  64616. * On pick out.
  64617. * This trigger will only be raised if you also declared a OnPickDown
  64618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64619. */
  64620. static readonly ACTION_OnPickOutTrigger: number;
  64621. /**
  64622. * On long press
  64623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64624. */
  64625. static readonly ACTION_OnLongPressTrigger: number;
  64626. /**
  64627. * On pointer over
  64628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64629. */
  64630. static readonly ACTION_OnPointerOverTrigger: number;
  64631. /**
  64632. * On pointer out
  64633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64634. */
  64635. static readonly ACTION_OnPointerOutTrigger: number;
  64636. /**
  64637. * On every frame
  64638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64639. */
  64640. static readonly ACTION_OnEveryFrameTrigger: number;
  64641. /**
  64642. * On intersection enter
  64643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64644. */
  64645. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64646. /**
  64647. * On intersection exit
  64648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64649. */
  64650. static readonly ACTION_OnIntersectionExitTrigger: number;
  64651. /**
  64652. * On key down
  64653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64654. */
  64655. static readonly ACTION_OnKeyDownTrigger: number;
  64656. /**
  64657. * On key up
  64658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64659. */
  64660. static readonly ACTION_OnKeyUpTrigger: number;
  64661. /**
  64662. * Billboard mode will only apply to Y axis
  64663. */
  64664. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64665. /**
  64666. * Billboard mode will apply to all axes
  64667. */
  64668. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64669. /**
  64670. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64671. */
  64672. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64673. /**
  64674. * Gets or sets base Assets URL
  64675. */
  64676. static readonly PARTICLES_BaseAssetsUrl: string;
  64677. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64678. * Test order :
  64679. * Is the bounding sphere outside the frustum ?
  64680. * If not, are the bounding box vertices outside the frustum ?
  64681. * It not, then the cullable object is in the frustum.
  64682. */
  64683. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64684. /** Culling strategy : Bounding Sphere Only.
  64685. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64686. * It's also less accurate than the standard because some not visible objects can still be selected.
  64687. * Test : is the bounding sphere outside the frustum ?
  64688. * If not, then the cullable object is in the frustum.
  64689. */
  64690. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64691. /** Culling strategy : Optimistic Inclusion.
  64692. * This in an inclusion test first, then the standard exclusion test.
  64693. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64694. * 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.
  64695. * Anyway, it's as accurate as the standard strategy.
  64696. * Test :
  64697. * Is the cullable object bounding sphere center in the frustum ?
  64698. * If not, apply the default culling strategy.
  64699. */
  64700. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64701. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64702. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64703. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64704. * 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.
  64705. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64706. * Test :
  64707. * Is the cullable object bounding sphere center in the frustum ?
  64708. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64709. */
  64710. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64711. /**
  64712. * No logging while loading
  64713. */
  64714. static readonly SCENELOADER_NO_LOGGING: number;
  64715. /**
  64716. * Minimal logging while loading
  64717. */
  64718. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64719. /**
  64720. * Summary logging while loading
  64721. */
  64722. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64723. /**
  64724. * Detailled logging while loading
  64725. */
  64726. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64727. }
  64728. }
  64729. declare module BABYLON {
  64730. /**
  64731. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64732. * Babylon.js
  64733. */
  64734. export class DomManagement {
  64735. /**
  64736. * Checks if the window object exists
  64737. * @returns true if the window object exists
  64738. */
  64739. static IsWindowObjectExist(): boolean;
  64740. /**
  64741. * Extracts text content from a DOM element hierarchy
  64742. * @param element defines the root element
  64743. * @returns a string
  64744. */
  64745. static GetDOMTextContent(element: HTMLElement): string;
  64746. }
  64747. }
  64748. declare module BABYLON {
  64749. /**
  64750. * Logger used througouht the application to allow configuration of
  64751. * the log level required for the messages.
  64752. */
  64753. export class Logger {
  64754. /**
  64755. * No log
  64756. */
  64757. static readonly NoneLogLevel: number;
  64758. /**
  64759. * Only message logs
  64760. */
  64761. static readonly MessageLogLevel: number;
  64762. /**
  64763. * Only warning logs
  64764. */
  64765. static readonly WarningLogLevel: number;
  64766. /**
  64767. * Only error logs
  64768. */
  64769. static readonly ErrorLogLevel: number;
  64770. /**
  64771. * All logs
  64772. */
  64773. static readonly AllLogLevel: number;
  64774. private static _LogCache;
  64775. /**
  64776. * Gets a value indicating the number of loading errors
  64777. * @ignorenaming
  64778. */
  64779. static errorsCount: number;
  64780. /**
  64781. * Callback called when a new log is added
  64782. */
  64783. static OnNewCacheEntry: (entry: string) => void;
  64784. private static _AddLogEntry;
  64785. private static _FormatMessage;
  64786. private static _LogDisabled;
  64787. private static _LogEnabled;
  64788. private static _WarnDisabled;
  64789. private static _WarnEnabled;
  64790. private static _ErrorDisabled;
  64791. private static _ErrorEnabled;
  64792. /**
  64793. * Log a message to the console
  64794. */
  64795. static Log: (message: string) => void;
  64796. /**
  64797. * Write a warning message to the console
  64798. */
  64799. static Warn: (message: string) => void;
  64800. /**
  64801. * Write an error message to the console
  64802. */
  64803. static Error: (message: string) => void;
  64804. /**
  64805. * Gets current log cache (list of logs)
  64806. */
  64807. static readonly LogCache: string;
  64808. /**
  64809. * Clears the log cache
  64810. */
  64811. static ClearLogCache(): void;
  64812. /**
  64813. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64814. */
  64815. static LogLevels: number;
  64816. }
  64817. }
  64818. declare module BABYLON {
  64819. /** @hidden */
  64820. export class _TypeStore {
  64821. /** @hidden */
  64822. static RegisteredTypes: {
  64823. [key: string]: Object;
  64824. };
  64825. /** @hidden */
  64826. static GetClass(fqdn: string): any;
  64827. }
  64828. }
  64829. declare module BABYLON {
  64830. /**
  64831. * Class containing a set of static utilities functions for deep copy.
  64832. */
  64833. export class DeepCopier {
  64834. /**
  64835. * Tries to copy an object by duplicating every property
  64836. * @param source defines the source object
  64837. * @param destination defines the target object
  64838. * @param doNotCopyList defines a list of properties to avoid
  64839. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64840. */
  64841. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64842. }
  64843. }
  64844. declare module BABYLON {
  64845. /**
  64846. * Class containing a set of static utilities functions for precision date
  64847. */
  64848. export class PrecisionDate {
  64849. /**
  64850. * Gets either window.performance.now() if supported or Date.now() else
  64851. */
  64852. static readonly Now: number;
  64853. }
  64854. }
  64855. declare module BABYLON {
  64856. /** @hidden */
  64857. export class _DevTools {
  64858. static WarnImport(name: string): string;
  64859. }
  64860. }
  64861. declare module BABYLON {
  64862. /**
  64863. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64864. */
  64865. export class WebRequest {
  64866. private _xhr;
  64867. /**
  64868. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64869. * i.e. when loading files, where the server/service expects an Authorization header
  64870. */
  64871. static CustomRequestHeaders: {
  64872. [key: string]: string;
  64873. };
  64874. /**
  64875. * Add callback functions in this array to update all the requests before they get sent to the network
  64876. */
  64877. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64878. private _injectCustomRequestHeaders;
  64879. /**
  64880. * Gets or sets a function to be called when loading progress changes
  64881. */
  64882. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64883. /**
  64884. * Returns client's state
  64885. */
  64886. readonly readyState: number;
  64887. /**
  64888. * Returns client's status
  64889. */
  64890. readonly status: number;
  64891. /**
  64892. * Returns client's status as a text
  64893. */
  64894. readonly statusText: string;
  64895. /**
  64896. * Returns client's response
  64897. */
  64898. readonly response: any;
  64899. /**
  64900. * Returns client's response url
  64901. */
  64902. readonly responseURL: string;
  64903. /**
  64904. * Returns client's response as text
  64905. */
  64906. readonly responseText: string;
  64907. /**
  64908. * Gets or sets the expected response type
  64909. */
  64910. responseType: XMLHttpRequestResponseType;
  64911. /** @hidden */
  64912. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64913. /** @hidden */
  64914. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64915. /**
  64916. * Cancels any network activity
  64917. */
  64918. abort(): void;
  64919. /**
  64920. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64921. * @param body defines an optional request body
  64922. */
  64923. send(body?: Document | BodyInit | null): void;
  64924. /**
  64925. * Sets the request method, request URL
  64926. * @param method defines the method to use (GET, POST, etc..)
  64927. * @param url defines the url to connect with
  64928. */
  64929. open(method: string, url: string): void;
  64930. }
  64931. }
  64932. declare module BABYLON {
  64933. /**
  64934. * Class used to evalaute queries containing `and` and `or` operators
  64935. */
  64936. export class AndOrNotEvaluator {
  64937. /**
  64938. * Evaluate a query
  64939. * @param query defines the query to evaluate
  64940. * @param evaluateCallback defines the callback used to filter result
  64941. * @returns true if the query matches
  64942. */
  64943. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64944. private static _HandleParenthesisContent;
  64945. private static _SimplifyNegation;
  64946. }
  64947. }
  64948. declare module BABYLON {
  64949. /**
  64950. * Class used to store custom tags
  64951. */
  64952. export class Tags {
  64953. /**
  64954. * Adds support for tags on the given object
  64955. * @param obj defines the object to use
  64956. */
  64957. static EnableFor(obj: any): void;
  64958. /**
  64959. * Removes tags support
  64960. * @param obj defines the object to use
  64961. */
  64962. static DisableFor(obj: any): void;
  64963. /**
  64964. * Gets a boolean indicating if the given object has tags
  64965. * @param obj defines the object to use
  64966. * @returns a boolean
  64967. */
  64968. static HasTags(obj: any): boolean;
  64969. /**
  64970. * Gets the tags available on a given object
  64971. * @param obj defines the object to use
  64972. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64973. * @returns the tags
  64974. */
  64975. static GetTags(obj: any, asString?: boolean): any;
  64976. /**
  64977. * Adds tags to an object
  64978. * @param obj defines the object to use
  64979. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64980. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64981. */
  64982. static AddTagsTo(obj: any, tagsString: string): void;
  64983. /**
  64984. * @hidden
  64985. */
  64986. static _AddTagTo(obj: any, tag: string): void;
  64987. /**
  64988. * Removes specific tags from a specific object
  64989. * @param obj defines the object to use
  64990. * @param tagsString defines the tags to remove
  64991. */
  64992. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64993. /**
  64994. * @hidden
  64995. */
  64996. static _RemoveTagFrom(obj: any, tag: string): void;
  64997. /**
  64998. * Defines if tags hosted on an object match a given query
  64999. * @param obj defines the object to use
  65000. * @param tagsQuery defines the tag query
  65001. * @returns a boolean
  65002. */
  65003. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65004. }
  65005. }
  65006. declare module BABYLON {
  65007. /**
  65008. * Manages the defines for the Material
  65009. */
  65010. export class MaterialDefines {
  65011. private _keys;
  65012. private _isDirty;
  65013. /** @hidden */
  65014. _renderId: number;
  65015. /** @hidden */
  65016. _areLightsDirty: boolean;
  65017. /** @hidden */
  65018. _areAttributesDirty: boolean;
  65019. /** @hidden */
  65020. _areTexturesDirty: boolean;
  65021. /** @hidden */
  65022. _areFresnelDirty: boolean;
  65023. /** @hidden */
  65024. _areMiscDirty: boolean;
  65025. /** @hidden */
  65026. _areImageProcessingDirty: boolean;
  65027. /** @hidden */
  65028. _normals: boolean;
  65029. /** @hidden */
  65030. _uvs: boolean;
  65031. /** @hidden */
  65032. _needNormals: boolean;
  65033. /** @hidden */
  65034. _needUVs: boolean;
  65035. /**
  65036. * Specifies if the material needs to be re-calculated
  65037. */
  65038. readonly isDirty: boolean;
  65039. /**
  65040. * Marks the material to indicate that it has been re-calculated
  65041. */
  65042. markAsProcessed(): void;
  65043. /**
  65044. * Marks the material to indicate that it needs to be re-calculated
  65045. */
  65046. markAsUnprocessed(): void;
  65047. /**
  65048. * Marks the material to indicate all of its defines need to be re-calculated
  65049. */
  65050. markAllAsDirty(): void;
  65051. /**
  65052. * Marks the material to indicate that image processing needs to be re-calculated
  65053. */
  65054. markAsImageProcessingDirty(): void;
  65055. /**
  65056. * Marks the material to indicate the lights need to be re-calculated
  65057. */
  65058. markAsLightDirty(): void;
  65059. /**
  65060. * Marks the attribute state as changed
  65061. */
  65062. markAsAttributesDirty(): void;
  65063. /**
  65064. * Marks the texture state as changed
  65065. */
  65066. markAsTexturesDirty(): void;
  65067. /**
  65068. * Marks the fresnel state as changed
  65069. */
  65070. markAsFresnelDirty(): void;
  65071. /**
  65072. * Marks the misc state as changed
  65073. */
  65074. markAsMiscDirty(): void;
  65075. /**
  65076. * Rebuilds the material defines
  65077. */
  65078. rebuild(): void;
  65079. /**
  65080. * Specifies if two material defines are equal
  65081. * @param other - A material define instance to compare to
  65082. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65083. */
  65084. isEqual(other: MaterialDefines): boolean;
  65085. /**
  65086. * Clones this instance's defines to another instance
  65087. * @param other - material defines to clone values to
  65088. */
  65089. cloneTo(other: MaterialDefines): void;
  65090. /**
  65091. * Resets the material define values
  65092. */
  65093. reset(): void;
  65094. /**
  65095. * Converts the material define values to a string
  65096. * @returns - String of material define information
  65097. */
  65098. toString(): string;
  65099. }
  65100. }
  65101. declare module BABYLON {
  65102. /**
  65103. * Class used to store and describe the pipeline context associated with an effect
  65104. */
  65105. export interface IPipelineContext {
  65106. /**
  65107. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65108. */
  65109. isAsync: boolean;
  65110. /**
  65111. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65112. */
  65113. isReady: boolean;
  65114. }
  65115. }
  65116. declare module BABYLON {
  65117. /**
  65118. * Class used to store gfx data (like WebGLBuffer)
  65119. */
  65120. export class DataBuffer {
  65121. /**
  65122. * Gets or sets the number of objects referencing this buffer
  65123. */
  65124. references: number;
  65125. /** Gets or sets the size of the underlying buffer */
  65126. capacity: number;
  65127. /**
  65128. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65129. */
  65130. is32Bits: boolean;
  65131. /**
  65132. * Gets the underlying buffer
  65133. */
  65134. readonly underlyingResource: any;
  65135. }
  65136. }
  65137. declare module BABYLON {
  65138. /**
  65139. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65140. */
  65141. export class PerformanceMonitor {
  65142. private _enabled;
  65143. private _rollingFrameTime;
  65144. private _lastFrameTimeMs;
  65145. /**
  65146. * constructor
  65147. * @param frameSampleSize The number of samples required to saturate the sliding window
  65148. */
  65149. constructor(frameSampleSize?: number);
  65150. /**
  65151. * Samples current frame
  65152. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65153. */
  65154. sampleFrame(timeMs?: number): void;
  65155. /**
  65156. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65157. */
  65158. readonly averageFrameTime: number;
  65159. /**
  65160. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65161. */
  65162. readonly averageFrameTimeVariance: number;
  65163. /**
  65164. * Returns the frame time of the most recent frame
  65165. */
  65166. readonly instantaneousFrameTime: number;
  65167. /**
  65168. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65169. */
  65170. readonly averageFPS: number;
  65171. /**
  65172. * Returns the average framerate in frames per second using the most recent frame time
  65173. */
  65174. readonly instantaneousFPS: number;
  65175. /**
  65176. * Returns true if enough samples have been taken to completely fill the sliding window
  65177. */
  65178. readonly isSaturated: boolean;
  65179. /**
  65180. * Enables contributions to the sliding window sample set
  65181. */
  65182. enable(): void;
  65183. /**
  65184. * Disables contributions to the sliding window sample set
  65185. * Samples will not be interpolated over the disabled period
  65186. */
  65187. disable(): void;
  65188. /**
  65189. * Returns true if sampling is enabled
  65190. */
  65191. readonly isEnabled: boolean;
  65192. /**
  65193. * Resets performance monitor
  65194. */
  65195. reset(): void;
  65196. }
  65197. /**
  65198. * RollingAverage
  65199. *
  65200. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65201. */
  65202. export class RollingAverage {
  65203. /**
  65204. * Current average
  65205. */
  65206. average: number;
  65207. /**
  65208. * Current variance
  65209. */
  65210. variance: number;
  65211. protected _samples: Array<number>;
  65212. protected _sampleCount: number;
  65213. protected _pos: number;
  65214. protected _m2: number;
  65215. /**
  65216. * constructor
  65217. * @param length The number of samples required to saturate the sliding window
  65218. */
  65219. constructor(length: number);
  65220. /**
  65221. * Adds a sample to the sample set
  65222. * @param v The sample value
  65223. */
  65224. add(v: number): void;
  65225. /**
  65226. * Returns previously added values or null if outside of history or outside the sliding window domain
  65227. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65228. * @return Value previously recorded with add() or null if outside of range
  65229. */
  65230. history(i: number): number;
  65231. /**
  65232. * Returns true if enough samples have been taken to completely fill the sliding window
  65233. * @return true if sample-set saturated
  65234. */
  65235. isSaturated(): boolean;
  65236. /**
  65237. * Resets the rolling average (equivalent to 0 samples taken so far)
  65238. */
  65239. reset(): void;
  65240. /**
  65241. * Wraps a value around the sample range boundaries
  65242. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65243. * @return Wrapped position in sample range
  65244. */
  65245. protected _wrapPosition(i: number): number;
  65246. }
  65247. }
  65248. declare module BABYLON {
  65249. /**
  65250. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65251. * The underlying implementation relies on an associative array to ensure the best performances.
  65252. * The value can be anything including 'null' but except 'undefined'
  65253. */
  65254. export class StringDictionary<T> {
  65255. /**
  65256. * This will clear this dictionary and copy the content from the 'source' one.
  65257. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65258. * @param source the dictionary to take the content from and copy to this dictionary
  65259. */
  65260. copyFrom(source: StringDictionary<T>): void;
  65261. /**
  65262. * Get a value based from its key
  65263. * @param key the given key to get the matching value from
  65264. * @return the value if found, otherwise undefined is returned
  65265. */
  65266. get(key: string): T | undefined;
  65267. /**
  65268. * Get a value from its key or add it if it doesn't exist.
  65269. * This method will ensure you that a given key/data will be present in the dictionary.
  65270. * @param key the given key to get the matching value from
  65271. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65272. * The factory will only be invoked if there's no data for the given key.
  65273. * @return the value corresponding to the key.
  65274. */
  65275. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65276. /**
  65277. * Get a value from its key if present in the dictionary otherwise add it
  65278. * @param key the key to get the value from
  65279. * @param val if there's no such key/value pair in the dictionary add it with this value
  65280. * @return the value corresponding to the key
  65281. */
  65282. getOrAdd(key: string, val: T): T;
  65283. /**
  65284. * Check if there's a given key in the dictionary
  65285. * @param key the key to check for
  65286. * @return true if the key is present, false otherwise
  65287. */
  65288. contains(key: string): boolean;
  65289. /**
  65290. * Add a new key and its corresponding value
  65291. * @param key the key to add
  65292. * @param value the value corresponding to the key
  65293. * @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
  65294. */
  65295. add(key: string, value: T): boolean;
  65296. /**
  65297. * Update a specific value associated to a key
  65298. * @param key defines the key to use
  65299. * @param value defines the value to store
  65300. * @returns true if the value was updated (or false if the key was not found)
  65301. */
  65302. set(key: string, value: T): boolean;
  65303. /**
  65304. * Get the element of the given key and remove it from the dictionary
  65305. * @param key defines the key to search
  65306. * @returns the value associated with the key or null if not found
  65307. */
  65308. getAndRemove(key: string): Nullable<T>;
  65309. /**
  65310. * Remove a key/value from the dictionary.
  65311. * @param key the key to remove
  65312. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65313. */
  65314. remove(key: string): boolean;
  65315. /**
  65316. * Clear the whole content of the dictionary
  65317. */
  65318. clear(): void;
  65319. /**
  65320. * Gets the current count
  65321. */
  65322. readonly count: number;
  65323. /**
  65324. * Execute a callback on each key/val of the dictionary.
  65325. * Note that you can remove any element in this dictionary in the callback implementation
  65326. * @param callback the callback to execute on a given key/value pair
  65327. */
  65328. forEach(callback: (key: string, val: T) => void): void;
  65329. /**
  65330. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65331. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65332. * Note that you can remove any element in this dictionary in the callback implementation
  65333. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65334. * @returns the first item
  65335. */
  65336. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65337. private _count;
  65338. private _data;
  65339. }
  65340. }
  65341. declare module BABYLON {
  65342. /**
  65343. * Helper class that provides a small promise polyfill
  65344. */
  65345. export class PromisePolyfill {
  65346. /**
  65347. * Static function used to check if the polyfill is required
  65348. * If this is the case then the function will inject the polyfill to window.Promise
  65349. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65350. */
  65351. static Apply(force?: boolean): void;
  65352. }
  65353. }
  65354. declare module BABYLON {
  65355. /**
  65356. * Class used to store data that will be store in GPU memory
  65357. */
  65358. export class Buffer {
  65359. private _engine;
  65360. private _buffer;
  65361. /** @hidden */
  65362. _data: Nullable<DataArray>;
  65363. private _updatable;
  65364. private _instanced;
  65365. /**
  65366. * Gets the byte stride.
  65367. */
  65368. readonly byteStride: number;
  65369. /**
  65370. * Constructor
  65371. * @param engine the engine
  65372. * @param data the data to use for this buffer
  65373. * @param updatable whether the data is updatable
  65374. * @param stride the stride (optional)
  65375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65376. * @param instanced whether the buffer is instanced (optional)
  65377. * @param useBytes set to true if the stride in in bytes (optional)
  65378. */
  65379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65380. /**
  65381. * Create a new VertexBuffer based on the current buffer
  65382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65383. * @param offset defines offset in the buffer (0 by default)
  65384. * @param size defines the size in floats of attributes (position is 3 for instance)
  65385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65386. * @param instanced defines if the vertex buffer contains indexed data
  65387. * @param useBytes defines if the offset and stride are in bytes
  65388. * @returns the new vertex buffer
  65389. */
  65390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65391. /**
  65392. * Gets a boolean indicating if the Buffer is updatable?
  65393. * @returns true if the buffer is updatable
  65394. */
  65395. isUpdatable(): boolean;
  65396. /**
  65397. * Gets current buffer's data
  65398. * @returns a DataArray or null
  65399. */
  65400. getData(): Nullable<DataArray>;
  65401. /**
  65402. * Gets underlying native buffer
  65403. * @returns underlying native buffer
  65404. */
  65405. getBuffer(): Nullable<DataBuffer>;
  65406. /**
  65407. * Gets the stride in float32 units (i.e. byte stride / 4).
  65408. * May not be an integer if the byte stride is not divisible by 4.
  65409. * DEPRECATED. Use byteStride instead.
  65410. * @returns the stride in float32 units
  65411. */
  65412. getStrideSize(): number;
  65413. /**
  65414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65415. * @param data defines the data to store
  65416. */
  65417. create(data?: Nullable<DataArray>): void;
  65418. /** @hidden */
  65419. _rebuild(): void;
  65420. /**
  65421. * Update current buffer data
  65422. * @param data defines the data to store
  65423. */
  65424. update(data: DataArray): void;
  65425. /**
  65426. * Updates the data directly.
  65427. * @param data the new data
  65428. * @param offset the new offset
  65429. * @param vertexCount the vertex count (optional)
  65430. * @param useBytes set to true if the offset is in bytes
  65431. */
  65432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65433. /**
  65434. * Release all resources
  65435. */
  65436. dispose(): void;
  65437. }
  65438. /**
  65439. * Specialized buffer used to store vertex data
  65440. */
  65441. export class VertexBuffer {
  65442. /** @hidden */
  65443. _buffer: Buffer;
  65444. private _kind;
  65445. private _size;
  65446. private _ownsBuffer;
  65447. private _instanced;
  65448. private _instanceDivisor;
  65449. /**
  65450. * The byte type.
  65451. */
  65452. static readonly BYTE: number;
  65453. /**
  65454. * The unsigned byte type.
  65455. */
  65456. static readonly UNSIGNED_BYTE: number;
  65457. /**
  65458. * The short type.
  65459. */
  65460. static readonly SHORT: number;
  65461. /**
  65462. * The unsigned short type.
  65463. */
  65464. static readonly UNSIGNED_SHORT: number;
  65465. /**
  65466. * The integer type.
  65467. */
  65468. static readonly INT: number;
  65469. /**
  65470. * The unsigned integer type.
  65471. */
  65472. static readonly UNSIGNED_INT: number;
  65473. /**
  65474. * The float type.
  65475. */
  65476. static readonly FLOAT: number;
  65477. /**
  65478. * Gets or sets the instance divisor when in instanced mode
  65479. */
  65480. instanceDivisor: number;
  65481. /**
  65482. * Gets the byte stride.
  65483. */
  65484. readonly byteStride: number;
  65485. /**
  65486. * Gets the byte offset.
  65487. */
  65488. readonly byteOffset: number;
  65489. /**
  65490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65491. */
  65492. readonly normalized: boolean;
  65493. /**
  65494. * Gets the data type of each component in the array.
  65495. */
  65496. readonly type: number;
  65497. /**
  65498. * Constructor
  65499. * @param engine the engine
  65500. * @param data the data to use for this vertex buffer
  65501. * @param kind the vertex buffer kind
  65502. * @param updatable whether the data is updatable
  65503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65504. * @param stride the stride (optional)
  65505. * @param instanced whether the buffer is instanced (optional)
  65506. * @param offset the offset of the data (optional)
  65507. * @param size the number of components (optional)
  65508. * @param type the type of the component (optional)
  65509. * @param normalized whether the data contains normalized data (optional)
  65510. * @param useBytes set to true if stride and offset are in bytes (optional)
  65511. */
  65512. 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);
  65513. /** @hidden */
  65514. _rebuild(): void;
  65515. /**
  65516. * Returns the kind of the VertexBuffer (string)
  65517. * @returns a string
  65518. */
  65519. getKind(): string;
  65520. /**
  65521. * Gets a boolean indicating if the VertexBuffer is updatable?
  65522. * @returns true if the buffer is updatable
  65523. */
  65524. isUpdatable(): boolean;
  65525. /**
  65526. * Gets current buffer's data
  65527. * @returns a DataArray or null
  65528. */
  65529. getData(): Nullable<DataArray>;
  65530. /**
  65531. * Gets underlying native buffer
  65532. * @returns underlying native buffer
  65533. */
  65534. getBuffer(): Nullable<DataBuffer>;
  65535. /**
  65536. * Gets the stride in float32 units (i.e. byte stride / 4).
  65537. * May not be an integer if the byte stride is not divisible by 4.
  65538. * DEPRECATED. Use byteStride instead.
  65539. * @returns the stride in float32 units
  65540. */
  65541. getStrideSize(): number;
  65542. /**
  65543. * Returns the offset as a multiple of the type byte length.
  65544. * DEPRECATED. Use byteOffset instead.
  65545. * @returns the offset in bytes
  65546. */
  65547. getOffset(): number;
  65548. /**
  65549. * Returns the number of components per vertex attribute (integer)
  65550. * @returns the size in float
  65551. */
  65552. getSize(): number;
  65553. /**
  65554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65555. * @returns true if this buffer is instanced
  65556. */
  65557. getIsInstanced(): boolean;
  65558. /**
  65559. * Returns the instancing divisor, zero for non-instanced (integer).
  65560. * @returns a number
  65561. */
  65562. getInstanceDivisor(): number;
  65563. /**
  65564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65565. * @param data defines the data to store
  65566. */
  65567. create(data?: DataArray): void;
  65568. /**
  65569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65570. * This function will create a new buffer if the current one is not updatable
  65571. * @param data defines the data to store
  65572. */
  65573. update(data: DataArray): void;
  65574. /**
  65575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65576. * Returns the directly updated WebGLBuffer.
  65577. * @param data the new data
  65578. * @param offset the new offset
  65579. * @param useBytes set to true if the offset is in bytes
  65580. */
  65581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65582. /**
  65583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65584. */
  65585. dispose(): void;
  65586. /**
  65587. * Enumerates each value of this vertex buffer as numbers.
  65588. * @param count the number of values to enumerate
  65589. * @param callback the callback function called for each value
  65590. */
  65591. forEach(count: number, callback: (value: number, index: number) => void): void;
  65592. /**
  65593. * Positions
  65594. */
  65595. static readonly PositionKind: string;
  65596. /**
  65597. * Normals
  65598. */
  65599. static readonly NormalKind: string;
  65600. /**
  65601. * Tangents
  65602. */
  65603. static readonly TangentKind: string;
  65604. /**
  65605. * Texture coordinates
  65606. */
  65607. static readonly UVKind: string;
  65608. /**
  65609. * Texture coordinates 2
  65610. */
  65611. static readonly UV2Kind: string;
  65612. /**
  65613. * Texture coordinates 3
  65614. */
  65615. static readonly UV3Kind: string;
  65616. /**
  65617. * Texture coordinates 4
  65618. */
  65619. static readonly UV4Kind: string;
  65620. /**
  65621. * Texture coordinates 5
  65622. */
  65623. static readonly UV5Kind: string;
  65624. /**
  65625. * Texture coordinates 6
  65626. */
  65627. static readonly UV6Kind: string;
  65628. /**
  65629. * Colors
  65630. */
  65631. static readonly ColorKind: string;
  65632. /**
  65633. * Matrix indices (for bones)
  65634. */
  65635. static readonly MatricesIndicesKind: string;
  65636. /**
  65637. * Matrix weights (for bones)
  65638. */
  65639. static readonly MatricesWeightsKind: string;
  65640. /**
  65641. * Additional matrix indices (for bones)
  65642. */
  65643. static readonly MatricesIndicesExtraKind: string;
  65644. /**
  65645. * Additional matrix weights (for bones)
  65646. */
  65647. static readonly MatricesWeightsExtraKind: string;
  65648. /**
  65649. * Deduces the stride given a kind.
  65650. * @param kind The kind string to deduce
  65651. * @returns The deduced stride
  65652. */
  65653. static DeduceStride(kind: string): number;
  65654. /**
  65655. * Gets the byte length of the given type.
  65656. * @param type the type
  65657. * @returns the number of bytes
  65658. */
  65659. static GetTypeByteLength(type: number): number;
  65660. /**
  65661. * Enumerates each value of the given parameters as numbers.
  65662. * @param data the data to enumerate
  65663. * @param byteOffset the byte offset of the data
  65664. * @param byteStride the byte stride of the data
  65665. * @param componentCount the number of components per element
  65666. * @param componentType the type of the component
  65667. * @param count the total number of components
  65668. * @param normalized whether the data is normalized
  65669. * @param callback the callback function called for each value
  65670. */
  65671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65672. private static _GetFloatValue;
  65673. }
  65674. }
  65675. declare module BABYLON {
  65676. /**
  65677. * Class representing spherical polynomial coefficients to the 3rd degree
  65678. */
  65679. export class SphericalPolynomial {
  65680. /**
  65681. * The x coefficients of the spherical polynomial
  65682. */
  65683. x: Vector3;
  65684. /**
  65685. * The y coefficients of the spherical polynomial
  65686. */
  65687. y: Vector3;
  65688. /**
  65689. * The z coefficients of the spherical polynomial
  65690. */
  65691. z: Vector3;
  65692. /**
  65693. * The xx coefficients of the spherical polynomial
  65694. */
  65695. xx: Vector3;
  65696. /**
  65697. * The yy coefficients of the spherical polynomial
  65698. */
  65699. yy: Vector3;
  65700. /**
  65701. * The zz coefficients of the spherical polynomial
  65702. */
  65703. zz: Vector3;
  65704. /**
  65705. * The xy coefficients of the spherical polynomial
  65706. */
  65707. xy: Vector3;
  65708. /**
  65709. * The yz coefficients of the spherical polynomial
  65710. */
  65711. yz: Vector3;
  65712. /**
  65713. * The zx coefficients of the spherical polynomial
  65714. */
  65715. zx: Vector3;
  65716. /**
  65717. * Adds an ambient color to the spherical polynomial
  65718. * @param color the color to add
  65719. */
  65720. addAmbient(color: Color3): void;
  65721. /**
  65722. * Scales the spherical polynomial by the given amount
  65723. * @param scale the amount to scale
  65724. */
  65725. scale(scale: number): void;
  65726. /**
  65727. * Gets the spherical polynomial from harmonics
  65728. * @param harmonics the spherical harmonics
  65729. * @returns the spherical polynomial
  65730. */
  65731. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65732. /**
  65733. * Constructs a spherical polynomial from an array.
  65734. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65735. * @returns the spherical polynomial
  65736. */
  65737. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65738. }
  65739. /**
  65740. * Class representing spherical harmonics coefficients to the 3rd degree
  65741. */
  65742. export class SphericalHarmonics {
  65743. /**
  65744. * The l0,0 coefficients of the spherical harmonics
  65745. */
  65746. l00: Vector3;
  65747. /**
  65748. * The l1,-1 coefficients of the spherical harmonics
  65749. */
  65750. l1_1: Vector3;
  65751. /**
  65752. * The l1,0 coefficients of the spherical harmonics
  65753. */
  65754. l10: Vector3;
  65755. /**
  65756. * The l1,1 coefficients of the spherical harmonics
  65757. */
  65758. l11: Vector3;
  65759. /**
  65760. * The l2,-2 coefficients of the spherical harmonics
  65761. */
  65762. l2_2: Vector3;
  65763. /**
  65764. * The l2,-1 coefficients of the spherical harmonics
  65765. */
  65766. l2_1: Vector3;
  65767. /**
  65768. * The l2,0 coefficients of the spherical harmonics
  65769. */
  65770. l20: Vector3;
  65771. /**
  65772. * The l2,1 coefficients of the spherical harmonics
  65773. */
  65774. l21: Vector3;
  65775. /**
  65776. * The l2,2 coefficients of the spherical harmonics
  65777. */
  65778. lL22: Vector3;
  65779. /**
  65780. * Adds a light to the spherical harmonics
  65781. * @param direction the direction of the light
  65782. * @param color the color of the light
  65783. * @param deltaSolidAngle the delta solid angle of the light
  65784. */
  65785. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65786. /**
  65787. * Scales the spherical harmonics by the given amount
  65788. * @param scale the amount to scale
  65789. */
  65790. scale(scale: number): void;
  65791. /**
  65792. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65793. *
  65794. * ```
  65795. * E_lm = A_l * L_lm
  65796. * ```
  65797. *
  65798. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65799. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65800. * the scaling factors are given in equation 9.
  65801. */
  65802. convertIncidentRadianceToIrradiance(): void;
  65803. /**
  65804. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65805. *
  65806. * ```
  65807. * L = (1/pi) * E * rho
  65808. * ```
  65809. *
  65810. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65811. */
  65812. convertIrradianceToLambertianRadiance(): void;
  65813. /**
  65814. * Gets the spherical harmonics from polynomial
  65815. * @param polynomial the spherical polynomial
  65816. * @returns the spherical harmonics
  65817. */
  65818. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65819. /**
  65820. * Constructs a spherical harmonics from an array.
  65821. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65822. * @returns the spherical harmonics
  65823. */
  65824. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65825. }
  65826. }
  65827. declare module BABYLON {
  65828. /**
  65829. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65830. */
  65831. export interface CubeMapInfo {
  65832. /**
  65833. * The pixel array for the front face.
  65834. * This is stored in format, left to right, up to down format.
  65835. */
  65836. front: Nullable<ArrayBufferView>;
  65837. /**
  65838. * The pixel array for the back face.
  65839. * This is stored in format, left to right, up to down format.
  65840. */
  65841. back: Nullable<ArrayBufferView>;
  65842. /**
  65843. * The pixel array for the left face.
  65844. * This is stored in format, left to right, up to down format.
  65845. */
  65846. left: Nullable<ArrayBufferView>;
  65847. /**
  65848. * The pixel array for the right face.
  65849. * This is stored in format, left to right, up to down format.
  65850. */
  65851. right: Nullable<ArrayBufferView>;
  65852. /**
  65853. * The pixel array for the up face.
  65854. * This is stored in format, left to right, up to down format.
  65855. */
  65856. up: Nullable<ArrayBufferView>;
  65857. /**
  65858. * The pixel array for the down face.
  65859. * This is stored in format, left to right, up to down format.
  65860. */
  65861. down: Nullable<ArrayBufferView>;
  65862. /**
  65863. * The size of the cubemap stored.
  65864. *
  65865. * Each faces will be size * size pixels.
  65866. */
  65867. size: number;
  65868. /**
  65869. * The format of the texture.
  65870. *
  65871. * RGBA, RGB.
  65872. */
  65873. format: number;
  65874. /**
  65875. * The type of the texture data.
  65876. *
  65877. * UNSIGNED_INT, FLOAT.
  65878. */
  65879. type: number;
  65880. /**
  65881. * Specifies whether the texture is in gamma space.
  65882. */
  65883. gammaSpace: boolean;
  65884. }
  65885. /**
  65886. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65887. */
  65888. export class PanoramaToCubeMapTools {
  65889. private static FACE_FRONT;
  65890. private static FACE_BACK;
  65891. private static FACE_RIGHT;
  65892. private static FACE_LEFT;
  65893. private static FACE_DOWN;
  65894. private static FACE_UP;
  65895. /**
  65896. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65897. *
  65898. * @param float32Array The source data.
  65899. * @param inputWidth The width of the input panorama.
  65900. * @param inputHeight The height of the input panorama.
  65901. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65902. * @return The cubemap data
  65903. */
  65904. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65905. private static CreateCubemapTexture;
  65906. private static CalcProjectionSpherical;
  65907. }
  65908. }
  65909. declare module BABYLON {
  65910. /**
  65911. * Helper class dealing with the extraction of spherical polynomial dataArray
  65912. * from a cube map.
  65913. */
  65914. export class CubeMapToSphericalPolynomialTools {
  65915. private static FileFaces;
  65916. /**
  65917. * Converts a texture to the according Spherical Polynomial data.
  65918. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65919. *
  65920. * @param texture The texture to extract the information from.
  65921. * @return The Spherical Polynomial data.
  65922. */
  65923. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65924. /**
  65925. * Converts a cubemap to the according Spherical Polynomial data.
  65926. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65927. *
  65928. * @param cubeInfo The Cube map to extract the information from.
  65929. * @return The Spherical Polynomial data.
  65930. */
  65931. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65932. }
  65933. }
  65934. declare module BABYLON {
  65935. /**
  65936. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65937. * during the life time of the application.
  65938. */
  65939. export class EngineStore {
  65940. /** Gets the list of created engines */
  65941. static Instances: Engine[];
  65942. /**
  65943. * Gets the latest created engine
  65944. */
  65945. static readonly LastCreatedEngine: Nullable<Engine>;
  65946. /**
  65947. * Gets the latest created scene
  65948. */
  65949. static readonly LastCreatedScene: Nullable<Scene>;
  65950. }
  65951. }
  65952. declare module BABYLON {
  65953. /**
  65954. * Define options used to create a render target texture
  65955. */
  65956. export class RenderTargetCreationOptions {
  65957. /**
  65958. * Specifies is mipmaps must be generated
  65959. */
  65960. generateMipMaps?: boolean;
  65961. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65962. generateDepthBuffer?: boolean;
  65963. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65964. generateStencilBuffer?: boolean;
  65965. /** Defines texture type (int by default) */
  65966. type?: number;
  65967. /** Defines sampling mode (trilinear by default) */
  65968. samplingMode?: number;
  65969. /** Defines format (RGBA by default) */
  65970. format?: number;
  65971. }
  65972. }
  65973. declare module BABYLON {
  65974. /**
  65975. * @hidden
  65976. **/
  65977. export class _AlphaState {
  65978. private _isAlphaBlendDirty;
  65979. private _isBlendFunctionParametersDirty;
  65980. private _isBlendEquationParametersDirty;
  65981. private _isBlendConstantsDirty;
  65982. private _alphaBlend;
  65983. private _blendFunctionParameters;
  65984. private _blendEquationParameters;
  65985. private _blendConstants;
  65986. /**
  65987. * Initializes the state.
  65988. */
  65989. constructor();
  65990. readonly isDirty: boolean;
  65991. alphaBlend: boolean;
  65992. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65993. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65994. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65995. reset(): void;
  65996. apply(gl: WebGLRenderingContext): void;
  65997. }
  65998. }
  65999. declare module BABYLON {
  66000. /**
  66001. * @hidden
  66002. **/
  66003. export class _DepthCullingState {
  66004. private _isDepthTestDirty;
  66005. private _isDepthMaskDirty;
  66006. private _isDepthFuncDirty;
  66007. private _isCullFaceDirty;
  66008. private _isCullDirty;
  66009. private _isZOffsetDirty;
  66010. private _isFrontFaceDirty;
  66011. private _depthTest;
  66012. private _depthMask;
  66013. private _depthFunc;
  66014. private _cull;
  66015. private _cullFace;
  66016. private _zOffset;
  66017. private _frontFace;
  66018. /**
  66019. * Initializes the state.
  66020. */
  66021. constructor();
  66022. readonly isDirty: boolean;
  66023. zOffset: number;
  66024. cullFace: Nullable<number>;
  66025. cull: Nullable<boolean>;
  66026. depthFunc: Nullable<number>;
  66027. depthMask: boolean;
  66028. depthTest: boolean;
  66029. frontFace: Nullable<number>;
  66030. reset(): void;
  66031. apply(gl: WebGLRenderingContext): void;
  66032. }
  66033. }
  66034. declare module BABYLON {
  66035. /**
  66036. * @hidden
  66037. **/
  66038. export class _StencilState {
  66039. /** 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 */
  66040. static readonly ALWAYS: number;
  66041. /** Passed to stencilOperation to specify that stencil value must be kept */
  66042. static readonly KEEP: number;
  66043. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66044. static readonly REPLACE: number;
  66045. private _isStencilTestDirty;
  66046. private _isStencilMaskDirty;
  66047. private _isStencilFuncDirty;
  66048. private _isStencilOpDirty;
  66049. private _stencilTest;
  66050. private _stencilMask;
  66051. private _stencilFunc;
  66052. private _stencilFuncRef;
  66053. private _stencilFuncMask;
  66054. private _stencilOpStencilFail;
  66055. private _stencilOpDepthFail;
  66056. private _stencilOpStencilDepthPass;
  66057. readonly isDirty: boolean;
  66058. stencilFunc: number;
  66059. stencilFuncRef: number;
  66060. stencilFuncMask: number;
  66061. stencilOpStencilFail: number;
  66062. stencilOpDepthFail: number;
  66063. stencilOpStencilDepthPass: number;
  66064. stencilMask: number;
  66065. stencilTest: boolean;
  66066. constructor();
  66067. reset(): void;
  66068. apply(gl: WebGLRenderingContext): void;
  66069. }
  66070. }
  66071. declare module BABYLON {
  66072. /**
  66073. * @hidden
  66074. **/
  66075. export class _TimeToken {
  66076. _startTimeQuery: Nullable<WebGLQuery>;
  66077. _endTimeQuery: Nullable<WebGLQuery>;
  66078. _timeElapsedQuery: Nullable<WebGLQuery>;
  66079. _timeElapsedQueryEnded: boolean;
  66080. }
  66081. }
  66082. declare module BABYLON {
  66083. /**
  66084. * Class used to store data associated with WebGL texture data for the engine
  66085. * This class should not be used directly
  66086. */
  66087. export class InternalTexture {
  66088. /** hidden */
  66089. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66090. /**
  66091. * The source of the texture data is unknown
  66092. */
  66093. static DATASOURCE_UNKNOWN: number;
  66094. /**
  66095. * Texture data comes from an URL
  66096. */
  66097. static DATASOURCE_URL: number;
  66098. /**
  66099. * Texture data is only used for temporary storage
  66100. */
  66101. static DATASOURCE_TEMP: number;
  66102. /**
  66103. * Texture data comes from raw data (ArrayBuffer)
  66104. */
  66105. static DATASOURCE_RAW: number;
  66106. /**
  66107. * Texture content is dynamic (video or dynamic texture)
  66108. */
  66109. static DATASOURCE_DYNAMIC: number;
  66110. /**
  66111. * Texture content is generated by rendering to it
  66112. */
  66113. static DATASOURCE_RENDERTARGET: number;
  66114. /**
  66115. * Texture content is part of a multi render target process
  66116. */
  66117. static DATASOURCE_MULTIRENDERTARGET: number;
  66118. /**
  66119. * Texture data comes from a cube data file
  66120. */
  66121. static DATASOURCE_CUBE: number;
  66122. /**
  66123. * Texture data comes from a raw cube data
  66124. */
  66125. static DATASOURCE_CUBERAW: number;
  66126. /**
  66127. * Texture data come from a prefiltered cube data file
  66128. */
  66129. static DATASOURCE_CUBEPREFILTERED: number;
  66130. /**
  66131. * Texture content is raw 3D data
  66132. */
  66133. static DATASOURCE_RAW3D: number;
  66134. /**
  66135. * Texture content is a depth texture
  66136. */
  66137. static DATASOURCE_DEPTHTEXTURE: number;
  66138. /**
  66139. * Texture data comes from a raw cube data encoded with RGBD
  66140. */
  66141. static DATASOURCE_CUBERAW_RGBD: number;
  66142. /**
  66143. * Defines if the texture is ready
  66144. */
  66145. isReady: boolean;
  66146. /**
  66147. * Defines if the texture is a cube texture
  66148. */
  66149. isCube: boolean;
  66150. /**
  66151. * Defines if the texture contains 3D data
  66152. */
  66153. is3D: boolean;
  66154. /**
  66155. * Defines if the texture contains multiview data
  66156. */
  66157. isMultiview: boolean;
  66158. /**
  66159. * Gets the URL used to load this texture
  66160. */
  66161. url: string;
  66162. /**
  66163. * Gets the sampling mode of the texture
  66164. */
  66165. samplingMode: number;
  66166. /**
  66167. * Gets a boolean indicating if the texture needs mipmaps generation
  66168. */
  66169. generateMipMaps: boolean;
  66170. /**
  66171. * Gets the number of samples used by the texture (WebGL2+ only)
  66172. */
  66173. samples: number;
  66174. /**
  66175. * Gets the type of the texture (int, float...)
  66176. */
  66177. type: number;
  66178. /**
  66179. * Gets the format of the texture (RGB, RGBA...)
  66180. */
  66181. format: number;
  66182. /**
  66183. * Observable called when the texture is loaded
  66184. */
  66185. onLoadedObservable: Observable<InternalTexture>;
  66186. /**
  66187. * Gets the width of the texture
  66188. */
  66189. width: number;
  66190. /**
  66191. * Gets the height of the texture
  66192. */
  66193. height: number;
  66194. /**
  66195. * Gets the depth of the texture
  66196. */
  66197. depth: number;
  66198. /**
  66199. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66200. */
  66201. baseWidth: number;
  66202. /**
  66203. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66204. */
  66205. baseHeight: number;
  66206. /**
  66207. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66208. */
  66209. baseDepth: number;
  66210. /**
  66211. * Gets a boolean indicating if the texture is inverted on Y axis
  66212. */
  66213. invertY: boolean;
  66214. /** @hidden */
  66215. _invertVScale: boolean;
  66216. /** @hidden */
  66217. _associatedChannel: number;
  66218. /** @hidden */
  66219. _dataSource: number;
  66220. /** @hidden */
  66221. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66222. /** @hidden */
  66223. _bufferView: Nullable<ArrayBufferView>;
  66224. /** @hidden */
  66225. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66226. /** @hidden */
  66227. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66228. /** @hidden */
  66229. _size: number;
  66230. /** @hidden */
  66231. _extension: string;
  66232. /** @hidden */
  66233. _files: Nullable<string[]>;
  66234. /** @hidden */
  66235. _workingCanvas: Nullable<HTMLCanvasElement>;
  66236. /** @hidden */
  66237. _workingContext: Nullable<CanvasRenderingContext2D>;
  66238. /** @hidden */
  66239. _framebuffer: Nullable<WebGLFramebuffer>;
  66240. /** @hidden */
  66241. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66242. /** @hidden */
  66243. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66244. /** @hidden */
  66245. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66246. /** @hidden */
  66247. _attachments: Nullable<number[]>;
  66248. /** @hidden */
  66249. _cachedCoordinatesMode: Nullable<number>;
  66250. /** @hidden */
  66251. _cachedWrapU: Nullable<number>;
  66252. /** @hidden */
  66253. _cachedWrapV: Nullable<number>;
  66254. /** @hidden */
  66255. _cachedWrapR: Nullable<number>;
  66256. /** @hidden */
  66257. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66258. /** @hidden */
  66259. _isDisabled: boolean;
  66260. /** @hidden */
  66261. _compression: Nullable<string>;
  66262. /** @hidden */
  66263. _generateStencilBuffer: boolean;
  66264. /** @hidden */
  66265. _generateDepthBuffer: boolean;
  66266. /** @hidden */
  66267. _comparisonFunction: number;
  66268. /** @hidden */
  66269. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66270. /** @hidden */
  66271. _lodGenerationScale: number;
  66272. /** @hidden */
  66273. _lodGenerationOffset: number;
  66274. /** @hidden */
  66275. _colorTextureArray: Nullable<WebGLTexture>;
  66276. /** @hidden */
  66277. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66278. /** @hidden */
  66279. _lodTextureHigh: Nullable<BaseTexture>;
  66280. /** @hidden */
  66281. _lodTextureMid: Nullable<BaseTexture>;
  66282. /** @hidden */
  66283. _lodTextureLow: Nullable<BaseTexture>;
  66284. /** @hidden */
  66285. _isRGBD: boolean;
  66286. /** @hidden */
  66287. _webGLTexture: Nullable<WebGLTexture>;
  66288. /** @hidden */
  66289. _references: number;
  66290. private _engine;
  66291. /**
  66292. * Gets the Engine the texture belongs to.
  66293. * @returns The babylon engine
  66294. */
  66295. getEngine(): Engine;
  66296. /**
  66297. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66298. */
  66299. readonly dataSource: number;
  66300. /**
  66301. * Creates a new InternalTexture
  66302. * @param engine defines the engine to use
  66303. * @param dataSource defines the type of data that will be used
  66304. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66305. */
  66306. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66307. /**
  66308. * Increments the number of references (ie. the number of Texture that point to it)
  66309. */
  66310. incrementReferences(): void;
  66311. /**
  66312. * Change the size of the texture (not the size of the content)
  66313. * @param width defines the new width
  66314. * @param height defines the new height
  66315. * @param depth defines the new depth (1 by default)
  66316. */
  66317. updateSize(width: int, height: int, depth?: int): void;
  66318. /** @hidden */
  66319. _rebuild(): void;
  66320. /** @hidden */
  66321. _swapAndDie(target: InternalTexture): void;
  66322. /**
  66323. * Dispose the current allocated resources
  66324. */
  66325. dispose(): void;
  66326. }
  66327. }
  66328. declare module BABYLON {
  66329. /**
  66330. * This represents the main contract an easing function should follow.
  66331. * Easing functions are used throughout the animation system.
  66332. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66333. */
  66334. export interface IEasingFunction {
  66335. /**
  66336. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66337. * of the easing function.
  66338. * The link below provides some of the most common examples of easing functions.
  66339. * @see https://easings.net/
  66340. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66341. * @returns the corresponding value on the curve defined by the easing function
  66342. */
  66343. ease(gradient: number): number;
  66344. }
  66345. /**
  66346. * Base class used for every default easing function.
  66347. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66348. */
  66349. export class EasingFunction implements IEasingFunction {
  66350. /**
  66351. * Interpolation follows the mathematical formula associated with the easing function.
  66352. */
  66353. static readonly EASINGMODE_EASEIN: number;
  66354. /**
  66355. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66356. */
  66357. static readonly EASINGMODE_EASEOUT: number;
  66358. /**
  66359. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66360. */
  66361. static readonly EASINGMODE_EASEINOUT: number;
  66362. private _easingMode;
  66363. /**
  66364. * Sets the easing mode of the current function.
  66365. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66366. */
  66367. setEasingMode(easingMode: number): void;
  66368. /**
  66369. * Gets the current easing mode.
  66370. * @returns the easing mode
  66371. */
  66372. getEasingMode(): number;
  66373. /**
  66374. * @hidden
  66375. */
  66376. easeInCore(gradient: number): number;
  66377. /**
  66378. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66379. * of the easing function.
  66380. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66381. * @returns the corresponding value on the curve defined by the easing function
  66382. */
  66383. ease(gradient: number): number;
  66384. }
  66385. /**
  66386. * Easing function with a circle shape (see link below).
  66387. * @see https://easings.net/#easeInCirc
  66388. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66389. */
  66390. export class CircleEase extends EasingFunction implements IEasingFunction {
  66391. /** @hidden */
  66392. easeInCore(gradient: number): number;
  66393. }
  66394. /**
  66395. * Easing function with a ease back shape (see link below).
  66396. * @see https://easings.net/#easeInBack
  66397. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66398. */
  66399. export class BackEase extends EasingFunction implements IEasingFunction {
  66400. /** Defines the amplitude of the function */
  66401. amplitude: number;
  66402. /**
  66403. * Instantiates a back ease easing
  66404. * @see https://easings.net/#easeInBack
  66405. * @param amplitude Defines the amplitude of the function
  66406. */
  66407. constructor(
  66408. /** Defines the amplitude of the function */
  66409. amplitude?: number);
  66410. /** @hidden */
  66411. easeInCore(gradient: number): number;
  66412. }
  66413. /**
  66414. * Easing function with a bouncing shape (see link below).
  66415. * @see https://easings.net/#easeInBounce
  66416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66417. */
  66418. export class BounceEase extends EasingFunction implements IEasingFunction {
  66419. /** Defines the number of bounces */
  66420. bounces: number;
  66421. /** Defines the amplitude of the bounce */
  66422. bounciness: number;
  66423. /**
  66424. * Instantiates a bounce easing
  66425. * @see https://easings.net/#easeInBounce
  66426. * @param bounces Defines the number of bounces
  66427. * @param bounciness Defines the amplitude of the bounce
  66428. */
  66429. constructor(
  66430. /** Defines the number of bounces */
  66431. bounces?: number,
  66432. /** Defines the amplitude of the bounce */
  66433. bounciness?: number);
  66434. /** @hidden */
  66435. easeInCore(gradient: number): number;
  66436. }
  66437. /**
  66438. * Easing function with a power of 3 shape (see link below).
  66439. * @see https://easings.net/#easeInCubic
  66440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66441. */
  66442. export class CubicEase extends EasingFunction implements IEasingFunction {
  66443. /** @hidden */
  66444. easeInCore(gradient: number): number;
  66445. }
  66446. /**
  66447. * Easing function with an elastic shape (see link below).
  66448. * @see https://easings.net/#easeInElastic
  66449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66450. */
  66451. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66452. /** Defines the number of oscillations*/
  66453. oscillations: number;
  66454. /** Defines the amplitude of the oscillations*/
  66455. springiness: number;
  66456. /**
  66457. * Instantiates an elastic easing function
  66458. * @see https://easings.net/#easeInElastic
  66459. * @param oscillations Defines the number of oscillations
  66460. * @param springiness Defines the amplitude of the oscillations
  66461. */
  66462. constructor(
  66463. /** Defines the number of oscillations*/
  66464. oscillations?: number,
  66465. /** Defines the amplitude of the oscillations*/
  66466. springiness?: number);
  66467. /** @hidden */
  66468. easeInCore(gradient: number): number;
  66469. }
  66470. /**
  66471. * Easing function with an exponential shape (see link below).
  66472. * @see https://easings.net/#easeInExpo
  66473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66474. */
  66475. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66476. /** Defines the exponent of the function */
  66477. exponent: number;
  66478. /**
  66479. * Instantiates an exponential easing function
  66480. * @see https://easings.net/#easeInExpo
  66481. * @param exponent Defines the exponent of the function
  66482. */
  66483. constructor(
  66484. /** Defines the exponent of the function */
  66485. exponent?: number);
  66486. /** @hidden */
  66487. easeInCore(gradient: number): number;
  66488. }
  66489. /**
  66490. * Easing function with a power shape (see link below).
  66491. * @see https://easings.net/#easeInQuad
  66492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66493. */
  66494. export class PowerEase extends EasingFunction implements IEasingFunction {
  66495. /** Defines the power of the function */
  66496. power: number;
  66497. /**
  66498. * Instantiates an power base easing function
  66499. * @see https://easings.net/#easeInQuad
  66500. * @param power Defines the power of the function
  66501. */
  66502. constructor(
  66503. /** Defines the power of the function */
  66504. power?: number);
  66505. /** @hidden */
  66506. easeInCore(gradient: number): number;
  66507. }
  66508. /**
  66509. * Easing function with a power of 2 shape (see link below).
  66510. * @see https://easings.net/#easeInQuad
  66511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66512. */
  66513. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66514. /** @hidden */
  66515. easeInCore(gradient: number): number;
  66516. }
  66517. /**
  66518. * Easing function with a power of 4 shape (see link below).
  66519. * @see https://easings.net/#easeInQuart
  66520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66521. */
  66522. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66523. /** @hidden */
  66524. easeInCore(gradient: number): number;
  66525. }
  66526. /**
  66527. * Easing function with a power of 5 shape (see link below).
  66528. * @see https://easings.net/#easeInQuint
  66529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66530. */
  66531. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66532. /** @hidden */
  66533. easeInCore(gradient: number): number;
  66534. }
  66535. /**
  66536. * Easing function with a sin shape (see link below).
  66537. * @see https://easings.net/#easeInSine
  66538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66539. */
  66540. export class SineEase extends EasingFunction implements IEasingFunction {
  66541. /** @hidden */
  66542. easeInCore(gradient: number): number;
  66543. }
  66544. /**
  66545. * Easing function with a bezier shape (see link below).
  66546. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66548. */
  66549. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66550. /** Defines the x component of the start tangent in the bezier curve */
  66551. x1: number;
  66552. /** Defines the y component of the start tangent in the bezier curve */
  66553. y1: number;
  66554. /** Defines the x component of the end tangent in the bezier curve */
  66555. x2: number;
  66556. /** Defines the y component of the end tangent in the bezier curve */
  66557. y2: number;
  66558. /**
  66559. * Instantiates a bezier function
  66560. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66561. * @param x1 Defines the x component of the start tangent in the bezier curve
  66562. * @param y1 Defines the y component of the start tangent in the bezier curve
  66563. * @param x2 Defines the x component of the end tangent in the bezier curve
  66564. * @param y2 Defines the y component of the end tangent in the bezier curve
  66565. */
  66566. constructor(
  66567. /** Defines the x component of the start tangent in the bezier curve */
  66568. x1?: number,
  66569. /** Defines the y component of the start tangent in the bezier curve */
  66570. y1?: number,
  66571. /** Defines the x component of the end tangent in the bezier curve */
  66572. x2?: number,
  66573. /** Defines the y component of the end tangent in the bezier curve */
  66574. y2?: number);
  66575. /** @hidden */
  66576. easeInCore(gradient: number): number;
  66577. }
  66578. }
  66579. declare module BABYLON {
  66580. /**
  66581. * Defines an interface which represents an animation key frame
  66582. */
  66583. export interface IAnimationKey {
  66584. /**
  66585. * Frame of the key frame
  66586. */
  66587. frame: number;
  66588. /**
  66589. * Value at the specifies key frame
  66590. */
  66591. value: any;
  66592. /**
  66593. * The input tangent for the cubic hermite spline
  66594. */
  66595. inTangent?: any;
  66596. /**
  66597. * The output tangent for the cubic hermite spline
  66598. */
  66599. outTangent?: any;
  66600. /**
  66601. * The animation interpolation type
  66602. */
  66603. interpolation?: AnimationKeyInterpolation;
  66604. }
  66605. /**
  66606. * Enum for the animation key frame interpolation type
  66607. */
  66608. export enum AnimationKeyInterpolation {
  66609. /**
  66610. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66611. */
  66612. STEP = 1
  66613. }
  66614. }
  66615. declare module BABYLON {
  66616. /**
  66617. * Represents the range of an animation
  66618. */
  66619. export class AnimationRange {
  66620. /**The name of the animation range**/
  66621. name: string;
  66622. /**The starting frame of the animation */
  66623. from: number;
  66624. /**The ending frame of the animation*/
  66625. to: number;
  66626. /**
  66627. * Initializes the range of an animation
  66628. * @param name The name of the animation range
  66629. * @param from The starting frame of the animation
  66630. * @param to The ending frame of the animation
  66631. */
  66632. constructor(
  66633. /**The name of the animation range**/
  66634. name: string,
  66635. /**The starting frame of the animation */
  66636. from: number,
  66637. /**The ending frame of the animation*/
  66638. to: number);
  66639. /**
  66640. * Makes a copy of the animation range
  66641. * @returns A copy of the animation range
  66642. */
  66643. clone(): AnimationRange;
  66644. }
  66645. }
  66646. declare module BABYLON {
  66647. /**
  66648. * Composed of a frame, and an action function
  66649. */
  66650. export class AnimationEvent {
  66651. /** The frame for which the event is triggered **/
  66652. frame: number;
  66653. /** The event to perform when triggered **/
  66654. action: (currentFrame: number) => void;
  66655. /** Specifies if the event should be triggered only once**/
  66656. onlyOnce?: boolean | undefined;
  66657. /**
  66658. * Specifies if the animation event is done
  66659. */
  66660. isDone: boolean;
  66661. /**
  66662. * Initializes the animation event
  66663. * @param frame The frame for which the event is triggered
  66664. * @param action The event to perform when triggered
  66665. * @param onlyOnce Specifies if the event should be triggered only once
  66666. */
  66667. constructor(
  66668. /** The frame for which the event is triggered **/
  66669. frame: number,
  66670. /** The event to perform when triggered **/
  66671. action: (currentFrame: number) => void,
  66672. /** Specifies if the event should be triggered only once**/
  66673. onlyOnce?: boolean | undefined);
  66674. /** @hidden */
  66675. _clone(): AnimationEvent;
  66676. }
  66677. }
  66678. declare module BABYLON {
  66679. /**
  66680. * Interface used to define a behavior
  66681. */
  66682. export interface Behavior<T> {
  66683. /** gets or sets behavior's name */
  66684. name: string;
  66685. /**
  66686. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66687. */
  66688. init(): void;
  66689. /**
  66690. * Called when the behavior is attached to a target
  66691. * @param target defines the target where the behavior is attached to
  66692. */
  66693. attach(target: T): void;
  66694. /**
  66695. * Called when the behavior is detached from its target
  66696. */
  66697. detach(): void;
  66698. }
  66699. /**
  66700. * Interface implemented by classes supporting behaviors
  66701. */
  66702. export interface IBehaviorAware<T> {
  66703. /**
  66704. * Attach a behavior
  66705. * @param behavior defines the behavior to attach
  66706. * @returns the current host
  66707. */
  66708. addBehavior(behavior: Behavior<T>): T;
  66709. /**
  66710. * Remove a behavior from the current object
  66711. * @param behavior defines the behavior to detach
  66712. * @returns the current host
  66713. */
  66714. removeBehavior(behavior: Behavior<T>): T;
  66715. /**
  66716. * Gets a behavior using its name to search
  66717. * @param name defines the name to search
  66718. * @returns the behavior or null if not found
  66719. */
  66720. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66721. }
  66722. }
  66723. declare module BABYLON {
  66724. /**
  66725. * @hidden
  66726. */
  66727. export class IntersectionInfo {
  66728. bu: Nullable<number>;
  66729. bv: Nullable<number>;
  66730. distance: number;
  66731. faceId: number;
  66732. subMeshId: number;
  66733. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66734. }
  66735. }
  66736. declare module BABYLON {
  66737. /**
  66738. * Class used to store bounding sphere information
  66739. */
  66740. export class BoundingSphere {
  66741. /**
  66742. * Gets the center of the bounding sphere in local space
  66743. */
  66744. readonly center: Vector3;
  66745. /**
  66746. * Radius of the bounding sphere in local space
  66747. */
  66748. radius: number;
  66749. /**
  66750. * Gets the center of the bounding sphere in world space
  66751. */
  66752. readonly centerWorld: Vector3;
  66753. /**
  66754. * Radius of the bounding sphere in world space
  66755. */
  66756. radiusWorld: number;
  66757. /**
  66758. * Gets the minimum vector in local space
  66759. */
  66760. readonly minimum: Vector3;
  66761. /**
  66762. * Gets the maximum vector in local space
  66763. */
  66764. readonly maximum: Vector3;
  66765. private _worldMatrix;
  66766. private static readonly TmpVector3;
  66767. /**
  66768. * Creates a new bounding sphere
  66769. * @param min defines the minimum vector (in local space)
  66770. * @param max defines the maximum vector (in local space)
  66771. * @param worldMatrix defines the new world matrix
  66772. */
  66773. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66774. /**
  66775. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66776. * @param min defines the new minimum vector (in local space)
  66777. * @param max defines the new maximum vector (in local space)
  66778. * @param worldMatrix defines the new world matrix
  66779. */
  66780. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66781. /**
  66782. * Scale the current bounding sphere by applying a scale factor
  66783. * @param factor defines the scale factor to apply
  66784. * @returns the current bounding box
  66785. */
  66786. scale(factor: number): BoundingSphere;
  66787. /**
  66788. * Gets the world matrix of the bounding box
  66789. * @returns a matrix
  66790. */
  66791. getWorldMatrix(): DeepImmutable<Matrix>;
  66792. /** @hidden */
  66793. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66794. /**
  66795. * Tests if the bounding sphere is intersecting the frustum planes
  66796. * @param frustumPlanes defines the frustum planes to test
  66797. * @returns true if there is an intersection
  66798. */
  66799. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66800. /**
  66801. * Tests if the bounding sphere center is in between the frustum planes.
  66802. * Used for optimistic fast inclusion.
  66803. * @param frustumPlanes defines the frustum planes to test
  66804. * @returns true if the sphere center is in between the frustum planes
  66805. */
  66806. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66807. /**
  66808. * Tests if a point is inside the bounding sphere
  66809. * @param point defines the point to test
  66810. * @returns true if the point is inside the bounding sphere
  66811. */
  66812. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66813. /**
  66814. * Checks if two sphere intersct
  66815. * @param sphere0 sphere 0
  66816. * @param sphere1 sphere 1
  66817. * @returns true if the speres intersect
  66818. */
  66819. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66820. }
  66821. }
  66822. declare module BABYLON {
  66823. /**
  66824. * Class used to store bounding box information
  66825. */
  66826. export class BoundingBox implements ICullable {
  66827. /**
  66828. * Gets the 8 vectors representing the bounding box in local space
  66829. */
  66830. readonly vectors: Vector3[];
  66831. /**
  66832. * Gets the center of the bounding box in local space
  66833. */
  66834. readonly center: Vector3;
  66835. /**
  66836. * Gets the center of the bounding box in world space
  66837. */
  66838. readonly centerWorld: Vector3;
  66839. /**
  66840. * Gets the extend size in local space
  66841. */
  66842. readonly extendSize: Vector3;
  66843. /**
  66844. * Gets the extend size in world space
  66845. */
  66846. readonly extendSizeWorld: Vector3;
  66847. /**
  66848. * Gets the OBB (object bounding box) directions
  66849. */
  66850. readonly directions: Vector3[];
  66851. /**
  66852. * Gets the 8 vectors representing the bounding box in world space
  66853. */
  66854. readonly vectorsWorld: Vector3[];
  66855. /**
  66856. * Gets the minimum vector in world space
  66857. */
  66858. readonly minimumWorld: Vector3;
  66859. /**
  66860. * Gets the maximum vector in world space
  66861. */
  66862. readonly maximumWorld: Vector3;
  66863. /**
  66864. * Gets the minimum vector in local space
  66865. */
  66866. readonly minimum: Vector3;
  66867. /**
  66868. * Gets the maximum vector in local space
  66869. */
  66870. readonly maximum: Vector3;
  66871. private _worldMatrix;
  66872. private static readonly TmpVector3;
  66873. /**
  66874. * @hidden
  66875. */
  66876. _tag: number;
  66877. /**
  66878. * Creates a new bounding box
  66879. * @param min defines the minimum vector (in local space)
  66880. * @param max defines the maximum vector (in local space)
  66881. * @param worldMatrix defines the new world matrix
  66882. */
  66883. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66884. /**
  66885. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66886. * @param min defines the new minimum vector (in local space)
  66887. * @param max defines the new maximum vector (in local space)
  66888. * @param worldMatrix defines the new world matrix
  66889. */
  66890. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66891. /**
  66892. * Scale the current bounding box by applying a scale factor
  66893. * @param factor defines the scale factor to apply
  66894. * @returns the current bounding box
  66895. */
  66896. scale(factor: number): BoundingBox;
  66897. /**
  66898. * Gets the world matrix of the bounding box
  66899. * @returns a matrix
  66900. */
  66901. getWorldMatrix(): DeepImmutable<Matrix>;
  66902. /** @hidden */
  66903. _update(world: DeepImmutable<Matrix>): void;
  66904. /**
  66905. * Tests if the bounding box is intersecting the frustum planes
  66906. * @param frustumPlanes defines the frustum planes to test
  66907. * @returns true if there is an intersection
  66908. */
  66909. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66910. /**
  66911. * Tests if the bounding box is entirely inside the frustum planes
  66912. * @param frustumPlanes defines the frustum planes to test
  66913. * @returns true if there is an inclusion
  66914. */
  66915. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66916. /**
  66917. * Tests if a point is inside the bounding box
  66918. * @param point defines the point to test
  66919. * @returns true if the point is inside the bounding box
  66920. */
  66921. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66922. /**
  66923. * Tests if the bounding box intersects with a bounding sphere
  66924. * @param sphere defines the sphere to test
  66925. * @returns true if there is an intersection
  66926. */
  66927. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66928. /**
  66929. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66930. * @param min defines the min vector to use
  66931. * @param max defines the max vector to use
  66932. * @returns true if there is an intersection
  66933. */
  66934. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66935. /**
  66936. * Tests if two bounding boxes are intersections
  66937. * @param box0 defines the first box to test
  66938. * @param box1 defines the second box to test
  66939. * @returns true if there is an intersection
  66940. */
  66941. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66942. /**
  66943. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66944. * @param minPoint defines the minimum vector of the bounding box
  66945. * @param maxPoint defines the maximum vector of the bounding box
  66946. * @param sphereCenter defines the sphere center
  66947. * @param sphereRadius defines the sphere radius
  66948. * @returns true if there is an intersection
  66949. */
  66950. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66951. /**
  66952. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66953. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66954. * @param frustumPlanes defines the frustum planes to test
  66955. * @return true if there is an inclusion
  66956. */
  66957. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66958. /**
  66959. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66960. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66961. * @param frustumPlanes defines the frustum planes to test
  66962. * @return true if there is an intersection
  66963. */
  66964. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66965. }
  66966. }
  66967. declare module BABYLON {
  66968. /** @hidden */
  66969. export class Collider {
  66970. /** Define if a collision was found */
  66971. collisionFound: boolean;
  66972. /**
  66973. * Define last intersection point in local space
  66974. */
  66975. intersectionPoint: Vector3;
  66976. /**
  66977. * Define last collided mesh
  66978. */
  66979. collidedMesh: Nullable<AbstractMesh>;
  66980. private _collisionPoint;
  66981. private _planeIntersectionPoint;
  66982. private _tempVector;
  66983. private _tempVector2;
  66984. private _tempVector3;
  66985. private _tempVector4;
  66986. private _edge;
  66987. private _baseToVertex;
  66988. private _destinationPoint;
  66989. private _slidePlaneNormal;
  66990. private _displacementVector;
  66991. /** @hidden */
  66992. _radius: Vector3;
  66993. /** @hidden */
  66994. _retry: number;
  66995. private _velocity;
  66996. private _basePoint;
  66997. private _epsilon;
  66998. /** @hidden */
  66999. _velocityWorldLength: number;
  67000. /** @hidden */
  67001. _basePointWorld: Vector3;
  67002. private _velocityWorld;
  67003. private _normalizedVelocity;
  67004. /** @hidden */
  67005. _initialVelocity: Vector3;
  67006. /** @hidden */
  67007. _initialPosition: Vector3;
  67008. private _nearestDistance;
  67009. private _collisionMask;
  67010. collisionMask: number;
  67011. /**
  67012. * Gets the plane normal used to compute the sliding response (in local space)
  67013. */
  67014. readonly slidePlaneNormal: Vector3;
  67015. /** @hidden */
  67016. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67017. /** @hidden */
  67018. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67019. /** @hidden */
  67020. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67021. /** @hidden */
  67022. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67023. /** @hidden */
  67024. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67025. /** @hidden */
  67026. _getResponse(pos: Vector3, vel: Vector3): void;
  67027. }
  67028. }
  67029. declare module BABYLON {
  67030. /**
  67031. * Interface for cullable objects
  67032. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67033. */
  67034. export interface ICullable {
  67035. /**
  67036. * Checks if the object or part of the object is in the frustum
  67037. * @param frustumPlanes Camera near/planes
  67038. * @returns true if the object is in frustum otherwise false
  67039. */
  67040. isInFrustum(frustumPlanes: Plane[]): boolean;
  67041. /**
  67042. * Checks if a cullable object (mesh...) is in the camera frustum
  67043. * Unlike isInFrustum this cheks the full bounding box
  67044. * @param frustumPlanes Camera near/planes
  67045. * @returns true if the object is in frustum otherwise false
  67046. */
  67047. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67048. }
  67049. /**
  67050. * Info for a bounding data of a mesh
  67051. */
  67052. export class BoundingInfo implements ICullable {
  67053. /**
  67054. * Bounding box for the mesh
  67055. */
  67056. readonly boundingBox: BoundingBox;
  67057. /**
  67058. * Bounding sphere for the mesh
  67059. */
  67060. readonly boundingSphere: BoundingSphere;
  67061. private _isLocked;
  67062. private static readonly TmpVector3;
  67063. /**
  67064. * Constructs bounding info
  67065. * @param minimum min vector of the bounding box/sphere
  67066. * @param maximum max vector of the bounding box/sphere
  67067. * @param worldMatrix defines the new world matrix
  67068. */
  67069. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67070. /**
  67071. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67072. * @param min defines the new minimum vector (in local space)
  67073. * @param max defines the new maximum vector (in local space)
  67074. * @param worldMatrix defines the new world matrix
  67075. */
  67076. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67077. /**
  67078. * min vector of the bounding box/sphere
  67079. */
  67080. readonly minimum: Vector3;
  67081. /**
  67082. * max vector of the bounding box/sphere
  67083. */
  67084. readonly maximum: Vector3;
  67085. /**
  67086. * If the info is locked and won't be updated to avoid perf overhead
  67087. */
  67088. isLocked: boolean;
  67089. /**
  67090. * Updates the bounding sphere and box
  67091. * @param world world matrix to be used to update
  67092. */
  67093. update(world: DeepImmutable<Matrix>): void;
  67094. /**
  67095. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67096. * @param center New center of the bounding info
  67097. * @param extend New extend of the bounding info
  67098. * @returns the current bounding info
  67099. */
  67100. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67101. /**
  67102. * Scale the current bounding info by applying a scale factor
  67103. * @param factor defines the scale factor to apply
  67104. * @returns the current bounding info
  67105. */
  67106. scale(factor: number): BoundingInfo;
  67107. /**
  67108. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67109. * @param frustumPlanes defines the frustum to test
  67110. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67111. * @returns true if the bounding info is in the frustum planes
  67112. */
  67113. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67114. /**
  67115. * Gets the world distance between the min and max points of the bounding box
  67116. */
  67117. readonly diagonalLength: number;
  67118. /**
  67119. * Checks if a cullable object (mesh...) is in the camera frustum
  67120. * Unlike isInFrustum this cheks the full bounding box
  67121. * @param frustumPlanes Camera near/planes
  67122. * @returns true if the object is in frustum otherwise false
  67123. */
  67124. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67125. /** @hidden */
  67126. _checkCollision(collider: Collider): boolean;
  67127. /**
  67128. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67129. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67130. * @param point the point to check intersection with
  67131. * @returns if the point intersects
  67132. */
  67133. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67134. /**
  67135. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67136. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67137. * @param boundingInfo the bounding info to check intersection with
  67138. * @param precise if the intersection should be done using OBB
  67139. * @returns if the bounding info intersects
  67140. */
  67141. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67142. }
  67143. }
  67144. declare module BABYLON {
  67145. /**
  67146. * Defines an array and its length.
  67147. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67148. */
  67149. export interface ISmartArrayLike<T> {
  67150. /**
  67151. * The data of the array.
  67152. */
  67153. data: Array<T>;
  67154. /**
  67155. * The active length of the array.
  67156. */
  67157. length: number;
  67158. }
  67159. /**
  67160. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67161. */
  67162. export class SmartArray<T> implements ISmartArrayLike<T> {
  67163. /**
  67164. * The full set of data from the array.
  67165. */
  67166. data: Array<T>;
  67167. /**
  67168. * The active length of the array.
  67169. */
  67170. length: number;
  67171. protected _id: number;
  67172. /**
  67173. * Instantiates a Smart Array.
  67174. * @param capacity defines the default capacity of the array.
  67175. */
  67176. constructor(capacity: number);
  67177. /**
  67178. * Pushes a value at the end of the active data.
  67179. * @param value defines the object to push in the array.
  67180. */
  67181. push(value: T): void;
  67182. /**
  67183. * Iterates over the active data and apply the lambda to them.
  67184. * @param func defines the action to apply on each value.
  67185. */
  67186. forEach(func: (content: T) => void): void;
  67187. /**
  67188. * Sorts the full sets of data.
  67189. * @param compareFn defines the comparison function to apply.
  67190. */
  67191. sort(compareFn: (a: T, b: T) => number): void;
  67192. /**
  67193. * Resets the active data to an empty array.
  67194. */
  67195. reset(): void;
  67196. /**
  67197. * Releases all the data from the array as well as the array.
  67198. */
  67199. dispose(): void;
  67200. /**
  67201. * Concats the active data with a given array.
  67202. * @param array defines the data to concatenate with.
  67203. */
  67204. concat(array: any): void;
  67205. /**
  67206. * Returns the position of a value in the active data.
  67207. * @param value defines the value to find the index for
  67208. * @returns the index if found in the active data otherwise -1
  67209. */
  67210. indexOf(value: T): number;
  67211. /**
  67212. * Returns whether an element is part of the active data.
  67213. * @param value defines the value to look for
  67214. * @returns true if found in the active data otherwise false
  67215. */
  67216. contains(value: T): boolean;
  67217. private static _GlobalId;
  67218. }
  67219. /**
  67220. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67221. * The data in this array can only be present once
  67222. */
  67223. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67224. private _duplicateId;
  67225. /**
  67226. * Pushes a value at the end of the active data.
  67227. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67228. * @param value defines the object to push in the array.
  67229. */
  67230. push(value: T): void;
  67231. /**
  67232. * Pushes a value at the end of the active data.
  67233. * If the data is already present, it won t be added again
  67234. * @param value defines the object to push in the array.
  67235. * @returns true if added false if it was already present
  67236. */
  67237. pushNoDuplicate(value: T): boolean;
  67238. /**
  67239. * Resets the active data to an empty array.
  67240. */
  67241. reset(): void;
  67242. /**
  67243. * Concats the active data with a given array.
  67244. * This ensures no dupplicate will be present in the result.
  67245. * @param array defines the data to concatenate with.
  67246. */
  67247. concatWithNoDuplicate(array: any): void;
  67248. }
  67249. }
  67250. declare module BABYLON {
  67251. /**
  67252. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67253. * separate meshes. This can be use to improve performances.
  67254. * @see http://doc.babylonjs.com/how_to/multi_materials
  67255. */
  67256. export class MultiMaterial extends Material {
  67257. private _subMaterials;
  67258. /**
  67259. * Gets or Sets the list of Materials used within the multi material.
  67260. * They need to be ordered according to the submeshes order in the associated mesh
  67261. */
  67262. subMaterials: Nullable<Material>[];
  67263. /**
  67264. * Function used to align with Node.getChildren()
  67265. * @returns the list of Materials used within the multi material
  67266. */
  67267. getChildren(): Nullable<Material>[];
  67268. /**
  67269. * Instantiates a new Multi Material
  67270. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67271. * separate meshes. This can be use to improve performances.
  67272. * @see http://doc.babylonjs.com/how_to/multi_materials
  67273. * @param name Define the name in the scene
  67274. * @param scene Define the scene the material belongs to
  67275. */
  67276. constructor(name: string, scene: Scene);
  67277. private _hookArray;
  67278. /**
  67279. * Get one of the submaterial by its index in the submaterials array
  67280. * @param index The index to look the sub material at
  67281. * @returns The Material if the index has been defined
  67282. */
  67283. getSubMaterial(index: number): Nullable<Material>;
  67284. /**
  67285. * Get the list of active textures for the whole sub materials list.
  67286. * @returns All the textures that will be used during the rendering
  67287. */
  67288. getActiveTextures(): BaseTexture[];
  67289. /**
  67290. * Gets the current class name of the material e.g. "MultiMaterial"
  67291. * Mainly use in serialization.
  67292. * @returns the class name
  67293. */
  67294. getClassName(): string;
  67295. /**
  67296. * Checks if the material is ready to render the requested sub mesh
  67297. * @param mesh Define the mesh the submesh belongs to
  67298. * @param subMesh Define the sub mesh to look readyness for
  67299. * @param useInstances Define whether or not the material is used with instances
  67300. * @returns true if ready, otherwise false
  67301. */
  67302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67303. /**
  67304. * Clones the current material and its related sub materials
  67305. * @param name Define the name of the newly cloned material
  67306. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67307. * @returns the cloned material
  67308. */
  67309. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67310. /**
  67311. * Serializes the materials into a JSON representation.
  67312. * @returns the JSON representation
  67313. */
  67314. serialize(): any;
  67315. /**
  67316. * Dispose the material and release its associated resources
  67317. * @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)
  67318. * @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)
  67319. * @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)
  67320. */
  67321. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67322. /**
  67323. * Creates a MultiMaterial from parsed MultiMaterial data.
  67324. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67325. * @param scene defines the hosting scene
  67326. * @returns a new MultiMaterial
  67327. */
  67328. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67329. }
  67330. }
  67331. declare module BABYLON {
  67332. /**
  67333. * Class used to represent data loading progression
  67334. */
  67335. export class SceneLoaderFlags {
  67336. private static _ForceFullSceneLoadingForIncremental;
  67337. private static _ShowLoadingScreen;
  67338. private static _CleanBoneMatrixWeights;
  67339. private static _loggingLevel;
  67340. /**
  67341. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67342. */
  67343. static ForceFullSceneLoadingForIncremental: boolean;
  67344. /**
  67345. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67346. */
  67347. static ShowLoadingScreen: boolean;
  67348. /**
  67349. * Defines the current logging level (while loading the scene)
  67350. * @ignorenaming
  67351. */
  67352. static loggingLevel: number;
  67353. /**
  67354. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67355. */
  67356. static CleanBoneMatrixWeights: boolean;
  67357. }
  67358. }
  67359. declare module BABYLON {
  67360. /**
  67361. * 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.
  67362. * @see https://doc.babylonjs.com/how_to/transformnode
  67363. */
  67364. export class TransformNode extends Node {
  67365. /**
  67366. * Object will not rotate to face the camera
  67367. */
  67368. static BILLBOARDMODE_NONE: number;
  67369. /**
  67370. * Object will rotate to face the camera but only on the x axis
  67371. */
  67372. static BILLBOARDMODE_X: number;
  67373. /**
  67374. * Object will rotate to face the camera but only on the y axis
  67375. */
  67376. static BILLBOARDMODE_Y: number;
  67377. /**
  67378. * Object will rotate to face the camera but only on the z axis
  67379. */
  67380. static BILLBOARDMODE_Z: number;
  67381. /**
  67382. * Object will rotate to face the camera
  67383. */
  67384. static BILLBOARDMODE_ALL: number;
  67385. private _forward;
  67386. private _forwardInverted;
  67387. private _up;
  67388. private _right;
  67389. private _rightInverted;
  67390. private _position;
  67391. private _rotation;
  67392. private _rotationQuaternion;
  67393. protected _scaling: Vector3;
  67394. protected _isDirty: boolean;
  67395. private _transformToBoneReferal;
  67396. private _billboardMode;
  67397. /**
  67398. * Gets or sets the billboard mode. Default is 0.
  67399. *
  67400. * | Value | Type | Description |
  67401. * | --- | --- | --- |
  67402. * | 0 | BILLBOARDMODE_NONE | |
  67403. * | 1 | BILLBOARDMODE_X | |
  67404. * | 2 | BILLBOARDMODE_Y | |
  67405. * | 4 | BILLBOARDMODE_Z | |
  67406. * | 7 | BILLBOARDMODE_ALL | |
  67407. *
  67408. */
  67409. billboardMode: number;
  67410. private _preserveParentRotationForBillboard;
  67411. /**
  67412. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67413. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67414. */
  67415. preserveParentRotationForBillboard: boolean;
  67416. /**
  67417. * 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
  67418. */
  67419. scalingDeterminant: number;
  67420. private _infiniteDistance;
  67421. /**
  67422. * Gets or sets the distance of the object to max, often used by skybox
  67423. */
  67424. infiniteDistance: boolean;
  67425. /**
  67426. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67427. * By default the system will update normals to compensate
  67428. */
  67429. ignoreNonUniformScaling: boolean;
  67430. /**
  67431. * 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
  67432. */
  67433. reIntegrateRotationIntoRotationQuaternion: boolean;
  67434. /** @hidden */
  67435. _poseMatrix: Nullable<Matrix>;
  67436. /** @hidden */
  67437. _localMatrix: Matrix;
  67438. private _usePivotMatrix;
  67439. private _absolutePosition;
  67440. private _pivotMatrix;
  67441. private _pivotMatrixInverse;
  67442. protected _postMultiplyPivotMatrix: boolean;
  67443. protected _isWorldMatrixFrozen: boolean;
  67444. /** @hidden */
  67445. _indexInSceneTransformNodesArray: number;
  67446. /**
  67447. * An event triggered after the world matrix is updated
  67448. */
  67449. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67450. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67451. /**
  67452. * Gets a string identifying the name of the class
  67453. * @returns "TransformNode" string
  67454. */
  67455. getClassName(): string;
  67456. /**
  67457. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67458. */
  67459. position: Vector3;
  67460. /**
  67461. * 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)).
  67462. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67463. */
  67464. rotation: Vector3;
  67465. /**
  67466. * 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)).
  67467. */
  67468. scaling: Vector3;
  67469. /**
  67470. * 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).
  67471. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67472. */
  67473. rotationQuaternion: Nullable<Quaternion>;
  67474. /**
  67475. * The forward direction of that transform in world space.
  67476. */
  67477. readonly forward: Vector3;
  67478. /**
  67479. * The up direction of that transform in world space.
  67480. */
  67481. readonly up: Vector3;
  67482. /**
  67483. * The right direction of that transform in world space.
  67484. */
  67485. readonly right: Vector3;
  67486. /**
  67487. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67488. * @param matrix the matrix to copy the pose from
  67489. * @returns this TransformNode.
  67490. */
  67491. updatePoseMatrix(matrix: Matrix): TransformNode;
  67492. /**
  67493. * Returns the mesh Pose matrix.
  67494. * @returns the pose matrix
  67495. */
  67496. getPoseMatrix(): Matrix;
  67497. /** @hidden */
  67498. _isSynchronized(): boolean;
  67499. /** @hidden */
  67500. _initCache(): void;
  67501. /**
  67502. * Flag the transform node as dirty (Forcing it to update everything)
  67503. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67504. * @returns this transform node
  67505. */
  67506. markAsDirty(property: string): TransformNode;
  67507. /**
  67508. * Returns the current mesh absolute position.
  67509. * Returns a Vector3.
  67510. */
  67511. readonly absolutePosition: Vector3;
  67512. /**
  67513. * Sets a new matrix to apply before all other transformation
  67514. * @param matrix defines the transform matrix
  67515. * @returns the current TransformNode
  67516. */
  67517. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67518. /**
  67519. * Sets a new pivot matrix to the current node
  67520. * @param matrix defines the new pivot matrix to use
  67521. * @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
  67522. * @returns the current TransformNode
  67523. */
  67524. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67525. /**
  67526. * Returns the mesh pivot matrix.
  67527. * Default : Identity.
  67528. * @returns the matrix
  67529. */
  67530. getPivotMatrix(): Matrix;
  67531. /**
  67532. * Prevents the World matrix to be computed any longer.
  67533. * @returns the TransformNode.
  67534. */
  67535. freezeWorldMatrix(): TransformNode;
  67536. /**
  67537. * Allows back the World matrix computation.
  67538. * @returns the TransformNode.
  67539. */
  67540. unfreezeWorldMatrix(): this;
  67541. /**
  67542. * True if the World matrix has been frozen.
  67543. */
  67544. readonly isWorldMatrixFrozen: boolean;
  67545. /**
  67546. * Retuns the mesh absolute position in the World.
  67547. * @returns a Vector3.
  67548. */
  67549. getAbsolutePosition(): Vector3;
  67550. /**
  67551. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67552. * @param absolutePosition the absolute position to set
  67553. * @returns the TransformNode.
  67554. */
  67555. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67556. /**
  67557. * Sets the mesh position in its local space.
  67558. * @param vector3 the position to set in localspace
  67559. * @returns the TransformNode.
  67560. */
  67561. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67562. /**
  67563. * Returns the mesh position in the local space from the current World matrix values.
  67564. * @returns a new Vector3.
  67565. */
  67566. getPositionExpressedInLocalSpace(): Vector3;
  67567. /**
  67568. * Translates the mesh along the passed Vector3 in its local space.
  67569. * @param vector3 the distance to translate in localspace
  67570. * @returns the TransformNode.
  67571. */
  67572. locallyTranslate(vector3: Vector3): TransformNode;
  67573. private static _lookAtVectorCache;
  67574. /**
  67575. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67576. * @param targetPoint the position (must be in same space as current mesh) to look at
  67577. * @param yawCor optional yaw (y-axis) correction in radians
  67578. * @param pitchCor optional pitch (x-axis) correction in radians
  67579. * @param rollCor optional roll (z-axis) correction in radians
  67580. * @param space the choosen space of the target
  67581. * @returns the TransformNode.
  67582. */
  67583. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67584. /**
  67585. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67586. * This Vector3 is expressed in the World space.
  67587. * @param localAxis axis to rotate
  67588. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67589. */
  67590. getDirection(localAxis: Vector3): Vector3;
  67591. /**
  67592. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67593. * localAxis is expressed in the mesh local space.
  67594. * result is computed in the Wordl space from the mesh World matrix.
  67595. * @param localAxis axis to rotate
  67596. * @param result the resulting transformnode
  67597. * @returns this TransformNode.
  67598. */
  67599. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67600. /**
  67601. * Sets this transform node rotation to the given local axis.
  67602. * @param localAxis the axis in local space
  67603. * @param yawCor optional yaw (y-axis) correction in radians
  67604. * @param pitchCor optional pitch (x-axis) correction in radians
  67605. * @param rollCor optional roll (z-axis) correction in radians
  67606. * @returns this TransformNode
  67607. */
  67608. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67609. /**
  67610. * Sets a new pivot point to the current node
  67611. * @param point defines the new pivot point to use
  67612. * @param space defines if the point is in world or local space (local by default)
  67613. * @returns the current TransformNode
  67614. */
  67615. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67616. /**
  67617. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67618. * @returns the pivot point
  67619. */
  67620. getPivotPoint(): Vector3;
  67621. /**
  67622. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67623. * @param result the vector3 to store the result
  67624. * @returns this TransformNode.
  67625. */
  67626. getPivotPointToRef(result: Vector3): TransformNode;
  67627. /**
  67628. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67629. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67630. */
  67631. getAbsolutePivotPoint(): Vector3;
  67632. /**
  67633. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67634. * @param result vector3 to store the result
  67635. * @returns this TransformNode.
  67636. */
  67637. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67638. /**
  67639. * Defines the passed node as the parent of the current node.
  67640. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67641. * @see https://doc.babylonjs.com/how_to/parenting
  67642. * @param node the node ot set as the parent
  67643. * @returns this TransformNode.
  67644. */
  67645. setParent(node: Nullable<Node>): TransformNode;
  67646. private _nonUniformScaling;
  67647. /**
  67648. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67649. */
  67650. readonly nonUniformScaling: boolean;
  67651. /** @hidden */
  67652. _updateNonUniformScalingState(value: boolean): boolean;
  67653. /**
  67654. * Attach the current TransformNode to another TransformNode associated with a bone
  67655. * @param bone Bone affecting the TransformNode
  67656. * @param affectedTransformNode TransformNode associated with the bone
  67657. * @returns this object
  67658. */
  67659. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67660. /**
  67661. * Detach the transform node if its associated with a bone
  67662. * @returns this object
  67663. */
  67664. detachFromBone(): TransformNode;
  67665. private static _rotationAxisCache;
  67666. /**
  67667. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67668. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67669. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67670. * The passed axis is also normalized.
  67671. * @param axis the axis to rotate around
  67672. * @param amount the amount to rotate in radians
  67673. * @param space Space to rotate in (Default: local)
  67674. * @returns the TransformNode.
  67675. */
  67676. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67677. /**
  67678. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67679. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67680. * The passed axis is also normalized. .
  67681. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67682. * @param point the point to rotate around
  67683. * @param axis the axis to rotate around
  67684. * @param amount the amount to rotate in radians
  67685. * @returns the TransformNode
  67686. */
  67687. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67688. /**
  67689. * Translates the mesh along the axis vector for the passed distance in the given space.
  67690. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67691. * @param axis the axis to translate in
  67692. * @param distance the distance to translate
  67693. * @param space Space to rotate in (Default: local)
  67694. * @returns the TransformNode.
  67695. */
  67696. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67697. /**
  67698. * Adds a rotation step to the mesh current rotation.
  67699. * x, y, z are Euler angles expressed in radians.
  67700. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67701. * This means this rotation is made in the mesh local space only.
  67702. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67703. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67704. * ```javascript
  67705. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67706. * ```
  67707. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67708. * 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.
  67709. * @param x Rotation to add
  67710. * @param y Rotation to add
  67711. * @param z Rotation to add
  67712. * @returns the TransformNode.
  67713. */
  67714. addRotation(x: number, y: number, z: number): TransformNode;
  67715. /**
  67716. * @hidden
  67717. */
  67718. protected _getEffectiveParent(): Nullable<Node>;
  67719. /**
  67720. * Computes the world matrix of the node
  67721. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67722. * @returns the world matrix
  67723. */
  67724. computeWorldMatrix(force?: boolean): Matrix;
  67725. protected _afterComputeWorldMatrix(): void;
  67726. /**
  67727. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67728. * @param func callback function to add
  67729. *
  67730. * @returns the TransformNode.
  67731. */
  67732. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67733. /**
  67734. * Removes a registered callback function.
  67735. * @param func callback function to remove
  67736. * @returns the TransformNode.
  67737. */
  67738. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67739. /**
  67740. * Gets the position of the current mesh in camera space
  67741. * @param camera defines the camera to use
  67742. * @returns a position
  67743. */
  67744. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67745. /**
  67746. * Returns the distance from the mesh to the active camera
  67747. * @param camera defines the camera to use
  67748. * @returns the distance
  67749. */
  67750. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67751. /**
  67752. * Clone the current transform node
  67753. * @param name Name of the new clone
  67754. * @param newParent New parent for the clone
  67755. * @param doNotCloneChildren Do not clone children hierarchy
  67756. * @returns the new transform node
  67757. */
  67758. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67759. /**
  67760. * Serializes the objects information.
  67761. * @param currentSerializationObject defines the object to serialize in
  67762. * @returns the serialized object
  67763. */
  67764. serialize(currentSerializationObject?: any): any;
  67765. /**
  67766. * Returns a new TransformNode object parsed from the source provided.
  67767. * @param parsedTransformNode is the source.
  67768. * @param scene the scne the object belongs to
  67769. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67770. * @returns a new TransformNode object parsed from the source provided.
  67771. */
  67772. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67773. /**
  67774. * Get all child-transformNodes of this node
  67775. * @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
  67776. * @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
  67777. * @returns an array of TransformNode
  67778. */
  67779. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67780. /**
  67781. * Releases resources associated with this transform node.
  67782. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67783. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67784. */
  67785. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67786. }
  67787. }
  67788. declare module BABYLON {
  67789. /**
  67790. * Class used to override all child animations of a given target
  67791. */
  67792. export class AnimationPropertiesOverride {
  67793. /**
  67794. * Gets or sets a value indicating if animation blending must be used
  67795. */
  67796. enableBlending: boolean;
  67797. /**
  67798. * Gets or sets the blending speed to use when enableBlending is true
  67799. */
  67800. blendingSpeed: number;
  67801. /**
  67802. * Gets or sets the default loop mode to use
  67803. */
  67804. loopMode: number;
  67805. }
  67806. }
  67807. declare module BABYLON {
  67808. /**
  67809. * Class used to store bone information
  67810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67811. */
  67812. export class Bone extends Node {
  67813. /**
  67814. * defines the bone name
  67815. */
  67816. name: string;
  67817. private static _tmpVecs;
  67818. private static _tmpQuat;
  67819. private static _tmpMats;
  67820. /**
  67821. * Gets the list of child bones
  67822. */
  67823. children: Bone[];
  67824. /** Gets the animations associated with this bone */
  67825. animations: Animation[];
  67826. /**
  67827. * Gets or sets bone length
  67828. */
  67829. length: number;
  67830. /**
  67831. * @hidden Internal only
  67832. * Set this value to map this bone to a different index in the transform matrices
  67833. * Set this value to -1 to exclude the bone from the transform matrices
  67834. */
  67835. _index: Nullable<number>;
  67836. private _skeleton;
  67837. private _localMatrix;
  67838. private _restPose;
  67839. private _baseMatrix;
  67840. private _absoluteTransform;
  67841. private _invertedAbsoluteTransform;
  67842. private _parent;
  67843. private _scalingDeterminant;
  67844. private _worldTransform;
  67845. private _localScaling;
  67846. private _localRotation;
  67847. private _localPosition;
  67848. private _needToDecompose;
  67849. private _needToCompose;
  67850. /** @hidden */
  67851. _linkedTransformNode: Nullable<TransformNode>;
  67852. /** @hidden */
  67853. /** @hidden */
  67854. _matrix: Matrix;
  67855. /**
  67856. * Create a new bone
  67857. * @param name defines the bone name
  67858. * @param skeleton defines the parent skeleton
  67859. * @param parentBone defines the parent (can be null if the bone is the root)
  67860. * @param localMatrix defines the local matrix
  67861. * @param restPose defines the rest pose matrix
  67862. * @param baseMatrix defines the base matrix
  67863. * @param index defines index of the bone in the hiearchy
  67864. */
  67865. constructor(
  67866. /**
  67867. * defines the bone name
  67868. */
  67869. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67870. /**
  67871. * Gets the current object class name.
  67872. * @return the class name
  67873. */
  67874. getClassName(): string;
  67875. /**
  67876. * Gets the parent skeleton
  67877. * @returns a skeleton
  67878. */
  67879. getSkeleton(): Skeleton;
  67880. /**
  67881. * Gets parent bone
  67882. * @returns a bone or null if the bone is the root of the bone hierarchy
  67883. */
  67884. getParent(): Nullable<Bone>;
  67885. /**
  67886. * Returns an array containing the root bones
  67887. * @returns an array containing the root bones
  67888. */
  67889. getChildren(): Array<Bone>;
  67890. /**
  67891. * Sets the parent bone
  67892. * @param parent defines the parent (can be null if the bone is the root)
  67893. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67894. */
  67895. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67896. /**
  67897. * Gets the local matrix
  67898. * @returns a matrix
  67899. */
  67900. getLocalMatrix(): Matrix;
  67901. /**
  67902. * Gets the base matrix (initial matrix which remains unchanged)
  67903. * @returns a matrix
  67904. */
  67905. getBaseMatrix(): Matrix;
  67906. /**
  67907. * Gets the rest pose matrix
  67908. * @returns a matrix
  67909. */
  67910. getRestPose(): Matrix;
  67911. /**
  67912. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67913. */
  67914. getWorldMatrix(): Matrix;
  67915. /**
  67916. * Sets the local matrix to rest pose matrix
  67917. */
  67918. returnToRest(): void;
  67919. /**
  67920. * Gets the inverse of the absolute transform matrix.
  67921. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67922. * @returns a matrix
  67923. */
  67924. getInvertedAbsoluteTransform(): Matrix;
  67925. /**
  67926. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67927. * @returns a matrix
  67928. */
  67929. getAbsoluteTransform(): Matrix;
  67930. /**
  67931. * Links with the given transform node.
  67932. * The local matrix of this bone is copied from the transform node every frame.
  67933. * @param transformNode defines the transform node to link to
  67934. */
  67935. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67936. /** Gets or sets current position (in local space) */
  67937. position: Vector3;
  67938. /** Gets or sets current rotation (in local space) */
  67939. rotation: Vector3;
  67940. /** Gets or sets current rotation quaternion (in local space) */
  67941. rotationQuaternion: Quaternion;
  67942. /** Gets or sets current scaling (in local space) */
  67943. scaling: Vector3;
  67944. /**
  67945. * Gets the animation properties override
  67946. */
  67947. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67948. private _decompose;
  67949. private _compose;
  67950. /**
  67951. * Update the base and local matrices
  67952. * @param matrix defines the new base or local matrix
  67953. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67954. * @param updateLocalMatrix defines if the local matrix should be updated
  67955. */
  67956. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67957. /** @hidden */
  67958. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67959. /**
  67960. * Flag the bone as dirty (Forcing it to update everything)
  67961. */
  67962. markAsDirty(): void;
  67963. private _markAsDirtyAndCompose;
  67964. private _markAsDirtyAndDecompose;
  67965. /**
  67966. * Translate the bone in local or world space
  67967. * @param vec The amount to translate the bone
  67968. * @param space The space that the translation is in
  67969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67970. */
  67971. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67972. /**
  67973. * Set the postion of the bone in local or world space
  67974. * @param position The position to set the bone
  67975. * @param space The space that the position is in
  67976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67977. */
  67978. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67979. /**
  67980. * Set the absolute position of the bone (world space)
  67981. * @param position The position to set the bone
  67982. * @param mesh The mesh that this bone is attached to
  67983. */
  67984. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67985. /**
  67986. * Scale the bone on the x, y and z axes (in local space)
  67987. * @param x The amount to scale the bone on the x axis
  67988. * @param y The amount to scale the bone on the y axis
  67989. * @param z The amount to scale the bone on the z axis
  67990. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67991. */
  67992. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67993. /**
  67994. * Set the bone scaling in local space
  67995. * @param scale defines the scaling vector
  67996. */
  67997. setScale(scale: Vector3): void;
  67998. /**
  67999. * Gets the current scaling in local space
  68000. * @returns the current scaling vector
  68001. */
  68002. getScale(): Vector3;
  68003. /**
  68004. * Gets the current scaling in local space and stores it in a target vector
  68005. * @param result defines the target vector
  68006. */
  68007. getScaleToRef(result: Vector3): void;
  68008. /**
  68009. * Set the yaw, pitch, and roll of the bone in local or world space
  68010. * @param yaw The rotation of the bone on the y axis
  68011. * @param pitch The rotation of the bone on the x axis
  68012. * @param roll The rotation of the bone on the z axis
  68013. * @param space The space that the axes of rotation are in
  68014. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68015. */
  68016. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68017. /**
  68018. * Add a rotation to the bone on an axis in local or world space
  68019. * @param axis The axis to rotate the bone on
  68020. * @param amount The amount to rotate the bone
  68021. * @param space The space that the axis is in
  68022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68023. */
  68024. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68025. /**
  68026. * Set the rotation of the bone to a particular axis angle in local or world space
  68027. * @param axis The axis to rotate the bone on
  68028. * @param angle The angle that the bone should be rotated to
  68029. * @param space The space that the axis is in
  68030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68031. */
  68032. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68033. /**
  68034. * Set the euler rotation of the bone in local of world space
  68035. * @param rotation The euler rotation that the bone should be set to
  68036. * @param space The space that the rotation is in
  68037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68038. */
  68039. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68040. /**
  68041. * Set the quaternion rotation of the bone in local of world space
  68042. * @param quat The quaternion rotation that the bone should be set to
  68043. * @param space The space that the rotation is in
  68044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68045. */
  68046. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68047. /**
  68048. * Set the rotation matrix of the bone in local of world space
  68049. * @param rotMat The rotation matrix that the bone should be set to
  68050. * @param space The space that the rotation is in
  68051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68052. */
  68053. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68054. private _rotateWithMatrix;
  68055. private _getNegativeRotationToRef;
  68056. /**
  68057. * Get the position of the bone in local or world space
  68058. * @param space The space that the returned position is in
  68059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68060. * @returns The position of the bone
  68061. */
  68062. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68063. /**
  68064. * Copy the position of the bone to a vector3 in local or world space
  68065. * @param space The space that the returned position is in
  68066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68067. * @param result The vector3 to copy the position to
  68068. */
  68069. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68070. /**
  68071. * Get the absolute position of the bone (world space)
  68072. * @param mesh The mesh that this bone is attached to
  68073. * @returns The absolute position of the bone
  68074. */
  68075. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68076. /**
  68077. * Copy the absolute position of the bone (world space) to the result param
  68078. * @param mesh The mesh that this bone is attached to
  68079. * @param result The vector3 to copy the absolute position to
  68080. */
  68081. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68082. /**
  68083. * Compute the absolute transforms of this bone and its children
  68084. */
  68085. computeAbsoluteTransforms(): void;
  68086. /**
  68087. * Get the world direction from an axis that is in the local space of the bone
  68088. * @param localAxis The local direction that is used to compute the world direction
  68089. * @param mesh The mesh that this bone is attached to
  68090. * @returns The world direction
  68091. */
  68092. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68093. /**
  68094. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68095. * @param localAxis The local direction that is used to compute the world direction
  68096. * @param mesh The mesh that this bone is attached to
  68097. * @param result The vector3 that the world direction will be copied to
  68098. */
  68099. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68100. /**
  68101. * Get the euler rotation of the bone in local or world space
  68102. * @param space The space that the rotation should be in
  68103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68104. * @returns The euler rotation
  68105. */
  68106. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68107. /**
  68108. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68109. * @param space The space that the rotation should be in
  68110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68111. * @param result The vector3 that the rotation should be copied to
  68112. */
  68113. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68114. /**
  68115. * Get the quaternion rotation of the bone in either local or world space
  68116. * @param space The space that the rotation should be in
  68117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68118. * @returns The quaternion rotation
  68119. */
  68120. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68121. /**
  68122. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68123. * @param space The space that the rotation should be in
  68124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68125. * @param result The quaternion that the rotation should be copied to
  68126. */
  68127. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68128. /**
  68129. * Get the rotation matrix of the bone in local or world space
  68130. * @param space The space that the rotation should be in
  68131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68132. * @returns The rotation matrix
  68133. */
  68134. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68135. /**
  68136. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68137. * @param space The space that the rotation should be in
  68138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68139. * @param result The quaternion that the rotation should be copied to
  68140. */
  68141. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68142. /**
  68143. * Get the world position of a point that is in the local space of the bone
  68144. * @param position The local position
  68145. * @param mesh The mesh that this bone is attached to
  68146. * @returns The world position
  68147. */
  68148. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68149. /**
  68150. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68151. * @param position The local position
  68152. * @param mesh The mesh that this bone is attached to
  68153. * @param result The vector3 that the world position should be copied to
  68154. */
  68155. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68156. /**
  68157. * Get the local position of a point that is in world space
  68158. * @param position The world position
  68159. * @param mesh The mesh that this bone is attached to
  68160. * @returns The local position
  68161. */
  68162. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68163. /**
  68164. * Get the local position of a point that is in world space and copy it to the result param
  68165. * @param position The world position
  68166. * @param mesh The mesh that this bone is attached to
  68167. * @param result The vector3 that the local position should be copied to
  68168. */
  68169. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68170. }
  68171. }
  68172. declare module BABYLON {
  68173. /**
  68174. * Enum that determines the text-wrapping mode to use.
  68175. */
  68176. export enum InspectableType {
  68177. /**
  68178. * Checkbox for booleans
  68179. */
  68180. Checkbox = 0,
  68181. /**
  68182. * Sliders for numbers
  68183. */
  68184. Slider = 1,
  68185. /**
  68186. * Vector3
  68187. */
  68188. Vector3 = 2,
  68189. /**
  68190. * Quaternions
  68191. */
  68192. Quaternion = 3,
  68193. /**
  68194. * Color3
  68195. */
  68196. Color3 = 4
  68197. }
  68198. /**
  68199. * Interface used to define custom inspectable properties.
  68200. * This interface is used by the inspector to display custom property grids
  68201. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68202. */
  68203. export interface IInspectable {
  68204. /**
  68205. * Gets the label to display
  68206. */
  68207. label: string;
  68208. /**
  68209. * Gets the name of the property to edit
  68210. */
  68211. propertyName: string;
  68212. /**
  68213. * Gets the type of the editor to use
  68214. */
  68215. type: InspectableType;
  68216. /**
  68217. * Gets the minimum value of the property when using in "slider" mode
  68218. */
  68219. min?: number;
  68220. /**
  68221. * Gets the maximum value of the property when using in "slider" mode
  68222. */
  68223. max?: number;
  68224. /**
  68225. * Gets the setp to use when using in "slider" mode
  68226. */
  68227. step?: number;
  68228. }
  68229. }
  68230. declare module BABYLON {
  68231. /**
  68232. * This represents the required contract to create a new type of texture loader.
  68233. */
  68234. export interface IInternalTextureLoader {
  68235. /**
  68236. * Defines wether the loader supports cascade loading the different faces.
  68237. */
  68238. supportCascades: boolean;
  68239. /**
  68240. * This returns if the loader support the current file information.
  68241. * @param extension defines the file extension of the file being loaded
  68242. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68243. * @param fallback defines the fallback internal texture if any
  68244. * @param isBase64 defines whether the texture is encoded as a base64
  68245. * @param isBuffer defines whether the texture data are stored as a buffer
  68246. * @returns true if the loader can load the specified file
  68247. */
  68248. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68249. /**
  68250. * Transform the url before loading if required.
  68251. * @param rootUrl the url of the texture
  68252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68253. * @returns the transformed texture
  68254. */
  68255. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68256. /**
  68257. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68258. * @param rootUrl the url of the texture
  68259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68260. * @returns the fallback texture
  68261. */
  68262. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68263. /**
  68264. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68265. * @param data contains the texture data
  68266. * @param texture defines the BabylonJS internal texture
  68267. * @param createPolynomials will be true if polynomials have been requested
  68268. * @param onLoad defines the callback to trigger once the texture is ready
  68269. * @param onError defines the callback to trigger in case of error
  68270. */
  68271. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68272. /**
  68273. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68274. * @param data contains the texture data
  68275. * @param texture defines the BabylonJS internal texture
  68276. * @param callback defines the method to call once ready to upload
  68277. */
  68278. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68279. }
  68280. }
  68281. declare module BABYLON {
  68282. interface Engine {
  68283. /**
  68284. * Creates a depth stencil cube texture.
  68285. * This is only available in WebGL 2.
  68286. * @param size The size of face edge in the cube texture.
  68287. * @param options The options defining the cube texture.
  68288. * @returns The cube texture
  68289. */
  68290. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68291. /**
  68292. * Creates a cube texture
  68293. * @param rootUrl defines the url where the files to load is located
  68294. * @param scene defines the current scene
  68295. * @param files defines the list of files to load (1 per face)
  68296. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68297. * @param onLoad defines an optional callback raised when the texture is loaded
  68298. * @param onError defines an optional callback raised if there is an issue to load the texture
  68299. * @param format defines the format of the data
  68300. * @param forcedExtension defines the extension to use to pick the right loader
  68301. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68302. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68303. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68304. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68305. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68306. * @returns the cube texture as an InternalTexture
  68307. */
  68308. 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;
  68309. /**
  68310. * Creates a cube texture
  68311. * @param rootUrl defines the url where the files to load is located
  68312. * @param scene defines the current scene
  68313. * @param files defines the list of files to load (1 per face)
  68314. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68315. * @param onLoad defines an optional callback raised when the texture is loaded
  68316. * @param onError defines an optional callback raised if there is an issue to load the texture
  68317. * @param format defines the format of the data
  68318. * @param forcedExtension defines the extension to use to pick the right loader
  68319. * @returns the cube texture as an InternalTexture
  68320. */
  68321. 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;
  68322. /**
  68323. * Creates a cube texture
  68324. * @param rootUrl defines the url where the files to load is located
  68325. * @param scene defines the current scene
  68326. * @param files defines the list of files to load (1 per face)
  68327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68328. * @param onLoad defines an optional callback raised when the texture is loaded
  68329. * @param onError defines an optional callback raised if there is an issue to load the texture
  68330. * @param format defines the format of the data
  68331. * @param forcedExtension defines the extension to use to pick the right loader
  68332. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68333. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68334. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68335. * @returns the cube texture as an InternalTexture
  68336. */
  68337. 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;
  68338. /** @hidden */
  68339. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68340. /** @hidden */
  68341. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68342. /** @hidden */
  68343. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68344. /** @hidden */
  68345. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68346. }
  68347. }
  68348. declare module BABYLON {
  68349. /**
  68350. * Class for creating a cube texture
  68351. */
  68352. export class CubeTexture extends BaseTexture {
  68353. private _delayedOnLoad;
  68354. /**
  68355. * The url of the texture
  68356. */
  68357. url: string;
  68358. /**
  68359. * Gets or sets the center of the bounding box associated with the cube texture.
  68360. * It must define where the camera used to render the texture was set
  68361. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68362. */
  68363. boundingBoxPosition: Vector3;
  68364. private _boundingBoxSize;
  68365. /**
  68366. * Gets or sets the size of the bounding box associated with the cube texture
  68367. * When defined, the cubemap will switch to local mode
  68368. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68369. * @example https://www.babylonjs-playground.com/#RNASML
  68370. */
  68371. /**
  68372. * Returns the bounding box size
  68373. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68374. */
  68375. boundingBoxSize: Vector3;
  68376. protected _rotationY: number;
  68377. /**
  68378. * Sets texture matrix rotation angle around Y axis in radians.
  68379. */
  68380. /**
  68381. * Gets texture matrix rotation angle around Y axis radians.
  68382. */
  68383. rotationY: number;
  68384. /**
  68385. * Are mip maps generated for this texture or not.
  68386. */
  68387. readonly noMipmap: boolean;
  68388. private _noMipmap;
  68389. private _files;
  68390. private _extensions;
  68391. private _textureMatrix;
  68392. private _format;
  68393. private _createPolynomials;
  68394. /** @hidden */
  68395. _prefiltered: boolean;
  68396. /**
  68397. * Creates a cube texture from an array of image urls
  68398. * @param files defines an array of image urls
  68399. * @param scene defines the hosting scene
  68400. * @param noMipmap specifies if mip maps are not used
  68401. * @returns a cube texture
  68402. */
  68403. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68404. /**
  68405. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68406. * @param url defines the url of the prefiltered texture
  68407. * @param scene defines the scene the texture is attached to
  68408. * @param forcedExtension defines the extension of the file if different from the url
  68409. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68410. * @return the prefiltered texture
  68411. */
  68412. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68413. /**
  68414. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68415. * as prefiltered data.
  68416. * @param rootUrl defines the url of the texture or the root name of the six images
  68417. * @param scene defines the scene the texture is attached to
  68418. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68419. * @param noMipmap defines if mipmaps should be created or not
  68420. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68421. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68422. * @param onError defines a callback triggered in case of error during load
  68423. * @param format defines the internal format to use for the texture once loaded
  68424. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68425. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68426. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68427. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68428. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68429. * @return the cube texture
  68430. */
  68431. 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);
  68432. /**
  68433. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68434. */
  68435. readonly isPrefiltered: boolean;
  68436. /**
  68437. * Get the current class name of the texture useful for serialization or dynamic coding.
  68438. * @returns "CubeTexture"
  68439. */
  68440. getClassName(): string;
  68441. /**
  68442. * Update the url (and optional buffer) of this texture if url was null during construction.
  68443. * @param url the url of the texture
  68444. * @param forcedExtension defines the extension to use
  68445. * @param onLoad callback called when the texture is loaded (defaults to null)
  68446. */
  68447. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68448. /**
  68449. * Delays loading of the cube texture
  68450. * @param forcedExtension defines the extension to use
  68451. */
  68452. delayLoad(forcedExtension?: string): void;
  68453. /**
  68454. * Returns the reflection texture matrix
  68455. * @returns the reflection texture matrix
  68456. */
  68457. getReflectionTextureMatrix(): Matrix;
  68458. /**
  68459. * Sets the reflection texture matrix
  68460. * @param value Reflection texture matrix
  68461. */
  68462. setReflectionTextureMatrix(value: Matrix): void;
  68463. /**
  68464. * Parses text to create a cube texture
  68465. * @param parsedTexture define the serialized text to read from
  68466. * @param scene defines the hosting scene
  68467. * @param rootUrl defines the root url of the cube texture
  68468. * @returns a cube texture
  68469. */
  68470. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68471. /**
  68472. * Makes a clone, or deep copy, of the cube texture
  68473. * @returns a new cube texture
  68474. */
  68475. clone(): CubeTexture;
  68476. }
  68477. }
  68478. declare module BABYLON {
  68479. /** @hidden */
  68480. export var postprocessVertexShader: {
  68481. name: string;
  68482. shader: string;
  68483. };
  68484. }
  68485. declare module BABYLON {
  68486. /**
  68487. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68488. * This is the base of the follow, arc rotate cameras and Free camera
  68489. * @see http://doc.babylonjs.com/features/cameras
  68490. */
  68491. export class TargetCamera extends Camera {
  68492. private static _RigCamTransformMatrix;
  68493. private static _TargetTransformMatrix;
  68494. private static _TargetFocalPoint;
  68495. /**
  68496. * Define the current direction the camera is moving to
  68497. */
  68498. cameraDirection: Vector3;
  68499. /**
  68500. * Define the current rotation the camera is rotating to
  68501. */
  68502. cameraRotation: Vector2;
  68503. /**
  68504. * When set, the up vector of the camera will be updated by the rotation of the camera
  68505. */
  68506. updateUpVectorFromRotation: boolean;
  68507. private _tmpQuaternion;
  68508. /**
  68509. * Define the current rotation of the camera
  68510. */
  68511. rotation: Vector3;
  68512. /**
  68513. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68514. */
  68515. rotationQuaternion: Quaternion;
  68516. /**
  68517. * Define the current speed of the camera
  68518. */
  68519. speed: number;
  68520. /**
  68521. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68522. * around all axis.
  68523. */
  68524. noRotationConstraint: boolean;
  68525. /**
  68526. * Define the current target of the camera as an object or a position.
  68527. */
  68528. lockedTarget: any;
  68529. /** @hidden */
  68530. _currentTarget: Vector3;
  68531. /** @hidden */
  68532. _initialFocalDistance: number;
  68533. /** @hidden */
  68534. _viewMatrix: Matrix;
  68535. /** @hidden */
  68536. _camMatrix: Matrix;
  68537. /** @hidden */
  68538. _cameraTransformMatrix: Matrix;
  68539. /** @hidden */
  68540. _cameraRotationMatrix: Matrix;
  68541. /** @hidden */
  68542. _referencePoint: Vector3;
  68543. /** @hidden */
  68544. _transformedReferencePoint: Vector3;
  68545. protected _globalCurrentTarget: Vector3;
  68546. protected _globalCurrentUpVector: Vector3;
  68547. /** @hidden */
  68548. _reset: () => void;
  68549. private _defaultUp;
  68550. /**
  68551. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68552. * This is the base of the follow, arc rotate cameras and Free camera
  68553. * @see http://doc.babylonjs.com/features/cameras
  68554. * @param name Defines the name of the camera in the scene
  68555. * @param position Defines the start position of the camera in the scene
  68556. * @param scene Defines the scene the camera belongs to
  68557. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68558. */
  68559. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68560. /**
  68561. * Gets the position in front of the camera at a given distance.
  68562. * @param distance The distance from the camera we want the position to be
  68563. * @returns the position
  68564. */
  68565. getFrontPosition(distance: number): Vector3;
  68566. /** @hidden */
  68567. _getLockedTargetPosition(): Nullable<Vector3>;
  68568. private _storedPosition;
  68569. private _storedRotation;
  68570. private _storedRotationQuaternion;
  68571. /**
  68572. * Store current camera state of the camera (fov, position, rotation, etc..)
  68573. * @returns the camera
  68574. */
  68575. storeState(): Camera;
  68576. /**
  68577. * Restored camera state. You must call storeState() first
  68578. * @returns whether it was successful or not
  68579. * @hidden
  68580. */
  68581. _restoreStateValues(): boolean;
  68582. /** @hidden */
  68583. _initCache(): void;
  68584. /** @hidden */
  68585. _updateCache(ignoreParentClass?: boolean): void;
  68586. /** @hidden */
  68587. _isSynchronizedViewMatrix(): boolean;
  68588. /** @hidden */
  68589. _computeLocalCameraSpeed(): number;
  68590. /**
  68591. * Defines the target the camera should look at.
  68592. * This will automatically adapt alpha beta and radius to fit within the new target.
  68593. * @param target Defines the new target as a Vector or a mesh
  68594. */
  68595. setTarget(target: Vector3): void;
  68596. /**
  68597. * Return the current target position of the camera. This value is expressed in local space.
  68598. * @returns the target position
  68599. */
  68600. getTarget(): Vector3;
  68601. /** @hidden */
  68602. _decideIfNeedsToMove(): boolean;
  68603. /** @hidden */
  68604. _updatePosition(): void;
  68605. /** @hidden */
  68606. _checkInputs(): void;
  68607. protected _updateCameraRotationMatrix(): void;
  68608. /**
  68609. * 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)
  68610. * @returns the current camera
  68611. */
  68612. private _rotateUpVectorWithCameraRotationMatrix;
  68613. private _cachedRotationZ;
  68614. private _cachedQuaternionRotationZ;
  68615. /** @hidden */
  68616. _getViewMatrix(): Matrix;
  68617. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68618. /**
  68619. * @hidden
  68620. */
  68621. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68622. /**
  68623. * @hidden
  68624. */
  68625. _updateRigCameras(): void;
  68626. private _getRigCamPositionAndTarget;
  68627. /**
  68628. * Gets the current object class name.
  68629. * @return the class name
  68630. */
  68631. getClassName(): string;
  68632. }
  68633. }
  68634. declare module BABYLON {
  68635. /**
  68636. * @ignore
  68637. * This is a list of all the different input types that are available in the application.
  68638. * Fo instance: ArcRotateCameraGamepadInput...
  68639. */
  68640. export var CameraInputTypes: {};
  68641. /**
  68642. * This is the contract to implement in order to create a new input class.
  68643. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68644. */
  68645. export interface ICameraInput<TCamera extends Camera> {
  68646. /**
  68647. * Defines the camera the input is attached to.
  68648. */
  68649. camera: Nullable<TCamera>;
  68650. /**
  68651. * Gets the class name of the current intput.
  68652. * @returns the class name
  68653. */
  68654. getClassName(): string;
  68655. /**
  68656. * Get the friendly name associated with the input class.
  68657. * @returns the input friendly name
  68658. */
  68659. getSimpleName(): string;
  68660. /**
  68661. * Attach the input controls to a specific dom element to get the input from.
  68662. * @param element Defines the element the controls should be listened from
  68663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68664. */
  68665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68666. /**
  68667. * Detach the current controls from the specified dom element.
  68668. * @param element Defines the element to stop listening the inputs from
  68669. */
  68670. detachControl(element: Nullable<HTMLElement>): void;
  68671. /**
  68672. * Update the current camera state depending on the inputs that have been used this frame.
  68673. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68674. */
  68675. checkInputs?: () => void;
  68676. }
  68677. /**
  68678. * Represents a map of input types to input instance or input index to input instance.
  68679. */
  68680. export interface CameraInputsMap<TCamera extends Camera> {
  68681. /**
  68682. * Accessor to the input by input type.
  68683. */
  68684. [name: string]: ICameraInput<TCamera>;
  68685. /**
  68686. * Accessor to the input by input index.
  68687. */
  68688. [idx: number]: ICameraInput<TCamera>;
  68689. }
  68690. /**
  68691. * This represents the input manager used within a camera.
  68692. * It helps dealing with all the different kind of input attached to a camera.
  68693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68694. */
  68695. export class CameraInputsManager<TCamera extends Camera> {
  68696. /**
  68697. * Defines the list of inputs attahed to the camera.
  68698. */
  68699. attached: CameraInputsMap<TCamera>;
  68700. /**
  68701. * Defines the dom element the camera is collecting inputs from.
  68702. * This is null if the controls have not been attached.
  68703. */
  68704. attachedElement: Nullable<HTMLElement>;
  68705. /**
  68706. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68707. */
  68708. noPreventDefault: boolean;
  68709. /**
  68710. * Defined the camera the input manager belongs to.
  68711. */
  68712. camera: TCamera;
  68713. /**
  68714. * Update the current camera state depending on the inputs that have been used this frame.
  68715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68716. */
  68717. checkInputs: () => void;
  68718. /**
  68719. * Instantiate a new Camera Input Manager.
  68720. * @param camera Defines the camera the input manager blongs to
  68721. */
  68722. constructor(camera: TCamera);
  68723. /**
  68724. * Add an input method to a camera
  68725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68726. * @param input camera input method
  68727. */
  68728. add(input: ICameraInput<TCamera>): void;
  68729. /**
  68730. * Remove a specific input method from a camera
  68731. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68732. * @param inputToRemove camera input method
  68733. */
  68734. remove(inputToRemove: ICameraInput<TCamera>): void;
  68735. /**
  68736. * Remove a specific input type from a camera
  68737. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68738. * @param inputType the type of the input to remove
  68739. */
  68740. removeByType(inputType: string): void;
  68741. private _addCheckInputs;
  68742. /**
  68743. * Attach the input controls to the currently attached dom element to listen the events from.
  68744. * @param input Defines the input to attach
  68745. */
  68746. attachInput(input: ICameraInput<TCamera>): void;
  68747. /**
  68748. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68749. * @param element Defines the dom element to collect the events from
  68750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68751. */
  68752. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68753. /**
  68754. * Detach the current manager inputs controls from a specific dom element.
  68755. * @param element Defines the dom element to collect the events from
  68756. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68757. */
  68758. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68759. /**
  68760. * Rebuild the dynamic inputCheck function from the current list of
  68761. * defined inputs in the manager.
  68762. */
  68763. rebuildInputCheck(): void;
  68764. /**
  68765. * Remove all attached input methods from a camera
  68766. */
  68767. clear(): void;
  68768. /**
  68769. * Serialize the current input manager attached to a camera.
  68770. * This ensures than once parsed,
  68771. * the input associated to the camera will be identical to the current ones
  68772. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68773. */
  68774. serialize(serializedCamera: any): void;
  68775. /**
  68776. * Parses an input manager serialized JSON to restore the previous list of inputs
  68777. * and states associated to a camera.
  68778. * @param parsedCamera Defines the JSON to parse
  68779. */
  68780. parse(parsedCamera: any): void;
  68781. }
  68782. }
  68783. declare module BABYLON {
  68784. /**
  68785. * Gather the list of keyboard event types as constants.
  68786. */
  68787. export class KeyboardEventTypes {
  68788. /**
  68789. * The keydown event is fired when a key becomes active (pressed).
  68790. */
  68791. static readonly KEYDOWN: number;
  68792. /**
  68793. * The keyup event is fired when a key has been released.
  68794. */
  68795. static readonly KEYUP: number;
  68796. }
  68797. /**
  68798. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68799. */
  68800. export class KeyboardInfo {
  68801. /**
  68802. * Defines the type of event (KeyboardEventTypes)
  68803. */
  68804. type: number;
  68805. /**
  68806. * Defines the related dom event
  68807. */
  68808. event: KeyboardEvent;
  68809. /**
  68810. * Instantiates a new keyboard info.
  68811. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68812. * @param type Defines the type of event (KeyboardEventTypes)
  68813. * @param event Defines the related dom event
  68814. */
  68815. constructor(
  68816. /**
  68817. * Defines the type of event (KeyboardEventTypes)
  68818. */
  68819. type: number,
  68820. /**
  68821. * Defines the related dom event
  68822. */
  68823. event: KeyboardEvent);
  68824. }
  68825. /**
  68826. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68827. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68828. */
  68829. export class KeyboardInfoPre extends KeyboardInfo {
  68830. /**
  68831. * Defines the type of event (KeyboardEventTypes)
  68832. */
  68833. type: number;
  68834. /**
  68835. * Defines the related dom event
  68836. */
  68837. event: KeyboardEvent;
  68838. /**
  68839. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68840. */
  68841. skipOnPointerObservable: boolean;
  68842. /**
  68843. * Instantiates a new keyboard pre info.
  68844. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68845. * @param type Defines the type of event (KeyboardEventTypes)
  68846. * @param event Defines the related dom event
  68847. */
  68848. constructor(
  68849. /**
  68850. * Defines the type of event (KeyboardEventTypes)
  68851. */
  68852. type: number,
  68853. /**
  68854. * Defines the related dom event
  68855. */
  68856. event: KeyboardEvent);
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * Manage the keyboard inputs to control the movement of a free camera.
  68862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68863. */
  68864. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68865. /**
  68866. * Defines the camera the input is attached to.
  68867. */
  68868. camera: FreeCamera;
  68869. /**
  68870. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68871. */
  68872. keysUp: number[];
  68873. /**
  68874. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68875. */
  68876. keysDown: number[];
  68877. /**
  68878. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68879. */
  68880. keysLeft: number[];
  68881. /**
  68882. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68883. */
  68884. keysRight: number[];
  68885. private _keys;
  68886. private _onCanvasBlurObserver;
  68887. private _onKeyboardObserver;
  68888. private _engine;
  68889. private _scene;
  68890. /**
  68891. * Attach the input controls to a specific dom element to get the input from.
  68892. * @param element Defines the element the controls should be listened from
  68893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68894. */
  68895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68896. /**
  68897. * Detach the current controls from the specified dom element.
  68898. * @param element Defines the element to stop listening the inputs from
  68899. */
  68900. detachControl(element: Nullable<HTMLElement>): void;
  68901. /**
  68902. * Update the current camera state depending on the inputs that have been used this frame.
  68903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68904. */
  68905. checkInputs(): void;
  68906. /**
  68907. * Gets the class name of the current intput.
  68908. * @returns the class name
  68909. */
  68910. getClassName(): string;
  68911. /** @hidden */
  68912. _onLostFocus(): void;
  68913. /**
  68914. * Get the friendly name associated with the input class.
  68915. * @returns the input friendly name
  68916. */
  68917. getSimpleName(): string;
  68918. }
  68919. }
  68920. declare module BABYLON {
  68921. /**
  68922. * Interface describing all the common properties and methods a shadow light needs to implement.
  68923. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68924. * as well as binding the different shadow properties to the effects.
  68925. */
  68926. export interface IShadowLight extends Light {
  68927. /**
  68928. * The light id in the scene (used in scene.findLighById for instance)
  68929. */
  68930. id: string;
  68931. /**
  68932. * The position the shdow will be casted from.
  68933. */
  68934. position: Vector3;
  68935. /**
  68936. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68937. */
  68938. direction: Vector3;
  68939. /**
  68940. * The transformed position. Position of the light in world space taking parenting in account.
  68941. */
  68942. transformedPosition: Vector3;
  68943. /**
  68944. * The transformed direction. Direction of the light in world space taking parenting in account.
  68945. */
  68946. transformedDirection: Vector3;
  68947. /**
  68948. * The friendly name of the light in the scene.
  68949. */
  68950. name: string;
  68951. /**
  68952. * Defines the shadow projection clipping minimum z value.
  68953. */
  68954. shadowMinZ: number;
  68955. /**
  68956. * Defines the shadow projection clipping maximum z value.
  68957. */
  68958. shadowMaxZ: number;
  68959. /**
  68960. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68961. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68962. */
  68963. computeTransformedInformation(): boolean;
  68964. /**
  68965. * Gets the scene the light belongs to.
  68966. * @returns The scene
  68967. */
  68968. getScene(): Scene;
  68969. /**
  68970. * Callback defining a custom Projection Matrix Builder.
  68971. * This can be used to override the default projection matrix computation.
  68972. */
  68973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68974. /**
  68975. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68976. * @param matrix The materix to updated with the projection information
  68977. * @param viewMatrix The transform matrix of the light
  68978. * @param renderList The list of mesh to render in the map
  68979. * @returns The current light
  68980. */
  68981. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68982. /**
  68983. * Gets the current depth scale used in ESM.
  68984. * @returns The scale
  68985. */
  68986. getDepthScale(): number;
  68987. /**
  68988. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68989. * @returns true if a cube texture needs to be use
  68990. */
  68991. needCube(): boolean;
  68992. /**
  68993. * Detects if the projection matrix requires to be recomputed this frame.
  68994. * @returns true if it requires to be recomputed otherwise, false.
  68995. */
  68996. needProjectionMatrixCompute(): boolean;
  68997. /**
  68998. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68999. */
  69000. forceProjectionMatrixCompute(): void;
  69001. /**
  69002. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69003. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69004. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69005. */
  69006. getShadowDirection(faceIndex?: number): Vector3;
  69007. /**
  69008. * Gets the minZ used for shadow according to both the scene and the light.
  69009. * @param activeCamera The camera we are returning the min for
  69010. * @returns the depth min z
  69011. */
  69012. getDepthMinZ(activeCamera: Camera): number;
  69013. /**
  69014. * Gets the maxZ used for shadow according to both the scene and the light.
  69015. * @param activeCamera The camera we are returning the max for
  69016. * @returns the depth max z
  69017. */
  69018. getDepthMaxZ(activeCamera: Camera): number;
  69019. }
  69020. /**
  69021. * Base implementation IShadowLight
  69022. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69023. */
  69024. export abstract class ShadowLight extends Light implements IShadowLight {
  69025. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69026. protected _position: Vector3;
  69027. protected _setPosition(value: Vector3): void;
  69028. /**
  69029. * Sets the position the shadow will be casted from. Also use as the light position for both
  69030. * point and spot lights.
  69031. */
  69032. /**
  69033. * Sets the position the shadow will be casted from. Also use as the light position for both
  69034. * point and spot lights.
  69035. */
  69036. position: Vector3;
  69037. protected _direction: Vector3;
  69038. protected _setDirection(value: Vector3): void;
  69039. /**
  69040. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69041. * Also use as the light direction on spot and directional lights.
  69042. */
  69043. /**
  69044. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69045. * Also use as the light direction on spot and directional lights.
  69046. */
  69047. direction: Vector3;
  69048. private _shadowMinZ;
  69049. /**
  69050. * Gets the shadow projection clipping minimum z value.
  69051. */
  69052. /**
  69053. * Sets the shadow projection clipping minimum z value.
  69054. */
  69055. shadowMinZ: number;
  69056. private _shadowMaxZ;
  69057. /**
  69058. * Sets the shadow projection clipping maximum z value.
  69059. */
  69060. /**
  69061. * Gets the shadow projection clipping maximum z value.
  69062. */
  69063. shadowMaxZ: number;
  69064. /**
  69065. * Callback defining a custom Projection Matrix Builder.
  69066. * This can be used to override the default projection matrix computation.
  69067. */
  69068. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69069. /**
  69070. * The transformed position. Position of the light in world space taking parenting in account.
  69071. */
  69072. transformedPosition: Vector3;
  69073. /**
  69074. * The transformed direction. Direction of the light in world space taking parenting in account.
  69075. */
  69076. transformedDirection: Vector3;
  69077. private _needProjectionMatrixCompute;
  69078. /**
  69079. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69080. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69081. */
  69082. computeTransformedInformation(): boolean;
  69083. /**
  69084. * Return the depth scale used for the shadow map.
  69085. * @returns the depth scale.
  69086. */
  69087. getDepthScale(): number;
  69088. /**
  69089. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69090. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69091. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69092. */
  69093. getShadowDirection(faceIndex?: number): Vector3;
  69094. /**
  69095. * Returns the ShadowLight absolute position in the World.
  69096. * @returns the position vector in world space
  69097. */
  69098. getAbsolutePosition(): Vector3;
  69099. /**
  69100. * Sets the ShadowLight direction toward the passed target.
  69101. * @param target The point to target in local space
  69102. * @returns the updated ShadowLight direction
  69103. */
  69104. setDirectionToTarget(target: Vector3): Vector3;
  69105. /**
  69106. * Returns the light rotation in euler definition.
  69107. * @returns the x y z rotation in local space.
  69108. */
  69109. getRotation(): Vector3;
  69110. /**
  69111. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69112. * @returns true if a cube texture needs to be use
  69113. */
  69114. needCube(): boolean;
  69115. /**
  69116. * Detects if the projection matrix requires to be recomputed this frame.
  69117. * @returns true if it requires to be recomputed otherwise, false.
  69118. */
  69119. needProjectionMatrixCompute(): boolean;
  69120. /**
  69121. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69122. */
  69123. forceProjectionMatrixCompute(): void;
  69124. /** @hidden */
  69125. _initCache(): void;
  69126. /** @hidden */
  69127. _isSynchronized(): boolean;
  69128. /**
  69129. * Computes the world matrix of the node
  69130. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69131. * @returns the world matrix
  69132. */
  69133. computeWorldMatrix(force?: boolean): Matrix;
  69134. /**
  69135. * Gets the minZ used for shadow according to both the scene and the light.
  69136. * @param activeCamera The camera we are returning the min for
  69137. * @returns the depth min z
  69138. */
  69139. getDepthMinZ(activeCamera: Camera): number;
  69140. /**
  69141. * Gets the maxZ used for shadow according to both the scene and the light.
  69142. * @param activeCamera The camera we are returning the max for
  69143. * @returns the depth max z
  69144. */
  69145. getDepthMaxZ(activeCamera: Camera): number;
  69146. /**
  69147. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69148. * @param matrix The materix to updated with the projection information
  69149. * @param viewMatrix The transform matrix of the light
  69150. * @param renderList The list of mesh to render in the map
  69151. * @returns The current light
  69152. */
  69153. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69154. }
  69155. }
  69156. declare module BABYLON {
  69157. /**
  69158. * "Static Class" containing the most commonly used helper while dealing with material for
  69159. * rendering purpose.
  69160. *
  69161. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69162. *
  69163. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69164. */
  69165. export class MaterialHelper {
  69166. /**
  69167. * Bind the current view position to an effect.
  69168. * @param effect The effect to be bound
  69169. * @param scene The scene the eyes position is used from
  69170. */
  69171. static BindEyePosition(effect: Effect, scene: Scene): void;
  69172. /**
  69173. * Helps preparing the defines values about the UVs in used in the effect.
  69174. * UVs are shared as much as we can accross channels in the shaders.
  69175. * @param texture The texture we are preparing the UVs for
  69176. * @param defines The defines to update
  69177. * @param key The channel key "diffuse", "specular"... used in the shader
  69178. */
  69179. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69180. /**
  69181. * Binds a texture matrix value to its corrsponding uniform
  69182. * @param texture The texture to bind the matrix for
  69183. * @param uniformBuffer The uniform buffer receivin the data
  69184. * @param key The channel key "diffuse", "specular"... used in the shader
  69185. */
  69186. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69187. /**
  69188. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69189. * @param mesh defines the current mesh
  69190. * @param scene defines the current scene
  69191. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69192. * @param pointsCloud defines if point cloud rendering has to be turned on
  69193. * @param fogEnabled defines if fog has to be turned on
  69194. * @param alphaTest defines if alpha testing has to be turned on
  69195. * @param defines defines the current list of defines
  69196. */
  69197. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69198. /**
  69199. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69200. * @param scene defines the current scene
  69201. * @param engine defines the current engine
  69202. * @param defines specifies the list of active defines
  69203. * @param useInstances defines if instances have to be turned on
  69204. * @param useClipPlane defines if clip plane have to be turned on
  69205. */
  69206. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69207. /**
  69208. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69209. * @param mesh The mesh containing the geometry data we will draw
  69210. * @param defines The defines to update
  69211. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69212. * @param useBones Precise whether bones should be used or not (override mesh info)
  69213. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69214. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69215. * @returns false if defines are considered not dirty and have not been checked
  69216. */
  69217. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69218. /**
  69219. * Prepares the defines related to multiview
  69220. * @param scene The scene we are intending to draw
  69221. * @param defines The defines to update
  69222. */
  69223. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69224. /**
  69225. * Prepares the defines related to the light information passed in parameter
  69226. * @param scene The scene we are intending to draw
  69227. * @param mesh The mesh the effect is compiling for
  69228. * @param defines The defines to update
  69229. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69230. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69231. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69232. * @returns true if normals will be required for the rest of the effect
  69233. */
  69234. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69235. /**
  69236. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69237. * that won t be acctive due to defines being turned off.
  69238. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69239. * @param samplersList The samplers list
  69240. * @param defines The defines helping in the list generation
  69241. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69242. */
  69243. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69244. /**
  69245. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69246. * @param defines The defines to update while falling back
  69247. * @param fallbacks The authorized effect fallbacks
  69248. * @param maxSimultaneousLights The maximum number of lights allowed
  69249. * @param rank the current rank of the Effect
  69250. * @returns The newly affected rank
  69251. */
  69252. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69253. /**
  69254. * Prepares the list of attributes required for morph targets according to the effect defines.
  69255. * @param attribs The current list of supported attribs
  69256. * @param mesh The mesh to prepare the morph targets attributes for
  69257. * @param defines The current Defines of the effect
  69258. */
  69259. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69260. /**
  69261. * Prepares the list of attributes required for bones according to the effect defines.
  69262. * @param attribs The current list of supported attribs
  69263. * @param mesh The mesh to prepare the bones attributes for
  69264. * @param defines The current Defines of the effect
  69265. * @param fallbacks The current efffect fallback strategy
  69266. */
  69267. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69268. /**
  69269. * Prepares the list of attributes required for instances according to the effect defines.
  69270. * @param attribs The current list of supported attribs
  69271. * @param defines The current Defines of the effect
  69272. */
  69273. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69274. /**
  69275. * Binds the light shadow information to the effect for the given mesh.
  69276. * @param light The light containing the generator
  69277. * @param scene The scene the lights belongs to
  69278. * @param mesh The mesh we are binding the information to render
  69279. * @param lightIndex The light index in the effect used to render the mesh
  69280. * @param effect The effect we are binding the data to
  69281. */
  69282. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69283. /**
  69284. * Binds the light information to the effect.
  69285. * @param light The light containing the generator
  69286. * @param effect The effect we are binding the data to
  69287. * @param lightIndex The light index in the effect used to render
  69288. */
  69289. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69290. /**
  69291. * Binds the lights information from the scene to the effect for the given mesh.
  69292. * @param scene The scene the lights belongs to
  69293. * @param mesh The mesh we are binding the information to render
  69294. * @param effect The effect we are binding the data to
  69295. * @param defines The generated defines for the effect
  69296. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69297. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69298. */
  69299. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69300. private static _tempFogColor;
  69301. /**
  69302. * Binds the fog information from the scene to the effect for the given mesh.
  69303. * @param scene The scene the lights belongs to
  69304. * @param mesh The mesh we are binding the information to render
  69305. * @param effect The effect we are binding the data to
  69306. * @param linearSpace Defines if the fog effect is applied in linear space
  69307. */
  69308. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69309. /**
  69310. * Binds the bones information from the mesh to the effect.
  69311. * @param mesh The mesh we are binding the information to render
  69312. * @param effect The effect we are binding the data to
  69313. */
  69314. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69315. /**
  69316. * Binds the morph targets information from the mesh to the effect.
  69317. * @param abstractMesh The mesh we are binding the information to render
  69318. * @param effect The effect we are binding the data to
  69319. */
  69320. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69321. /**
  69322. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69323. * @param defines The generated defines used in the effect
  69324. * @param effect The effect we are binding the data to
  69325. * @param scene The scene we are willing to render with logarithmic scale for
  69326. */
  69327. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69328. /**
  69329. * Binds the clip plane information from the scene to the effect.
  69330. * @param scene The scene the clip plane information are extracted from
  69331. * @param effect The effect we are binding the data to
  69332. */
  69333. static BindClipPlane(effect: Effect, scene: Scene): void;
  69334. }
  69335. }
  69336. declare module BABYLON {
  69337. /** @hidden */
  69338. export var kernelBlurVaryingDeclaration: {
  69339. name: string;
  69340. shader: string;
  69341. };
  69342. }
  69343. declare module BABYLON {
  69344. /** @hidden */
  69345. export var kernelBlurFragment: {
  69346. name: string;
  69347. shader: string;
  69348. };
  69349. }
  69350. declare module BABYLON {
  69351. /** @hidden */
  69352. export var kernelBlurFragment2: {
  69353. name: string;
  69354. shader: string;
  69355. };
  69356. }
  69357. declare module BABYLON {
  69358. /** @hidden */
  69359. export var kernelBlurPixelShader: {
  69360. name: string;
  69361. shader: string;
  69362. };
  69363. }
  69364. declare module BABYLON {
  69365. /** @hidden */
  69366. export var kernelBlurVertex: {
  69367. name: string;
  69368. shader: string;
  69369. };
  69370. }
  69371. declare module BABYLON {
  69372. /** @hidden */
  69373. export var kernelBlurVertexShader: {
  69374. name: string;
  69375. shader: string;
  69376. };
  69377. }
  69378. declare module BABYLON {
  69379. /**
  69380. * The Blur Post Process which blurs an image based on a kernel and direction.
  69381. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69382. */
  69383. export class BlurPostProcess extends PostProcess {
  69384. /** The direction in which to blur the image. */
  69385. direction: Vector2;
  69386. private blockCompilation;
  69387. protected _kernel: number;
  69388. protected _idealKernel: number;
  69389. protected _packedFloat: boolean;
  69390. private _staticDefines;
  69391. /**
  69392. * Sets the length in pixels of the blur sample region
  69393. */
  69394. /**
  69395. * Gets the length in pixels of the blur sample region
  69396. */
  69397. kernel: number;
  69398. /**
  69399. * Sets wether or not the blur needs to unpack/repack floats
  69400. */
  69401. /**
  69402. * Gets wether or not the blur is unpacking/repacking floats
  69403. */
  69404. packedFloat: boolean;
  69405. /**
  69406. * Creates a new instance BlurPostProcess
  69407. * @param name The name of the effect.
  69408. * @param direction The direction in which to blur the image.
  69409. * @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.
  69410. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69411. * @param camera The camera to apply the render pass to.
  69412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69413. * @param engine The engine which the post process will be applied. (default: current engine)
  69414. * @param reusable If the post process can be reused on the same frame. (default: false)
  69415. * @param textureType Type of textures used when performing the post process. (default: 0)
  69416. * @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)
  69417. */
  69418. constructor(name: string,
  69419. /** The direction in which to blur the image. */
  69420. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69421. /**
  69422. * Updates the effect with the current post process compile time values and recompiles the shader.
  69423. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69424. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69425. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69426. * @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
  69427. * @param onCompiled Called when the shader has been compiled.
  69428. * @param onError Called if there is an error when compiling a shader.
  69429. */
  69430. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69431. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69432. /**
  69433. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69434. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69435. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69436. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69437. * The gaps between physical kernels are compensated for in the weighting of the samples
  69438. * @param idealKernel Ideal blur kernel.
  69439. * @return Nearest best kernel.
  69440. */
  69441. protected _nearestBestKernel(idealKernel: number): number;
  69442. /**
  69443. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69444. * @param x The point on the Gaussian distribution to sample.
  69445. * @return the value of the Gaussian function at x.
  69446. */
  69447. protected _gaussianWeight(x: number): number;
  69448. /**
  69449. * Generates a string that can be used as a floating point number in GLSL.
  69450. * @param x Value to print.
  69451. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69452. * @return GLSL float string.
  69453. */
  69454. protected _glslFloat(x: number, decimalFigures?: number): string;
  69455. }
  69456. }
  69457. declare module BABYLON {
  69458. /** @hidden */
  69459. export var shadowMapPixelShader: {
  69460. name: string;
  69461. shader: string;
  69462. };
  69463. }
  69464. declare module BABYLON {
  69465. /** @hidden */
  69466. export var bonesDeclaration: {
  69467. name: string;
  69468. shader: string;
  69469. };
  69470. }
  69471. declare module BABYLON {
  69472. /** @hidden */
  69473. export var morphTargetsVertexGlobalDeclaration: {
  69474. name: string;
  69475. shader: string;
  69476. };
  69477. }
  69478. declare module BABYLON {
  69479. /** @hidden */
  69480. export var morphTargetsVertexDeclaration: {
  69481. name: string;
  69482. shader: string;
  69483. };
  69484. }
  69485. declare module BABYLON {
  69486. /** @hidden */
  69487. export var instancesDeclaration: {
  69488. name: string;
  69489. shader: string;
  69490. };
  69491. }
  69492. declare module BABYLON {
  69493. /** @hidden */
  69494. export var helperFunctions: {
  69495. name: string;
  69496. shader: string;
  69497. };
  69498. }
  69499. declare module BABYLON {
  69500. /** @hidden */
  69501. export var morphTargetsVertex: {
  69502. name: string;
  69503. shader: string;
  69504. };
  69505. }
  69506. declare module BABYLON {
  69507. /** @hidden */
  69508. export var instancesVertex: {
  69509. name: string;
  69510. shader: string;
  69511. };
  69512. }
  69513. declare module BABYLON {
  69514. /** @hidden */
  69515. export var bonesVertex: {
  69516. name: string;
  69517. shader: string;
  69518. };
  69519. }
  69520. declare module BABYLON {
  69521. /** @hidden */
  69522. export var shadowMapVertexShader: {
  69523. name: string;
  69524. shader: string;
  69525. };
  69526. }
  69527. declare module BABYLON {
  69528. /** @hidden */
  69529. export var depthBoxBlurPixelShader: {
  69530. name: string;
  69531. shader: string;
  69532. };
  69533. }
  69534. declare module BABYLON {
  69535. /**
  69536. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69537. */
  69538. export interface ICustomShaderOptions {
  69539. /**
  69540. * Gets or sets the custom shader name to use
  69541. */
  69542. shaderName: string;
  69543. /**
  69544. * The list of attribute names used in the shader
  69545. */
  69546. attributes?: string[];
  69547. /**
  69548. * The list of unifrom names used in the shader
  69549. */
  69550. uniforms?: string[];
  69551. /**
  69552. * The list of sampler names used in the shader
  69553. */
  69554. samplers?: string[];
  69555. /**
  69556. * The list of defines used in the shader
  69557. */
  69558. defines?: string[];
  69559. }
  69560. /**
  69561. * Interface to implement to create a shadow generator compatible with BJS.
  69562. */
  69563. export interface IShadowGenerator {
  69564. /**
  69565. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69566. * @returns The render target texture if present otherwise, null
  69567. */
  69568. getShadowMap(): Nullable<RenderTargetTexture>;
  69569. /**
  69570. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69571. * @returns The render target texture if the shadow map is present otherwise, null
  69572. */
  69573. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69574. /**
  69575. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69576. * @param subMesh The submesh we want to render in the shadow map
  69577. * @param useInstances Defines wether will draw in the map using instances
  69578. * @returns true if ready otherwise, false
  69579. */
  69580. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69581. /**
  69582. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69583. * @param defines Defines of the material we want to update
  69584. * @param lightIndex Index of the light in the enabled light list of the material
  69585. */
  69586. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69587. /**
  69588. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69589. * defined in the generator but impacting the effect).
  69590. * It implies the unifroms available on the materials are the standard BJS ones.
  69591. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69592. * @param effect The effect we are binfing the information for
  69593. */
  69594. bindShadowLight(lightIndex: string, effect: Effect): void;
  69595. /**
  69596. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69597. * (eq to shadow prjection matrix * light transform matrix)
  69598. * @returns The transform matrix used to create the shadow map
  69599. */
  69600. getTransformMatrix(): Matrix;
  69601. /**
  69602. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69603. * Cube and 2D textures for instance.
  69604. */
  69605. recreateShadowMap(): void;
  69606. /**
  69607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69608. * @param onCompiled Callback triggered at the and of the effects compilation
  69609. * @param options Sets of optional options forcing the compilation with different modes
  69610. */
  69611. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69612. useInstances: boolean;
  69613. }>): void;
  69614. /**
  69615. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69616. * @param options Sets of optional options forcing the compilation with different modes
  69617. * @returns A promise that resolves when the compilation completes
  69618. */
  69619. forceCompilationAsync(options?: Partial<{
  69620. useInstances: boolean;
  69621. }>): Promise<void>;
  69622. /**
  69623. * Serializes the shadow generator setup to a json object.
  69624. * @returns The serialized JSON object
  69625. */
  69626. serialize(): any;
  69627. /**
  69628. * Disposes the Shadow map and related Textures and effects.
  69629. */
  69630. dispose(): void;
  69631. }
  69632. /**
  69633. * Default implementation IShadowGenerator.
  69634. * This is the main object responsible of generating shadows in the framework.
  69635. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69636. */
  69637. export class ShadowGenerator implements IShadowGenerator {
  69638. /**
  69639. * Shadow generator mode None: no filtering applied.
  69640. */
  69641. static readonly FILTER_NONE: number;
  69642. /**
  69643. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69644. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69645. */
  69646. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69647. /**
  69648. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69649. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69650. */
  69651. static readonly FILTER_POISSONSAMPLING: number;
  69652. /**
  69653. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69654. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69655. */
  69656. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69657. /**
  69658. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69659. * edge artifacts on steep falloff.
  69660. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69661. */
  69662. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69663. /**
  69664. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69665. * edge artifacts on steep falloff.
  69666. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69667. */
  69668. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69669. /**
  69670. * Shadow generator mode PCF: Percentage Closer Filtering
  69671. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69672. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69673. */
  69674. static readonly FILTER_PCF: number;
  69675. /**
  69676. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69677. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69678. * Contact Hardening
  69679. */
  69680. static readonly FILTER_PCSS: number;
  69681. /**
  69682. * Reserved for PCF and PCSS
  69683. * Highest Quality.
  69684. *
  69685. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69686. *
  69687. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69688. */
  69689. static readonly QUALITY_HIGH: number;
  69690. /**
  69691. * Reserved for PCF and PCSS
  69692. * Good tradeoff for quality/perf cross devices
  69693. *
  69694. * Execute PCF on a 3*3 kernel.
  69695. *
  69696. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69697. */
  69698. static readonly QUALITY_MEDIUM: number;
  69699. /**
  69700. * Reserved for PCF and PCSS
  69701. * The lowest quality but the fastest.
  69702. *
  69703. * Execute PCF on a 1*1 kernel.
  69704. *
  69705. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69706. */
  69707. static readonly QUALITY_LOW: number;
  69708. /** Gets or sets the custom shader name to use */
  69709. customShaderOptions: ICustomShaderOptions;
  69710. /**
  69711. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69712. */
  69713. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69714. /**
  69715. * Observable triggered before a mesh is rendered in the shadow map.
  69716. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69717. */
  69718. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69719. private _bias;
  69720. /**
  69721. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69722. */
  69723. /**
  69724. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69725. */
  69726. bias: number;
  69727. private _normalBias;
  69728. /**
  69729. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69730. */
  69731. /**
  69732. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69733. */
  69734. normalBias: number;
  69735. private _blurBoxOffset;
  69736. /**
  69737. * Gets the blur box offset: offset applied during the blur pass.
  69738. * Only useful if useKernelBlur = false
  69739. */
  69740. /**
  69741. * Sets the blur box offset: offset applied during the blur pass.
  69742. * Only useful if useKernelBlur = false
  69743. */
  69744. blurBoxOffset: number;
  69745. private _blurScale;
  69746. /**
  69747. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69748. * 2 means half of the size.
  69749. */
  69750. /**
  69751. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69752. * 2 means half of the size.
  69753. */
  69754. blurScale: number;
  69755. private _blurKernel;
  69756. /**
  69757. * Gets the blur kernel: kernel size of the blur pass.
  69758. * Only useful if useKernelBlur = true
  69759. */
  69760. /**
  69761. * Sets the blur kernel: kernel size of the blur pass.
  69762. * Only useful if useKernelBlur = true
  69763. */
  69764. blurKernel: number;
  69765. private _useKernelBlur;
  69766. /**
  69767. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69768. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69769. */
  69770. /**
  69771. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69772. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69773. */
  69774. useKernelBlur: boolean;
  69775. private _depthScale;
  69776. /**
  69777. * Gets the depth scale used in ESM mode.
  69778. */
  69779. /**
  69780. * Sets the depth scale used in ESM mode.
  69781. * This can override the scale stored on the light.
  69782. */
  69783. depthScale: number;
  69784. private _filter;
  69785. /**
  69786. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69787. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69788. */
  69789. /**
  69790. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69791. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69792. */
  69793. filter: number;
  69794. /**
  69795. * Gets if the current filter is set to Poisson Sampling.
  69796. */
  69797. /**
  69798. * Sets the current filter to Poisson Sampling.
  69799. */
  69800. usePoissonSampling: boolean;
  69801. /**
  69802. * Gets if the current filter is set to ESM.
  69803. */
  69804. /**
  69805. * Sets the current filter is to ESM.
  69806. */
  69807. useExponentialShadowMap: boolean;
  69808. /**
  69809. * Gets if the current filter is set to filtered ESM.
  69810. */
  69811. /**
  69812. * Gets if the current filter is set to filtered ESM.
  69813. */
  69814. useBlurExponentialShadowMap: boolean;
  69815. /**
  69816. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69817. * exponential to prevent steep falloff artifacts).
  69818. */
  69819. /**
  69820. * Sets the current filter to "close ESM" (using the inverse of the
  69821. * exponential to prevent steep falloff artifacts).
  69822. */
  69823. useCloseExponentialShadowMap: boolean;
  69824. /**
  69825. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69826. * exponential to prevent steep falloff artifacts).
  69827. */
  69828. /**
  69829. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69830. * exponential to prevent steep falloff artifacts).
  69831. */
  69832. useBlurCloseExponentialShadowMap: boolean;
  69833. /**
  69834. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69835. */
  69836. /**
  69837. * Sets the current filter to "PCF" (percentage closer filtering).
  69838. */
  69839. usePercentageCloserFiltering: boolean;
  69840. private _filteringQuality;
  69841. /**
  69842. * Gets the PCF or PCSS Quality.
  69843. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69844. */
  69845. /**
  69846. * Sets the PCF or PCSS Quality.
  69847. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69848. */
  69849. filteringQuality: number;
  69850. /**
  69851. * Gets if the current filter is set to "PCSS" (contact hardening).
  69852. */
  69853. /**
  69854. * Sets the current filter to "PCSS" (contact hardening).
  69855. */
  69856. useContactHardeningShadow: boolean;
  69857. private _contactHardeningLightSizeUVRatio;
  69858. /**
  69859. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69860. * Using a ratio helps keeping shape stability independently of the map size.
  69861. *
  69862. * It does not account for the light projection as it was having too much
  69863. * instability during the light setup or during light position changes.
  69864. *
  69865. * Only valid if useContactHardeningShadow is true.
  69866. */
  69867. /**
  69868. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69869. * Using a ratio helps keeping shape stability independently of the map size.
  69870. *
  69871. * It does not account for the light projection as it was having too much
  69872. * instability during the light setup or during light position changes.
  69873. *
  69874. * Only valid if useContactHardeningShadow is true.
  69875. */
  69876. contactHardeningLightSizeUVRatio: number;
  69877. private _darkness;
  69878. /**
  69879. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69880. * 0 means strongest and 1 would means no shadow.
  69881. * @returns the darkness.
  69882. */
  69883. getDarkness(): number;
  69884. /**
  69885. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69886. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69887. * @returns the shadow generator allowing fluent coding.
  69888. */
  69889. setDarkness(darkness: number): ShadowGenerator;
  69890. private _transparencyShadow;
  69891. /**
  69892. * Sets the ability to have transparent shadow (boolean).
  69893. * @param transparent True if transparent else False
  69894. * @returns the shadow generator allowing fluent coding
  69895. */
  69896. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69897. private _shadowMap;
  69898. private _shadowMap2;
  69899. /**
  69900. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69901. * @returns The render target texture if present otherwise, null
  69902. */
  69903. getShadowMap(): Nullable<RenderTargetTexture>;
  69904. /**
  69905. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69906. * @returns The render target texture if the shadow map is present otherwise, null
  69907. */
  69908. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69909. /**
  69910. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69911. * @param mesh Mesh to add
  69912. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69913. * @returns the Shadow Generator itself
  69914. */
  69915. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69916. /**
  69917. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69918. * @param mesh Mesh to remove
  69919. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69920. * @returns the Shadow Generator itself
  69921. */
  69922. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69923. /**
  69924. * Controls the extent to which the shadows fade out at the edge of the frustum
  69925. * Used only by directionals and spots
  69926. */
  69927. frustumEdgeFalloff: number;
  69928. private _light;
  69929. /**
  69930. * Returns the associated light object.
  69931. * @returns the light generating the shadow
  69932. */
  69933. getLight(): IShadowLight;
  69934. /**
  69935. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69936. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69937. * It might on the other hand introduce peter panning.
  69938. */
  69939. forceBackFacesOnly: boolean;
  69940. private _scene;
  69941. private _lightDirection;
  69942. private _effect;
  69943. private _viewMatrix;
  69944. private _projectionMatrix;
  69945. private _transformMatrix;
  69946. private _cachedPosition;
  69947. private _cachedDirection;
  69948. private _cachedDefines;
  69949. private _currentRenderID;
  69950. private _boxBlurPostprocess;
  69951. private _kernelBlurXPostprocess;
  69952. private _kernelBlurYPostprocess;
  69953. private _blurPostProcesses;
  69954. private _mapSize;
  69955. private _currentFaceIndex;
  69956. private _currentFaceIndexCache;
  69957. private _textureType;
  69958. private _defaultTextureMatrix;
  69959. /** @hidden */
  69960. static _SceneComponentInitialization: (scene: Scene) => void;
  69961. /**
  69962. * Creates a ShadowGenerator object.
  69963. * A ShadowGenerator is the required tool to use the shadows.
  69964. * Each light casting shadows needs to use its own ShadowGenerator.
  69965. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69966. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69967. * @param light The light object generating the shadows.
  69968. * @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.
  69969. */
  69970. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69971. private _initializeGenerator;
  69972. private _initializeShadowMap;
  69973. private _initializeBlurRTTAndPostProcesses;
  69974. private _renderForShadowMap;
  69975. private _renderSubMeshForShadowMap;
  69976. private _applyFilterValues;
  69977. /**
  69978. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69979. * @param onCompiled Callback triggered at the and of the effects compilation
  69980. * @param options Sets of optional options forcing the compilation with different modes
  69981. */
  69982. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69983. useInstances: boolean;
  69984. }>): void;
  69985. /**
  69986. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69987. * @param options Sets of optional options forcing the compilation with different modes
  69988. * @returns A promise that resolves when the compilation completes
  69989. */
  69990. forceCompilationAsync(options?: Partial<{
  69991. useInstances: boolean;
  69992. }>): Promise<void>;
  69993. /**
  69994. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69995. * @param subMesh The submesh we want to render in the shadow map
  69996. * @param useInstances Defines wether will draw in the map using instances
  69997. * @returns true if ready otherwise, false
  69998. */
  69999. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70000. /**
  70001. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70002. * @param defines Defines of the material we want to update
  70003. * @param lightIndex Index of the light in the enabled light list of the material
  70004. */
  70005. prepareDefines(defines: any, lightIndex: number): void;
  70006. /**
  70007. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70008. * defined in the generator but impacting the effect).
  70009. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70010. * @param effect The effect we are binfing the information for
  70011. */
  70012. bindShadowLight(lightIndex: string, effect: Effect): void;
  70013. /**
  70014. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70015. * (eq to shadow prjection matrix * light transform matrix)
  70016. * @returns The transform matrix used to create the shadow map
  70017. */
  70018. getTransformMatrix(): Matrix;
  70019. /**
  70020. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70021. * Cube and 2D textures for instance.
  70022. */
  70023. recreateShadowMap(): void;
  70024. private _disposeBlurPostProcesses;
  70025. private _disposeRTTandPostProcesses;
  70026. /**
  70027. * Disposes the ShadowGenerator.
  70028. * Returns nothing.
  70029. */
  70030. dispose(): void;
  70031. /**
  70032. * Serializes the shadow generator setup to a json object.
  70033. * @returns The serialized JSON object
  70034. */
  70035. serialize(): any;
  70036. /**
  70037. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70038. * @param parsedShadowGenerator The JSON object to parse
  70039. * @param scene The scene to create the shadow map for
  70040. * @returns The parsed shadow generator
  70041. */
  70042. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70043. }
  70044. }
  70045. declare module BABYLON {
  70046. /**
  70047. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70048. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70049. * 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.
  70050. */
  70051. export abstract class Light extends Node {
  70052. /**
  70053. * Falloff Default: light is falling off following the material specification:
  70054. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70055. */
  70056. static readonly FALLOFF_DEFAULT: number;
  70057. /**
  70058. * Falloff Physical: light is falling off following the inverse squared distance law.
  70059. */
  70060. static readonly FALLOFF_PHYSICAL: number;
  70061. /**
  70062. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70063. * to enhance interoperability with other engines.
  70064. */
  70065. static readonly FALLOFF_GLTF: number;
  70066. /**
  70067. * Falloff Standard: light is falling off like in the standard material
  70068. * to enhance interoperability with other materials.
  70069. */
  70070. static readonly FALLOFF_STANDARD: number;
  70071. /**
  70072. * If every light affecting the material is in this lightmapMode,
  70073. * material.lightmapTexture adds or multiplies
  70074. * (depends on material.useLightmapAsShadowmap)
  70075. * after every other light calculations.
  70076. */
  70077. static readonly LIGHTMAP_DEFAULT: number;
  70078. /**
  70079. * material.lightmapTexture as only diffuse lighting from this light
  70080. * adds only specular lighting from this light
  70081. * adds dynamic shadows
  70082. */
  70083. static readonly LIGHTMAP_SPECULAR: number;
  70084. /**
  70085. * material.lightmapTexture as only lighting
  70086. * no light calculation from this light
  70087. * only adds dynamic shadows from this light
  70088. */
  70089. static readonly LIGHTMAP_SHADOWSONLY: number;
  70090. /**
  70091. * Each light type uses the default quantity according to its type:
  70092. * point/spot lights use luminous intensity
  70093. * directional lights use illuminance
  70094. */
  70095. static readonly INTENSITYMODE_AUTOMATIC: number;
  70096. /**
  70097. * lumen (lm)
  70098. */
  70099. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70100. /**
  70101. * candela (lm/sr)
  70102. */
  70103. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70104. /**
  70105. * lux (lm/m^2)
  70106. */
  70107. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70108. /**
  70109. * nit (cd/m^2)
  70110. */
  70111. static readonly INTENSITYMODE_LUMINANCE: number;
  70112. /**
  70113. * Light type const id of the point light.
  70114. */
  70115. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70116. /**
  70117. * Light type const id of the directional light.
  70118. */
  70119. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70120. /**
  70121. * Light type const id of the spot light.
  70122. */
  70123. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70124. /**
  70125. * Light type const id of the hemispheric light.
  70126. */
  70127. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70128. /**
  70129. * Diffuse gives the basic color to an object.
  70130. */
  70131. diffuse: Color3;
  70132. /**
  70133. * Specular produces a highlight color on an object.
  70134. * Note: This is note affecting PBR materials.
  70135. */
  70136. specular: Color3;
  70137. /**
  70138. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70139. * falling off base on range or angle.
  70140. * This can be set to any values in Light.FALLOFF_x.
  70141. *
  70142. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70143. * other types of materials.
  70144. */
  70145. falloffType: number;
  70146. /**
  70147. * Strength of the light.
  70148. * Note: By default it is define in the framework own unit.
  70149. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70150. */
  70151. intensity: number;
  70152. private _range;
  70153. protected _inverseSquaredRange: number;
  70154. /**
  70155. * Defines how far from the source the light is impacting in scene units.
  70156. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70157. */
  70158. /**
  70159. * Defines how far from the source the light is impacting in scene units.
  70160. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70161. */
  70162. range: number;
  70163. /**
  70164. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70165. * of light.
  70166. */
  70167. private _photometricScale;
  70168. private _intensityMode;
  70169. /**
  70170. * Gets the photometric scale used to interpret the intensity.
  70171. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70172. */
  70173. /**
  70174. * Sets the photometric scale used to interpret the intensity.
  70175. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70176. */
  70177. intensityMode: number;
  70178. private _radius;
  70179. /**
  70180. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70181. */
  70182. /**
  70183. * sets the light radius used by PBR Materials to simulate soft area lights.
  70184. */
  70185. radius: number;
  70186. private _renderPriority;
  70187. /**
  70188. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70189. * exceeding the number allowed of the materials.
  70190. */
  70191. renderPriority: number;
  70192. private _shadowEnabled;
  70193. /**
  70194. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70195. * the current shadow generator.
  70196. */
  70197. /**
  70198. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70199. * the current shadow generator.
  70200. */
  70201. shadowEnabled: boolean;
  70202. private _includedOnlyMeshes;
  70203. /**
  70204. * Gets the only meshes impacted by this light.
  70205. */
  70206. /**
  70207. * Sets the only meshes impacted by this light.
  70208. */
  70209. includedOnlyMeshes: AbstractMesh[];
  70210. private _excludedMeshes;
  70211. /**
  70212. * Gets the meshes not impacted by this light.
  70213. */
  70214. /**
  70215. * Sets the meshes not impacted by this light.
  70216. */
  70217. excludedMeshes: AbstractMesh[];
  70218. private _excludeWithLayerMask;
  70219. /**
  70220. * Gets the layer id use to find what meshes are not impacted by the light.
  70221. * Inactive if 0
  70222. */
  70223. /**
  70224. * Sets the layer id use to find what meshes are not impacted by the light.
  70225. * Inactive if 0
  70226. */
  70227. excludeWithLayerMask: number;
  70228. private _includeOnlyWithLayerMask;
  70229. /**
  70230. * Gets the layer id use to find what meshes are impacted by the light.
  70231. * Inactive if 0
  70232. */
  70233. /**
  70234. * Sets the layer id use to find what meshes are impacted by the light.
  70235. * Inactive if 0
  70236. */
  70237. includeOnlyWithLayerMask: number;
  70238. private _lightmapMode;
  70239. /**
  70240. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70241. */
  70242. /**
  70243. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70244. */
  70245. lightmapMode: number;
  70246. /**
  70247. * Shadow generator associted to the light.
  70248. * @hidden Internal use only.
  70249. */
  70250. _shadowGenerator: Nullable<IShadowGenerator>;
  70251. /**
  70252. * @hidden Internal use only.
  70253. */
  70254. _excludedMeshesIds: string[];
  70255. /**
  70256. * @hidden Internal use only.
  70257. */
  70258. _includedOnlyMeshesIds: string[];
  70259. /**
  70260. * The current light unifom buffer.
  70261. * @hidden Internal use only.
  70262. */
  70263. _uniformBuffer: UniformBuffer;
  70264. /**
  70265. * Creates a Light object in the scene.
  70266. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70267. * @param name The firendly name of the light
  70268. * @param scene The scene the light belongs too
  70269. */
  70270. constructor(name: string, scene: Scene);
  70271. protected abstract _buildUniformLayout(): void;
  70272. /**
  70273. * Sets the passed Effect "effect" with the Light information.
  70274. * @param effect The effect to update
  70275. * @param lightIndex The index of the light in the effect to update
  70276. * @returns The light
  70277. */
  70278. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70279. /**
  70280. * Returns the string "Light".
  70281. * @returns the class name
  70282. */
  70283. getClassName(): string;
  70284. /** @hidden */
  70285. readonly _isLight: boolean;
  70286. /**
  70287. * Converts the light information to a readable string for debug purpose.
  70288. * @param fullDetails Supports for multiple levels of logging within scene loading
  70289. * @returns the human readable light info
  70290. */
  70291. toString(fullDetails?: boolean): string;
  70292. /** @hidden */
  70293. protected _syncParentEnabledState(): void;
  70294. /**
  70295. * Set the enabled state of this node.
  70296. * @param value - the new enabled state
  70297. */
  70298. setEnabled(value: boolean): void;
  70299. /**
  70300. * Returns the Light associated shadow generator if any.
  70301. * @return the associated shadow generator.
  70302. */
  70303. getShadowGenerator(): Nullable<IShadowGenerator>;
  70304. /**
  70305. * Returns a Vector3, the absolute light position in the World.
  70306. * @returns the world space position of the light
  70307. */
  70308. getAbsolutePosition(): Vector3;
  70309. /**
  70310. * Specifies if the light will affect the passed mesh.
  70311. * @param mesh The mesh to test against the light
  70312. * @return true the mesh is affected otherwise, false.
  70313. */
  70314. canAffectMesh(mesh: AbstractMesh): boolean;
  70315. /**
  70316. * Sort function to order lights for rendering.
  70317. * @param a First Light object to compare to second.
  70318. * @param b Second Light object to compare first.
  70319. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70320. */
  70321. static CompareLightsPriority(a: Light, b: Light): number;
  70322. /**
  70323. * Releases resources associated with this node.
  70324. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70325. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70326. */
  70327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70328. /**
  70329. * Returns the light type ID (integer).
  70330. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70331. */
  70332. getTypeID(): number;
  70333. /**
  70334. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70335. * @returns the scaled intensity in intensity mode unit
  70336. */
  70337. getScaledIntensity(): number;
  70338. /**
  70339. * Returns a new Light object, named "name", from the current one.
  70340. * @param name The name of the cloned light
  70341. * @returns the new created light
  70342. */
  70343. clone(name: string): Nullable<Light>;
  70344. /**
  70345. * Serializes the current light into a Serialization object.
  70346. * @returns the serialized object.
  70347. */
  70348. serialize(): any;
  70349. /**
  70350. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70351. * This new light is named "name" and added to the passed scene.
  70352. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70353. * @param name The friendly name of the light
  70354. * @param scene The scene the new light will belong to
  70355. * @returns the constructor function
  70356. */
  70357. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70358. /**
  70359. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70360. * @param parsedLight The JSON representation of the light
  70361. * @param scene The scene to create the parsed light in
  70362. * @returns the created light after parsing
  70363. */
  70364. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70365. private _hookArrayForExcluded;
  70366. private _hookArrayForIncludedOnly;
  70367. private _resyncMeshes;
  70368. /**
  70369. * Forces the meshes to update their light related information in their rendering used effects
  70370. * @hidden Internal Use Only
  70371. */
  70372. _markMeshesAsLightDirty(): void;
  70373. /**
  70374. * Recomputes the cached photometric scale if needed.
  70375. */
  70376. private _computePhotometricScale;
  70377. /**
  70378. * Returns the Photometric Scale according to the light type and intensity mode.
  70379. */
  70380. private _getPhotometricScale;
  70381. /**
  70382. * Reorder the light in the scene according to their defined priority.
  70383. * @hidden Internal Use Only
  70384. */
  70385. _reorderLightsInScene(): void;
  70386. /**
  70387. * Prepares the list of defines specific to the light type.
  70388. * @param defines the list of defines
  70389. * @param lightIndex defines the index of the light for the effect
  70390. */
  70391. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70392. }
  70393. }
  70394. declare module BABYLON {
  70395. /**
  70396. * Interface used to define Action
  70397. */
  70398. export interface IAction {
  70399. /**
  70400. * Trigger for the action
  70401. */
  70402. trigger: number;
  70403. /** Options of the trigger */
  70404. triggerOptions: any;
  70405. /**
  70406. * Gets the trigger parameters
  70407. * @returns the trigger parameters
  70408. */
  70409. getTriggerParameter(): any;
  70410. /**
  70411. * Internal only - executes current action event
  70412. * @hidden
  70413. */
  70414. _executeCurrent(evt?: ActionEvent): void;
  70415. /**
  70416. * Serialize placeholder for child classes
  70417. * @param parent of child
  70418. * @returns the serialized object
  70419. */
  70420. serialize(parent: any): any;
  70421. /**
  70422. * Internal only
  70423. * @hidden
  70424. */
  70425. _prepare(): void;
  70426. /**
  70427. * Internal only - manager for action
  70428. * @hidden
  70429. */
  70430. _actionManager: AbstractActionManager;
  70431. }
  70432. /**
  70433. * The action to be carried out following a trigger
  70434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70435. */
  70436. export class Action implements IAction {
  70437. /** the trigger, with or without parameters, for the action */
  70438. triggerOptions: any;
  70439. /**
  70440. * Trigger for the action
  70441. */
  70442. trigger: number;
  70443. /**
  70444. * Internal only - manager for action
  70445. * @hidden
  70446. */
  70447. _actionManager: ActionManager;
  70448. private _nextActiveAction;
  70449. private _child;
  70450. private _condition?;
  70451. private _triggerParameter;
  70452. /**
  70453. * An event triggered prior to action being executed.
  70454. */
  70455. onBeforeExecuteObservable: Observable<Action>;
  70456. /**
  70457. * Creates a new Action
  70458. * @param triggerOptions the trigger, with or without parameters, for the action
  70459. * @param condition an optional determinant of action
  70460. */
  70461. constructor(
  70462. /** the trigger, with or without parameters, for the action */
  70463. triggerOptions: any, condition?: Condition);
  70464. /**
  70465. * Internal only
  70466. * @hidden
  70467. */
  70468. _prepare(): void;
  70469. /**
  70470. * Gets the trigger parameters
  70471. * @returns the trigger parameters
  70472. */
  70473. getTriggerParameter(): any;
  70474. /**
  70475. * Internal only - executes current action event
  70476. * @hidden
  70477. */
  70478. _executeCurrent(evt?: ActionEvent): void;
  70479. /**
  70480. * Execute placeholder for child classes
  70481. * @param evt optional action event
  70482. */
  70483. execute(evt?: ActionEvent): void;
  70484. /**
  70485. * Skips to next active action
  70486. */
  70487. skipToNextActiveAction(): void;
  70488. /**
  70489. * Adds action to chain of actions, may be a DoNothingAction
  70490. * @param action defines the next action to execute
  70491. * @returns The action passed in
  70492. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70493. */
  70494. then(action: Action): Action;
  70495. /**
  70496. * Internal only
  70497. * @hidden
  70498. */
  70499. _getProperty(propertyPath: string): string;
  70500. /**
  70501. * Internal only
  70502. * @hidden
  70503. */
  70504. _getEffectiveTarget(target: any, propertyPath: string): any;
  70505. /**
  70506. * Serialize placeholder for child classes
  70507. * @param parent of child
  70508. * @returns the serialized object
  70509. */
  70510. serialize(parent: any): any;
  70511. /**
  70512. * Internal only called by serialize
  70513. * @hidden
  70514. */
  70515. protected _serialize(serializedAction: any, parent?: any): any;
  70516. /**
  70517. * Internal only
  70518. * @hidden
  70519. */
  70520. static _SerializeValueAsString: (value: any) => string;
  70521. /**
  70522. * Internal only
  70523. * @hidden
  70524. */
  70525. static _GetTargetProperty: (target: Scene | Node) => {
  70526. name: string;
  70527. targetType: string;
  70528. value: string;
  70529. };
  70530. }
  70531. }
  70532. declare module BABYLON {
  70533. /**
  70534. * A Condition applied to an Action
  70535. */
  70536. export class Condition {
  70537. /**
  70538. * Internal only - manager for action
  70539. * @hidden
  70540. */
  70541. _actionManager: ActionManager;
  70542. /**
  70543. * Internal only
  70544. * @hidden
  70545. */
  70546. _evaluationId: number;
  70547. /**
  70548. * Internal only
  70549. * @hidden
  70550. */
  70551. _currentResult: boolean;
  70552. /**
  70553. * Creates a new Condition
  70554. * @param actionManager the manager of the action the condition is applied to
  70555. */
  70556. constructor(actionManager: ActionManager);
  70557. /**
  70558. * Check if the current condition is valid
  70559. * @returns a boolean
  70560. */
  70561. isValid(): boolean;
  70562. /**
  70563. * Internal only
  70564. * @hidden
  70565. */
  70566. _getProperty(propertyPath: string): string;
  70567. /**
  70568. * Internal only
  70569. * @hidden
  70570. */
  70571. _getEffectiveTarget(target: any, propertyPath: string): any;
  70572. /**
  70573. * Serialize placeholder for child classes
  70574. * @returns the serialized object
  70575. */
  70576. serialize(): any;
  70577. /**
  70578. * Internal only
  70579. * @hidden
  70580. */
  70581. protected _serialize(serializedCondition: any): any;
  70582. }
  70583. /**
  70584. * Defines specific conditional operators as extensions of Condition
  70585. */
  70586. export class ValueCondition extends Condition {
  70587. /** path to specify the property of the target the conditional operator uses */
  70588. propertyPath: string;
  70589. /** the value compared by the conditional operator against the current value of the property */
  70590. value: any;
  70591. /** the conditional operator, default ValueCondition.IsEqual */
  70592. operator: number;
  70593. /**
  70594. * Internal only
  70595. * @hidden
  70596. */
  70597. private static _IsEqual;
  70598. /**
  70599. * Internal only
  70600. * @hidden
  70601. */
  70602. private static _IsDifferent;
  70603. /**
  70604. * Internal only
  70605. * @hidden
  70606. */
  70607. private static _IsGreater;
  70608. /**
  70609. * Internal only
  70610. * @hidden
  70611. */
  70612. private static _IsLesser;
  70613. /**
  70614. * returns the number for IsEqual
  70615. */
  70616. static readonly IsEqual: number;
  70617. /**
  70618. * Returns the number for IsDifferent
  70619. */
  70620. static readonly IsDifferent: number;
  70621. /**
  70622. * Returns the number for IsGreater
  70623. */
  70624. static readonly IsGreater: number;
  70625. /**
  70626. * Returns the number for IsLesser
  70627. */
  70628. static readonly IsLesser: number;
  70629. /**
  70630. * Internal only The action manager for the condition
  70631. * @hidden
  70632. */
  70633. _actionManager: ActionManager;
  70634. /**
  70635. * Internal only
  70636. * @hidden
  70637. */
  70638. private _target;
  70639. /**
  70640. * Internal only
  70641. * @hidden
  70642. */
  70643. private _effectiveTarget;
  70644. /**
  70645. * Internal only
  70646. * @hidden
  70647. */
  70648. private _property;
  70649. /**
  70650. * Creates a new ValueCondition
  70651. * @param actionManager manager for the action the condition applies to
  70652. * @param target for the action
  70653. * @param propertyPath path to specify the property of the target the conditional operator uses
  70654. * @param value the value compared by the conditional operator against the current value of the property
  70655. * @param operator the conditional operator, default ValueCondition.IsEqual
  70656. */
  70657. constructor(actionManager: ActionManager, target: any,
  70658. /** path to specify the property of the target the conditional operator uses */
  70659. propertyPath: string,
  70660. /** the value compared by the conditional operator against the current value of the property */
  70661. value: any,
  70662. /** the conditional operator, default ValueCondition.IsEqual */
  70663. operator?: number);
  70664. /**
  70665. * Compares the given value with the property value for the specified conditional operator
  70666. * @returns the result of the comparison
  70667. */
  70668. isValid(): boolean;
  70669. /**
  70670. * Serialize the ValueCondition into a JSON compatible object
  70671. * @returns serialization object
  70672. */
  70673. serialize(): any;
  70674. /**
  70675. * Gets the name of the conditional operator for the ValueCondition
  70676. * @param operator the conditional operator
  70677. * @returns the name
  70678. */
  70679. static GetOperatorName(operator: number): string;
  70680. }
  70681. /**
  70682. * Defines a predicate condition as an extension of Condition
  70683. */
  70684. export class PredicateCondition extends Condition {
  70685. /** defines the predicate function used to validate the condition */
  70686. predicate: () => boolean;
  70687. /**
  70688. * Internal only - manager for action
  70689. * @hidden
  70690. */
  70691. _actionManager: ActionManager;
  70692. /**
  70693. * Creates a new PredicateCondition
  70694. * @param actionManager manager for the action the condition applies to
  70695. * @param predicate defines the predicate function used to validate the condition
  70696. */
  70697. constructor(actionManager: ActionManager,
  70698. /** defines the predicate function used to validate the condition */
  70699. predicate: () => boolean);
  70700. /**
  70701. * @returns the validity of the predicate condition
  70702. */
  70703. isValid(): boolean;
  70704. }
  70705. /**
  70706. * Defines a state condition as an extension of Condition
  70707. */
  70708. export class StateCondition extends Condition {
  70709. /** Value to compare with target state */
  70710. value: string;
  70711. /**
  70712. * Internal only - manager for action
  70713. * @hidden
  70714. */
  70715. _actionManager: ActionManager;
  70716. /**
  70717. * Internal only
  70718. * @hidden
  70719. */
  70720. private _target;
  70721. /**
  70722. * Creates a new StateCondition
  70723. * @param actionManager manager for the action the condition applies to
  70724. * @param target of the condition
  70725. * @param value to compare with target state
  70726. */
  70727. constructor(actionManager: ActionManager, target: any,
  70728. /** Value to compare with target state */
  70729. value: string);
  70730. /**
  70731. * Gets a boolean indicating if the current condition is met
  70732. * @returns the validity of the state
  70733. */
  70734. isValid(): boolean;
  70735. /**
  70736. * Serialize the StateCondition into a JSON compatible object
  70737. * @returns serialization object
  70738. */
  70739. serialize(): any;
  70740. }
  70741. }
  70742. declare module BABYLON {
  70743. /**
  70744. * This defines an action responsible to toggle a boolean once triggered.
  70745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70746. */
  70747. export class SwitchBooleanAction extends Action {
  70748. /**
  70749. * The path to the boolean property in the target object
  70750. */
  70751. propertyPath: string;
  70752. private _target;
  70753. private _effectiveTarget;
  70754. private _property;
  70755. /**
  70756. * Instantiate the action
  70757. * @param triggerOptions defines the trigger options
  70758. * @param target defines the object containing the boolean
  70759. * @param propertyPath defines the path to the boolean property in the target object
  70760. * @param condition defines the trigger related conditions
  70761. */
  70762. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70763. /** @hidden */
  70764. _prepare(): void;
  70765. /**
  70766. * Execute the action toggle the boolean value.
  70767. */
  70768. execute(): void;
  70769. /**
  70770. * Serializes the actions and its related information.
  70771. * @param parent defines the object to serialize in
  70772. * @returns the serialized object
  70773. */
  70774. serialize(parent: any): any;
  70775. }
  70776. /**
  70777. * This defines an action responsible to set a the state field of the target
  70778. * to a desired value once triggered.
  70779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70780. */
  70781. export class SetStateAction extends Action {
  70782. /**
  70783. * The value to store in the state field.
  70784. */
  70785. value: string;
  70786. private _target;
  70787. /**
  70788. * Instantiate the action
  70789. * @param triggerOptions defines the trigger options
  70790. * @param target defines the object containing the state property
  70791. * @param value defines the value to store in the state field
  70792. * @param condition defines the trigger related conditions
  70793. */
  70794. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70795. /**
  70796. * Execute the action and store the value on the target state property.
  70797. */
  70798. execute(): void;
  70799. /**
  70800. * Serializes the actions and its related information.
  70801. * @param parent defines the object to serialize in
  70802. * @returns the serialized object
  70803. */
  70804. serialize(parent: any): any;
  70805. }
  70806. /**
  70807. * This defines an action responsible to set a property of the target
  70808. * to a desired value once triggered.
  70809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70810. */
  70811. export class SetValueAction extends Action {
  70812. /**
  70813. * The path of the property to set in the target.
  70814. */
  70815. propertyPath: string;
  70816. /**
  70817. * The value to set in the property
  70818. */
  70819. value: any;
  70820. private _target;
  70821. private _effectiveTarget;
  70822. private _property;
  70823. /**
  70824. * Instantiate the action
  70825. * @param triggerOptions defines the trigger options
  70826. * @param target defines the object containing the property
  70827. * @param propertyPath defines the path of the property to set in the target
  70828. * @param value defines the value to set in the property
  70829. * @param condition defines the trigger related conditions
  70830. */
  70831. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70832. /** @hidden */
  70833. _prepare(): void;
  70834. /**
  70835. * Execute the action and set the targetted property to the desired value.
  70836. */
  70837. execute(): void;
  70838. /**
  70839. * Serializes the actions and its related information.
  70840. * @param parent defines the object to serialize in
  70841. * @returns the serialized object
  70842. */
  70843. serialize(parent: any): any;
  70844. }
  70845. /**
  70846. * This defines an action responsible to increment the target value
  70847. * to a desired value once triggered.
  70848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70849. */
  70850. export class IncrementValueAction extends Action {
  70851. /**
  70852. * The path of the property to increment in the target.
  70853. */
  70854. propertyPath: string;
  70855. /**
  70856. * The value we should increment the property by.
  70857. */
  70858. value: any;
  70859. private _target;
  70860. private _effectiveTarget;
  70861. private _property;
  70862. /**
  70863. * Instantiate the action
  70864. * @param triggerOptions defines the trigger options
  70865. * @param target defines the object containing the property
  70866. * @param propertyPath defines the path of the property to increment in the target
  70867. * @param value defines the value value we should increment the property by
  70868. * @param condition defines the trigger related conditions
  70869. */
  70870. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70871. /** @hidden */
  70872. _prepare(): void;
  70873. /**
  70874. * Execute the action and increment the target of the value amount.
  70875. */
  70876. execute(): void;
  70877. /**
  70878. * Serializes the actions and its related information.
  70879. * @param parent defines the object to serialize in
  70880. * @returns the serialized object
  70881. */
  70882. serialize(parent: any): any;
  70883. }
  70884. /**
  70885. * This defines an action responsible to start an animation once triggered.
  70886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70887. */
  70888. export class PlayAnimationAction extends Action {
  70889. /**
  70890. * Where the animation should start (animation frame)
  70891. */
  70892. from: number;
  70893. /**
  70894. * Where the animation should stop (animation frame)
  70895. */
  70896. to: number;
  70897. /**
  70898. * Define if the animation should loop or stop after the first play.
  70899. */
  70900. loop?: boolean;
  70901. private _target;
  70902. /**
  70903. * Instantiate the action
  70904. * @param triggerOptions defines the trigger options
  70905. * @param target defines the target animation or animation name
  70906. * @param from defines from where the animation should start (animation frame)
  70907. * @param end defines where the animation should stop (animation frame)
  70908. * @param loop defines if the animation should loop or stop after the first play
  70909. * @param condition defines the trigger related conditions
  70910. */
  70911. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70912. /** @hidden */
  70913. _prepare(): void;
  70914. /**
  70915. * Execute the action and play the animation.
  70916. */
  70917. execute(): void;
  70918. /**
  70919. * Serializes the actions and its related information.
  70920. * @param parent defines the object to serialize in
  70921. * @returns the serialized object
  70922. */
  70923. serialize(parent: any): any;
  70924. }
  70925. /**
  70926. * This defines an action responsible to stop an animation once triggered.
  70927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70928. */
  70929. export class StopAnimationAction extends Action {
  70930. private _target;
  70931. /**
  70932. * Instantiate the action
  70933. * @param triggerOptions defines the trigger options
  70934. * @param target defines the target animation or animation name
  70935. * @param condition defines the trigger related conditions
  70936. */
  70937. constructor(triggerOptions: any, target: any, condition?: Condition);
  70938. /** @hidden */
  70939. _prepare(): void;
  70940. /**
  70941. * Execute the action and stop the animation.
  70942. */
  70943. execute(): void;
  70944. /**
  70945. * Serializes the actions and its related information.
  70946. * @param parent defines the object to serialize in
  70947. * @returns the serialized object
  70948. */
  70949. serialize(parent: any): any;
  70950. }
  70951. /**
  70952. * This defines an action responsible that does nothing once triggered.
  70953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70954. */
  70955. export class DoNothingAction extends Action {
  70956. /**
  70957. * Instantiate the action
  70958. * @param triggerOptions defines the trigger options
  70959. * @param condition defines the trigger related conditions
  70960. */
  70961. constructor(triggerOptions?: any, condition?: Condition);
  70962. /**
  70963. * Execute the action and do nothing.
  70964. */
  70965. execute(): void;
  70966. /**
  70967. * Serializes the actions and its related information.
  70968. * @param parent defines the object to serialize in
  70969. * @returns the serialized object
  70970. */
  70971. serialize(parent: any): any;
  70972. }
  70973. /**
  70974. * This defines an action responsible to trigger several actions once triggered.
  70975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70976. */
  70977. export class CombineAction extends Action {
  70978. /**
  70979. * The list of aggregated animations to run.
  70980. */
  70981. children: Action[];
  70982. /**
  70983. * Instantiate the action
  70984. * @param triggerOptions defines the trigger options
  70985. * @param children defines the list of aggregated animations to run
  70986. * @param condition defines the trigger related conditions
  70987. */
  70988. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70989. /** @hidden */
  70990. _prepare(): void;
  70991. /**
  70992. * Execute the action and executes all the aggregated actions.
  70993. */
  70994. execute(evt: ActionEvent): void;
  70995. /**
  70996. * Serializes the actions and its related information.
  70997. * @param parent defines the object to serialize in
  70998. * @returns the serialized object
  70999. */
  71000. serialize(parent: any): any;
  71001. }
  71002. /**
  71003. * This defines an action responsible to run code (external event) once triggered.
  71004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71005. */
  71006. export class ExecuteCodeAction extends Action {
  71007. /**
  71008. * The callback function to run.
  71009. */
  71010. func: (evt: ActionEvent) => void;
  71011. /**
  71012. * Instantiate the action
  71013. * @param triggerOptions defines the trigger options
  71014. * @param func defines the callback function to run
  71015. * @param condition defines the trigger related conditions
  71016. */
  71017. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71018. /**
  71019. * Execute the action and run the attached code.
  71020. */
  71021. execute(evt: ActionEvent): void;
  71022. }
  71023. /**
  71024. * This defines an action responsible to set the parent property of the target once triggered.
  71025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71026. */
  71027. export class SetParentAction extends Action {
  71028. private _parent;
  71029. private _target;
  71030. /**
  71031. * Instantiate the action
  71032. * @param triggerOptions defines the trigger options
  71033. * @param target defines the target containing the parent property
  71034. * @param parent defines from where the animation should start (animation frame)
  71035. * @param condition defines the trigger related conditions
  71036. */
  71037. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71038. /** @hidden */
  71039. _prepare(): void;
  71040. /**
  71041. * Execute the action and set the parent property.
  71042. */
  71043. execute(): void;
  71044. /**
  71045. * Serializes the actions and its related information.
  71046. * @param parent defines the object to serialize in
  71047. * @returns the serialized object
  71048. */
  71049. serialize(parent: any): any;
  71050. }
  71051. }
  71052. declare module BABYLON {
  71053. /**
  71054. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71055. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71057. */
  71058. export class ActionManager extends AbstractActionManager {
  71059. /**
  71060. * Nothing
  71061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71062. */
  71063. static readonly NothingTrigger: number;
  71064. /**
  71065. * On pick
  71066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71067. */
  71068. static readonly OnPickTrigger: number;
  71069. /**
  71070. * On left pick
  71071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71072. */
  71073. static readonly OnLeftPickTrigger: number;
  71074. /**
  71075. * On right pick
  71076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71077. */
  71078. static readonly OnRightPickTrigger: number;
  71079. /**
  71080. * On center pick
  71081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71082. */
  71083. static readonly OnCenterPickTrigger: number;
  71084. /**
  71085. * On pick down
  71086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71087. */
  71088. static readonly OnPickDownTrigger: number;
  71089. /**
  71090. * On double pick
  71091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71092. */
  71093. static readonly OnDoublePickTrigger: number;
  71094. /**
  71095. * On pick up
  71096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71097. */
  71098. static readonly OnPickUpTrigger: number;
  71099. /**
  71100. * On pick out.
  71101. * This trigger will only be raised if you also declared a OnPickDown
  71102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71103. */
  71104. static readonly OnPickOutTrigger: number;
  71105. /**
  71106. * On long press
  71107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71108. */
  71109. static readonly OnLongPressTrigger: number;
  71110. /**
  71111. * On pointer over
  71112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71113. */
  71114. static readonly OnPointerOverTrigger: number;
  71115. /**
  71116. * On pointer out
  71117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71118. */
  71119. static readonly OnPointerOutTrigger: number;
  71120. /**
  71121. * On every frame
  71122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71123. */
  71124. static readonly OnEveryFrameTrigger: number;
  71125. /**
  71126. * On intersection enter
  71127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71128. */
  71129. static readonly OnIntersectionEnterTrigger: number;
  71130. /**
  71131. * On intersection exit
  71132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71133. */
  71134. static readonly OnIntersectionExitTrigger: number;
  71135. /**
  71136. * On key down
  71137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71138. */
  71139. static readonly OnKeyDownTrigger: number;
  71140. /**
  71141. * On key up
  71142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71143. */
  71144. static readonly OnKeyUpTrigger: number;
  71145. private _scene;
  71146. /**
  71147. * Creates a new action manager
  71148. * @param scene defines the hosting scene
  71149. */
  71150. constructor(scene: Scene);
  71151. /**
  71152. * Releases all associated resources
  71153. */
  71154. dispose(): void;
  71155. /**
  71156. * Gets hosting scene
  71157. * @returns the hosting scene
  71158. */
  71159. getScene(): Scene;
  71160. /**
  71161. * Does this action manager handles actions of any of the given triggers
  71162. * @param triggers defines the triggers to be tested
  71163. * @return a boolean indicating whether one (or more) of the triggers is handled
  71164. */
  71165. hasSpecificTriggers(triggers: number[]): boolean;
  71166. /**
  71167. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71168. * speed.
  71169. * @param triggerA defines the trigger to be tested
  71170. * @param triggerB defines the trigger to be tested
  71171. * @return a boolean indicating whether one (or more) of the triggers is handled
  71172. */
  71173. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71174. /**
  71175. * Does this action manager handles actions of a given trigger
  71176. * @param trigger defines the trigger to be tested
  71177. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71178. * @return whether the trigger is handled
  71179. */
  71180. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71181. /**
  71182. * Does this action manager has pointer triggers
  71183. */
  71184. readonly hasPointerTriggers: boolean;
  71185. /**
  71186. * Does this action manager has pick triggers
  71187. */
  71188. readonly hasPickTriggers: boolean;
  71189. /**
  71190. * Registers an action to this action manager
  71191. * @param action defines the action to be registered
  71192. * @return the action amended (prepared) after registration
  71193. */
  71194. registerAction(action: IAction): Nullable<IAction>;
  71195. /**
  71196. * Unregisters an action to this action manager
  71197. * @param action defines the action to be unregistered
  71198. * @return a boolean indicating whether the action has been unregistered
  71199. */
  71200. unregisterAction(action: IAction): Boolean;
  71201. /**
  71202. * Process a specific trigger
  71203. * @param trigger defines the trigger to process
  71204. * @param evt defines the event details to be processed
  71205. */
  71206. processTrigger(trigger: number, evt?: IActionEvent): void;
  71207. /** @hidden */
  71208. _getEffectiveTarget(target: any, propertyPath: string): any;
  71209. /** @hidden */
  71210. _getProperty(propertyPath: string): string;
  71211. /**
  71212. * Serialize this manager to a JSON object
  71213. * @param name defines the property name to store this manager
  71214. * @returns a JSON representation of this manager
  71215. */
  71216. serialize(name: string): any;
  71217. /**
  71218. * Creates a new ActionManager from a JSON data
  71219. * @param parsedActions defines the JSON data to read from
  71220. * @param object defines the hosting mesh
  71221. * @param scene defines the hosting scene
  71222. */
  71223. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71224. /**
  71225. * Get a trigger name by index
  71226. * @param trigger defines the trigger index
  71227. * @returns a trigger name
  71228. */
  71229. static GetTriggerName(trigger: number): string;
  71230. }
  71231. }
  71232. declare module BABYLON {
  71233. /**
  71234. * Class representing a ray with position and direction
  71235. */
  71236. export class Ray {
  71237. /** origin point */
  71238. origin: Vector3;
  71239. /** direction */
  71240. direction: Vector3;
  71241. /** length of the ray */
  71242. length: number;
  71243. private static readonly TmpVector3;
  71244. private _tmpRay;
  71245. /**
  71246. * Creates a new ray
  71247. * @param origin origin point
  71248. * @param direction direction
  71249. * @param length length of the ray
  71250. */
  71251. constructor(
  71252. /** origin point */
  71253. origin: Vector3,
  71254. /** direction */
  71255. direction: Vector3,
  71256. /** length of the ray */
  71257. length?: number);
  71258. /**
  71259. * Checks if the ray intersects a box
  71260. * @param minimum bound of the box
  71261. * @param maximum bound of the box
  71262. * @param intersectionTreshold extra extend to be added to the box in all direction
  71263. * @returns if the box was hit
  71264. */
  71265. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71266. /**
  71267. * Checks if the ray intersects a box
  71268. * @param box the bounding box to check
  71269. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71270. * @returns if the box was hit
  71271. */
  71272. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71273. /**
  71274. * If the ray hits a sphere
  71275. * @param sphere the bounding sphere to check
  71276. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71277. * @returns true if it hits the sphere
  71278. */
  71279. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71280. /**
  71281. * If the ray hits a triange
  71282. * @param vertex0 triangle vertex
  71283. * @param vertex1 triangle vertex
  71284. * @param vertex2 triangle vertex
  71285. * @returns intersection information if hit
  71286. */
  71287. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71288. /**
  71289. * Checks if ray intersects a plane
  71290. * @param plane the plane to check
  71291. * @returns the distance away it was hit
  71292. */
  71293. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71294. /**
  71295. * Checks if ray intersects a mesh
  71296. * @param mesh the mesh to check
  71297. * @param fastCheck if only the bounding box should checked
  71298. * @returns picking info of the intersecton
  71299. */
  71300. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71301. /**
  71302. * Checks if ray intersects a mesh
  71303. * @param meshes the meshes to check
  71304. * @param fastCheck if only the bounding box should checked
  71305. * @param results array to store result in
  71306. * @returns Array of picking infos
  71307. */
  71308. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71309. private _comparePickingInfo;
  71310. private static smallnum;
  71311. private static rayl;
  71312. /**
  71313. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71314. * @param sega the first point of the segment to test the intersection against
  71315. * @param segb the second point of the segment to test the intersection against
  71316. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71317. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71318. */
  71319. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71320. /**
  71321. * Update the ray from viewport position
  71322. * @param x position
  71323. * @param y y position
  71324. * @param viewportWidth viewport width
  71325. * @param viewportHeight viewport height
  71326. * @param world world matrix
  71327. * @param view view matrix
  71328. * @param projection projection matrix
  71329. * @returns this ray updated
  71330. */
  71331. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71332. /**
  71333. * Creates a ray with origin and direction of 0,0,0
  71334. * @returns the new ray
  71335. */
  71336. static Zero(): Ray;
  71337. /**
  71338. * Creates a new ray from screen space and viewport
  71339. * @param x position
  71340. * @param y y position
  71341. * @param viewportWidth viewport width
  71342. * @param viewportHeight viewport height
  71343. * @param world world matrix
  71344. * @param view view matrix
  71345. * @param projection projection matrix
  71346. * @returns new ray
  71347. */
  71348. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71349. /**
  71350. * 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
  71351. * transformed to the given world matrix.
  71352. * @param origin The origin point
  71353. * @param end The end point
  71354. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71355. * @returns the new ray
  71356. */
  71357. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71358. /**
  71359. * Transforms a ray by a matrix
  71360. * @param ray ray to transform
  71361. * @param matrix matrix to apply
  71362. * @returns the resulting new ray
  71363. */
  71364. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71365. /**
  71366. * Transforms a ray by a matrix
  71367. * @param ray ray to transform
  71368. * @param matrix matrix to apply
  71369. * @param result ray to store result in
  71370. */
  71371. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71372. /**
  71373. * Unproject a ray from screen space to object space
  71374. * @param sourceX defines the screen space x coordinate to use
  71375. * @param sourceY defines the screen space y coordinate to use
  71376. * @param viewportWidth defines the current width of the viewport
  71377. * @param viewportHeight defines the current height of the viewport
  71378. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71379. * @param view defines the view matrix to use
  71380. * @param projection defines the projection matrix to use
  71381. */
  71382. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71383. }
  71384. /**
  71385. * Type used to define predicate used to select faces when a mesh intersection is detected
  71386. */
  71387. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71388. interface Scene {
  71389. /** @hidden */
  71390. _tempPickingRay: Nullable<Ray>;
  71391. /** @hidden */
  71392. _cachedRayForTransform: Ray;
  71393. /** @hidden */
  71394. _pickWithRayInverseMatrix: Matrix;
  71395. /** @hidden */
  71396. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71397. /** @hidden */
  71398. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71399. }
  71400. }
  71401. declare module BABYLON {
  71402. /**
  71403. * Groups all the scene component constants in one place to ease maintenance.
  71404. * @hidden
  71405. */
  71406. export class SceneComponentConstants {
  71407. static readonly NAME_EFFECTLAYER: string;
  71408. static readonly NAME_LAYER: string;
  71409. static readonly NAME_LENSFLARESYSTEM: string;
  71410. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71411. static readonly NAME_PARTICLESYSTEM: string;
  71412. static readonly NAME_GAMEPAD: string;
  71413. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71414. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71415. static readonly NAME_DEPTHRENDERER: string;
  71416. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71417. static readonly NAME_SPRITE: string;
  71418. static readonly NAME_OUTLINERENDERER: string;
  71419. static readonly NAME_PROCEDURALTEXTURE: string;
  71420. static readonly NAME_SHADOWGENERATOR: string;
  71421. static readonly NAME_OCTREE: string;
  71422. static readonly NAME_PHYSICSENGINE: string;
  71423. static readonly NAME_AUDIO: string;
  71424. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71425. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71426. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71427. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71428. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71429. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71430. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71431. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71432. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71433. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71434. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71435. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71436. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71437. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71438. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71439. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71440. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71441. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71442. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71443. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71444. static readonly STEP_AFTERRENDER_AUDIO: number;
  71445. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71446. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71447. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71448. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71449. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71450. static readonly STEP_POINTERMOVE_SPRITE: number;
  71451. static readonly STEP_POINTERDOWN_SPRITE: number;
  71452. static readonly STEP_POINTERUP_SPRITE: number;
  71453. }
  71454. /**
  71455. * This represents a scene component.
  71456. *
  71457. * This is used to decouple the dependency the scene is having on the different workloads like
  71458. * layers, post processes...
  71459. */
  71460. export interface ISceneComponent {
  71461. /**
  71462. * The name of the component. Each component must have a unique name.
  71463. */
  71464. name: string;
  71465. /**
  71466. * The scene the component belongs to.
  71467. */
  71468. scene: Scene;
  71469. /**
  71470. * Register the component to one instance of a scene.
  71471. */
  71472. register(): void;
  71473. /**
  71474. * Rebuilds the elements related to this component in case of
  71475. * context lost for instance.
  71476. */
  71477. rebuild(): void;
  71478. /**
  71479. * Disposes the component and the associated ressources.
  71480. */
  71481. dispose(): void;
  71482. }
  71483. /**
  71484. * This represents a SERIALIZABLE scene component.
  71485. *
  71486. * This extends Scene Component to add Serialization methods on top.
  71487. */
  71488. export interface ISceneSerializableComponent extends ISceneComponent {
  71489. /**
  71490. * Adds all the element from the container to the scene
  71491. * @param container the container holding the elements
  71492. */
  71493. addFromContainer(container: AbstractScene): void;
  71494. /**
  71495. * Removes all the elements in the container from the scene
  71496. * @param container contains the elements to remove
  71497. * @param dispose if the removed element should be disposed (default: false)
  71498. */
  71499. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71500. /**
  71501. * Serializes the component data to the specified json object
  71502. * @param serializationObject The object to serialize to
  71503. */
  71504. serialize(serializationObject: any): void;
  71505. }
  71506. /**
  71507. * Strong typing of a Mesh related stage step action
  71508. */
  71509. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71510. /**
  71511. * Strong typing of a Evaluate Sub Mesh related stage step action
  71512. */
  71513. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71514. /**
  71515. * Strong typing of a Active Mesh related stage step action
  71516. */
  71517. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71518. /**
  71519. * Strong typing of a Camera related stage step action
  71520. */
  71521. export type CameraStageAction = (camera: Camera) => void;
  71522. /**
  71523. * Strong typing of a Camera Frame buffer related stage step action
  71524. */
  71525. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71526. /**
  71527. * Strong typing of a Render Target related stage step action
  71528. */
  71529. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71530. /**
  71531. * Strong typing of a RenderingGroup related stage step action
  71532. */
  71533. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71534. /**
  71535. * Strong typing of a Mesh Render related stage step action
  71536. */
  71537. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71538. /**
  71539. * Strong typing of a simple stage step action
  71540. */
  71541. export type SimpleStageAction = () => void;
  71542. /**
  71543. * Strong typing of a render target action.
  71544. */
  71545. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71546. /**
  71547. * Strong typing of a pointer move action.
  71548. */
  71549. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71550. /**
  71551. * Strong typing of a pointer up/down action.
  71552. */
  71553. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71554. /**
  71555. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71556. * @hidden
  71557. */
  71558. export class Stage<T extends Function> extends Array<{
  71559. index: number;
  71560. component: ISceneComponent;
  71561. action: T;
  71562. }> {
  71563. /**
  71564. * Hide ctor from the rest of the world.
  71565. * @param items The items to add.
  71566. */
  71567. private constructor();
  71568. /**
  71569. * Creates a new Stage.
  71570. * @returns A new instance of a Stage
  71571. */
  71572. static Create<T extends Function>(): Stage<T>;
  71573. /**
  71574. * Registers a step in an ordered way in the targeted stage.
  71575. * @param index Defines the position to register the step in
  71576. * @param component Defines the component attached to the step
  71577. * @param action Defines the action to launch during the step
  71578. */
  71579. registerStep(index: number, component: ISceneComponent, action: T): void;
  71580. /**
  71581. * Clears all the steps from the stage.
  71582. */
  71583. clear(): void;
  71584. }
  71585. }
  71586. declare module BABYLON {
  71587. interface Scene {
  71588. /** @hidden */
  71589. _pointerOverSprite: Nullable<Sprite>;
  71590. /** @hidden */
  71591. _pickedDownSprite: Nullable<Sprite>;
  71592. /** @hidden */
  71593. _tempSpritePickingRay: Nullable<Ray>;
  71594. /**
  71595. * All of the sprite managers added to this scene
  71596. * @see http://doc.babylonjs.com/babylon101/sprites
  71597. */
  71598. spriteManagers: Array<ISpriteManager>;
  71599. /**
  71600. * An event triggered when sprites rendering is about to start
  71601. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71602. */
  71603. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71604. /**
  71605. * An event triggered when sprites rendering is done
  71606. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71607. */
  71608. onAfterSpritesRenderingObservable: Observable<Scene>;
  71609. /** @hidden */
  71610. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71611. /** Launch a ray to try to pick a sprite in the scene
  71612. * @param x position on screen
  71613. * @param y position on screen
  71614. * @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
  71615. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71616. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71617. * @returns a PickingInfo
  71618. */
  71619. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71620. /** Use the given ray to pick a sprite in the scene
  71621. * @param ray The ray (in world space) to use to pick meshes
  71622. * @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
  71623. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71624. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71625. * @returns a PickingInfo
  71626. */
  71627. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71628. /**
  71629. * Force the sprite under the pointer
  71630. * @param sprite defines the sprite to use
  71631. */
  71632. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71633. /**
  71634. * Gets the sprite under the pointer
  71635. * @returns a Sprite or null if no sprite is under the pointer
  71636. */
  71637. getPointerOverSprite(): Nullable<Sprite>;
  71638. }
  71639. /**
  71640. * Defines the sprite scene component responsible to manage sprites
  71641. * in a given scene.
  71642. */
  71643. export class SpriteSceneComponent implements ISceneComponent {
  71644. /**
  71645. * The component name helpfull to identify the component in the list of scene components.
  71646. */
  71647. readonly name: string;
  71648. /**
  71649. * The scene the component belongs to.
  71650. */
  71651. scene: Scene;
  71652. /** @hidden */
  71653. private _spritePredicate;
  71654. /**
  71655. * Creates a new instance of the component for the given scene
  71656. * @param scene Defines the scene to register the component in
  71657. */
  71658. constructor(scene: Scene);
  71659. /**
  71660. * Registers the component in a given scene
  71661. */
  71662. register(): void;
  71663. /**
  71664. * Rebuilds the elements related to this component in case of
  71665. * context lost for instance.
  71666. */
  71667. rebuild(): void;
  71668. /**
  71669. * Disposes the component and the associated ressources.
  71670. */
  71671. dispose(): void;
  71672. private _pickSpriteButKeepRay;
  71673. private _pointerMove;
  71674. private _pointerDown;
  71675. private _pointerUp;
  71676. }
  71677. }
  71678. declare module BABYLON {
  71679. /** @hidden */
  71680. export var fogFragmentDeclaration: {
  71681. name: string;
  71682. shader: string;
  71683. };
  71684. }
  71685. declare module BABYLON {
  71686. /** @hidden */
  71687. export var fogFragment: {
  71688. name: string;
  71689. shader: string;
  71690. };
  71691. }
  71692. declare module BABYLON {
  71693. /** @hidden */
  71694. export var spritesPixelShader: {
  71695. name: string;
  71696. shader: string;
  71697. };
  71698. }
  71699. declare module BABYLON {
  71700. /** @hidden */
  71701. export var fogVertexDeclaration: {
  71702. name: string;
  71703. shader: string;
  71704. };
  71705. }
  71706. declare module BABYLON {
  71707. /** @hidden */
  71708. export var spritesVertexShader: {
  71709. name: string;
  71710. shader: string;
  71711. };
  71712. }
  71713. declare module BABYLON {
  71714. /**
  71715. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71716. */
  71717. export interface ISpriteManager extends IDisposable {
  71718. /**
  71719. * Restricts the camera to viewing objects with the same layerMask.
  71720. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71721. */
  71722. layerMask: number;
  71723. /**
  71724. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71725. */
  71726. isPickable: boolean;
  71727. /**
  71728. * Specifies the rendering group id for this mesh (0 by default)
  71729. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71730. */
  71731. renderingGroupId: number;
  71732. /**
  71733. * Defines the list of sprites managed by the manager.
  71734. */
  71735. sprites: Array<Sprite>;
  71736. /**
  71737. * Tests the intersection of a sprite with a specific ray.
  71738. * @param ray The ray we are sending to test the collision
  71739. * @param camera The camera space we are sending rays in
  71740. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71741. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71742. * @returns picking info or null.
  71743. */
  71744. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71745. /**
  71746. * Renders the list of sprites on screen.
  71747. */
  71748. render(): void;
  71749. }
  71750. /**
  71751. * Class used to manage multiple sprites on the same spritesheet
  71752. * @see http://doc.babylonjs.com/babylon101/sprites
  71753. */
  71754. export class SpriteManager implements ISpriteManager {
  71755. /** defines the manager's name */
  71756. name: string;
  71757. /** Gets the list of sprites */
  71758. sprites: Sprite[];
  71759. /** Gets or sets the rendering group id (0 by default) */
  71760. renderingGroupId: number;
  71761. /** Gets or sets camera layer mask */
  71762. layerMask: number;
  71763. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71764. fogEnabled: boolean;
  71765. /** Gets or sets a boolean indicating if the sprites are pickable */
  71766. isPickable: boolean;
  71767. /** Defines the default width of a cell in the spritesheet */
  71768. cellWidth: number;
  71769. /** Defines the default height of a cell in the spritesheet */
  71770. cellHeight: number;
  71771. /**
  71772. * An event triggered when the manager is disposed.
  71773. */
  71774. onDisposeObservable: Observable<SpriteManager>;
  71775. private _onDisposeObserver;
  71776. /**
  71777. * Callback called when the manager is disposed
  71778. */
  71779. onDispose: () => void;
  71780. private _capacity;
  71781. private _spriteTexture;
  71782. private _epsilon;
  71783. private _scene;
  71784. private _vertexData;
  71785. private _buffer;
  71786. private _vertexBuffers;
  71787. private _indexBuffer;
  71788. private _effectBase;
  71789. private _effectFog;
  71790. /**
  71791. * Gets or sets the spritesheet texture
  71792. */
  71793. texture: Texture;
  71794. /**
  71795. * Creates a new sprite manager
  71796. * @param name defines the manager's name
  71797. * @param imgUrl defines the sprite sheet url
  71798. * @param capacity defines the maximum allowed number of sprites
  71799. * @param cellSize defines the size of a sprite cell
  71800. * @param scene defines the hosting scene
  71801. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71802. * @param samplingMode defines the smapling mode to use with spritesheet
  71803. */
  71804. constructor(
  71805. /** defines the manager's name */
  71806. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71807. private _appendSpriteVertex;
  71808. /**
  71809. * Intersects the sprites with a ray
  71810. * @param ray defines the ray to intersect with
  71811. * @param camera defines the current active camera
  71812. * @param predicate defines a predicate used to select candidate sprites
  71813. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71814. * @returns null if no hit or a PickingInfo
  71815. */
  71816. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71817. /**
  71818. * Render all child sprites
  71819. */
  71820. render(): void;
  71821. /**
  71822. * Release associated resources
  71823. */
  71824. dispose(): void;
  71825. }
  71826. }
  71827. declare module BABYLON {
  71828. /**
  71829. * Class used to represent a sprite
  71830. * @see http://doc.babylonjs.com/babylon101/sprites
  71831. */
  71832. export class Sprite {
  71833. /** defines the name */
  71834. name: string;
  71835. /** Gets or sets the current world position */
  71836. position: Vector3;
  71837. /** Gets or sets the main color */
  71838. color: Color4;
  71839. /** Gets or sets the width */
  71840. width: number;
  71841. /** Gets or sets the height */
  71842. height: number;
  71843. /** Gets or sets rotation angle */
  71844. angle: number;
  71845. /** Gets or sets the cell index in the sprite sheet */
  71846. cellIndex: number;
  71847. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71848. invertU: number;
  71849. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71850. invertV: number;
  71851. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71852. disposeWhenFinishedAnimating: boolean;
  71853. /** Gets the list of attached animations */
  71854. animations: Animation[];
  71855. /** Gets or sets a boolean indicating if the sprite can be picked */
  71856. isPickable: boolean;
  71857. /**
  71858. * Gets or sets the associated action manager
  71859. */
  71860. actionManager: Nullable<ActionManager>;
  71861. private _animationStarted;
  71862. private _loopAnimation;
  71863. private _fromIndex;
  71864. private _toIndex;
  71865. private _delay;
  71866. private _direction;
  71867. private _manager;
  71868. private _time;
  71869. private _onAnimationEnd;
  71870. /**
  71871. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71872. */
  71873. isVisible: boolean;
  71874. /**
  71875. * Gets or sets the sprite size
  71876. */
  71877. size: number;
  71878. /**
  71879. * Creates a new Sprite
  71880. * @param name defines the name
  71881. * @param manager defines the manager
  71882. */
  71883. constructor(
  71884. /** defines the name */
  71885. name: string, manager: ISpriteManager);
  71886. /**
  71887. * Starts an animation
  71888. * @param from defines the initial key
  71889. * @param to defines the end key
  71890. * @param loop defines if the animation must loop
  71891. * @param delay defines the start delay (in ms)
  71892. * @param onAnimationEnd defines a callback to call when animation ends
  71893. */
  71894. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71895. /** Stops current animation (if any) */
  71896. stopAnimation(): void;
  71897. /** @hidden */
  71898. _animate(deltaTime: number): void;
  71899. /** Release associated resources */
  71900. dispose(): void;
  71901. }
  71902. }
  71903. declare module BABYLON {
  71904. /**
  71905. * Information about the result of picking within a scene
  71906. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71907. */
  71908. export class PickingInfo {
  71909. /** @hidden */
  71910. _pickingUnavailable: boolean;
  71911. /**
  71912. * If the pick collided with an object
  71913. */
  71914. hit: boolean;
  71915. /**
  71916. * Distance away where the pick collided
  71917. */
  71918. distance: number;
  71919. /**
  71920. * The location of pick collision
  71921. */
  71922. pickedPoint: Nullable<Vector3>;
  71923. /**
  71924. * The mesh corresponding the the pick collision
  71925. */
  71926. pickedMesh: Nullable<AbstractMesh>;
  71927. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71928. bu: number;
  71929. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71930. bv: number;
  71931. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71932. faceId: number;
  71933. /** Id of the the submesh that was picked */
  71934. subMeshId: number;
  71935. /** If a sprite was picked, this will be the sprite the pick collided with */
  71936. pickedSprite: Nullable<Sprite>;
  71937. /**
  71938. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71939. */
  71940. originMesh: Nullable<AbstractMesh>;
  71941. /**
  71942. * The ray that was used to perform the picking.
  71943. */
  71944. ray: Nullable<Ray>;
  71945. /**
  71946. * Gets the normal correspodning to the face the pick collided with
  71947. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71948. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71949. * @returns The normal correspodning to the face the pick collided with
  71950. */
  71951. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71952. /**
  71953. * Gets the texture coordinates of where the pick occured
  71954. * @returns the vector containing the coordnates of the texture
  71955. */
  71956. getTextureCoordinates(): Nullable<Vector2>;
  71957. }
  71958. }
  71959. declare module BABYLON {
  71960. /**
  71961. * Gather the list of pointer event types as constants.
  71962. */
  71963. export class PointerEventTypes {
  71964. /**
  71965. * 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.
  71966. */
  71967. static readonly POINTERDOWN: number;
  71968. /**
  71969. * The pointerup event is fired when a pointer is no longer active.
  71970. */
  71971. static readonly POINTERUP: number;
  71972. /**
  71973. * The pointermove event is fired when a pointer changes coordinates.
  71974. */
  71975. static readonly POINTERMOVE: number;
  71976. /**
  71977. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71978. */
  71979. static readonly POINTERWHEEL: number;
  71980. /**
  71981. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71982. */
  71983. static readonly POINTERPICK: number;
  71984. /**
  71985. * The pointertap event is fired when a the object has been touched and released without drag.
  71986. */
  71987. static readonly POINTERTAP: number;
  71988. /**
  71989. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71990. */
  71991. static readonly POINTERDOUBLETAP: number;
  71992. }
  71993. /**
  71994. * Base class of pointer info types.
  71995. */
  71996. export class PointerInfoBase {
  71997. /**
  71998. * Defines the type of event (PointerEventTypes)
  71999. */
  72000. type: number;
  72001. /**
  72002. * Defines the related dom event
  72003. */
  72004. event: PointerEvent | MouseWheelEvent;
  72005. /**
  72006. * Instantiates the base class of pointers info.
  72007. * @param type Defines the type of event (PointerEventTypes)
  72008. * @param event Defines the related dom event
  72009. */
  72010. constructor(
  72011. /**
  72012. * Defines the type of event (PointerEventTypes)
  72013. */
  72014. type: number,
  72015. /**
  72016. * Defines the related dom event
  72017. */
  72018. event: PointerEvent | MouseWheelEvent);
  72019. }
  72020. /**
  72021. * This class is used to store pointer related info for the onPrePointerObservable event.
  72022. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72023. */
  72024. export class PointerInfoPre extends PointerInfoBase {
  72025. /**
  72026. * Ray from a pointer if availible (eg. 6dof controller)
  72027. */
  72028. ray: Nullable<Ray>;
  72029. /**
  72030. * Defines the local position of the pointer on the canvas.
  72031. */
  72032. localPosition: Vector2;
  72033. /**
  72034. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72035. */
  72036. skipOnPointerObservable: boolean;
  72037. /**
  72038. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72039. * @param type Defines the type of event (PointerEventTypes)
  72040. * @param event Defines the related dom event
  72041. * @param localX Defines the local x coordinates of the pointer when the event occured
  72042. * @param localY Defines the local y coordinates of the pointer when the event occured
  72043. */
  72044. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72045. }
  72046. /**
  72047. * This type contains all the data related to a pointer event in Babylon.js.
  72048. * 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.
  72049. */
  72050. export class PointerInfo extends PointerInfoBase {
  72051. /**
  72052. * Defines the picking info associated to the info (if any)\
  72053. */
  72054. pickInfo: Nullable<PickingInfo>;
  72055. /**
  72056. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72057. * @param type Defines the type of event (PointerEventTypes)
  72058. * @param event Defines the related dom event
  72059. * @param pickInfo Defines the picking info associated to the info (if any)\
  72060. */
  72061. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72062. /**
  72063. * Defines the picking info associated to the info (if any)\
  72064. */
  72065. pickInfo: Nullable<PickingInfo>);
  72066. }
  72067. /**
  72068. * Data relating to a touch event on the screen.
  72069. */
  72070. export interface PointerTouch {
  72071. /**
  72072. * X coordinate of touch.
  72073. */
  72074. x: number;
  72075. /**
  72076. * Y coordinate of touch.
  72077. */
  72078. y: number;
  72079. /**
  72080. * Id of touch. Unique for each finger.
  72081. */
  72082. pointerId: number;
  72083. /**
  72084. * Event type passed from DOM.
  72085. */
  72086. type: any;
  72087. }
  72088. }
  72089. declare module BABYLON {
  72090. /**
  72091. * Manage the mouse inputs to control the movement of a free camera.
  72092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72093. */
  72094. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72095. /**
  72096. * Define if touch is enabled in the mouse input
  72097. */
  72098. touchEnabled: boolean;
  72099. /**
  72100. * Defines the camera the input is attached to.
  72101. */
  72102. camera: FreeCamera;
  72103. /**
  72104. * Defines the buttons associated with the input to handle camera move.
  72105. */
  72106. buttons: number[];
  72107. /**
  72108. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72109. */
  72110. angularSensibility: number;
  72111. private _pointerInput;
  72112. private _onMouseMove;
  72113. private _observer;
  72114. private previousPosition;
  72115. /**
  72116. * Observable for when a pointer move event occurs containing the move offset
  72117. */
  72118. onPointerMovedObservable: Observable<{
  72119. offsetX: number;
  72120. offsetY: number;
  72121. }>;
  72122. /**
  72123. * @hidden
  72124. * If the camera should be rotated automatically based on pointer movement
  72125. */
  72126. _allowCameraRotation: boolean;
  72127. /**
  72128. * Manage the mouse inputs to control the movement of a free camera.
  72129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72130. * @param touchEnabled Defines if touch is enabled or not
  72131. */
  72132. constructor(
  72133. /**
  72134. * Define if touch is enabled in the mouse input
  72135. */
  72136. touchEnabled?: boolean);
  72137. /**
  72138. * Attach the input controls to a specific dom element to get the input from.
  72139. * @param element Defines the element the controls should be listened from
  72140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72141. */
  72142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72143. /**
  72144. * Called on JS contextmenu event.
  72145. * Override this method to provide functionality.
  72146. */
  72147. protected onContextMenu(evt: PointerEvent): void;
  72148. /**
  72149. * Detach the current controls from the specified dom element.
  72150. * @param element Defines the element to stop listening the inputs from
  72151. */
  72152. detachControl(element: Nullable<HTMLElement>): void;
  72153. /**
  72154. * Gets the class name of the current intput.
  72155. * @returns the class name
  72156. */
  72157. getClassName(): string;
  72158. /**
  72159. * Get the friendly name associated with the input class.
  72160. * @returns the input friendly name
  72161. */
  72162. getSimpleName(): string;
  72163. }
  72164. }
  72165. declare module BABYLON {
  72166. /**
  72167. * Manage the touch inputs to control the movement of a free camera.
  72168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72169. */
  72170. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72171. /**
  72172. * Defines the camera the input is attached to.
  72173. */
  72174. camera: FreeCamera;
  72175. /**
  72176. * Defines the touch sensibility for rotation.
  72177. * The higher the faster.
  72178. */
  72179. touchAngularSensibility: number;
  72180. /**
  72181. * Defines the touch sensibility for move.
  72182. * The higher the faster.
  72183. */
  72184. touchMoveSensibility: number;
  72185. private _offsetX;
  72186. private _offsetY;
  72187. private _pointerPressed;
  72188. private _pointerInput;
  72189. private _observer;
  72190. private _onLostFocus;
  72191. /**
  72192. * Attach the input controls to a specific dom element to get the input from.
  72193. * @param element Defines the element the controls should be listened from
  72194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72195. */
  72196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72197. /**
  72198. * Detach the current controls from the specified dom element.
  72199. * @param element Defines the element to stop listening the inputs from
  72200. */
  72201. detachControl(element: Nullable<HTMLElement>): void;
  72202. /**
  72203. * Update the current camera state depending on the inputs that have been used this frame.
  72204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72205. */
  72206. checkInputs(): void;
  72207. /**
  72208. * Gets the class name of the current intput.
  72209. * @returns the class name
  72210. */
  72211. getClassName(): string;
  72212. /**
  72213. * Get the friendly name associated with the input class.
  72214. * @returns the input friendly name
  72215. */
  72216. getSimpleName(): string;
  72217. }
  72218. }
  72219. declare module BABYLON {
  72220. /**
  72221. * Default Inputs manager for the FreeCamera.
  72222. * It groups all the default supported inputs for ease of use.
  72223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72224. */
  72225. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72226. /**
  72227. * @hidden
  72228. */
  72229. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  72230. /**
  72231. * @hidden
  72232. */
  72233. _mouseInput: Nullable<FreeCameraMouseInput>;
  72234. /**
  72235. * Instantiates a new FreeCameraInputsManager.
  72236. * @param camera Defines the camera the inputs belong to
  72237. */
  72238. constructor(camera: FreeCamera);
  72239. /**
  72240. * Add keyboard input support to the input manager.
  72241. * @returns the current input manager
  72242. */
  72243. addKeyboard(): FreeCameraInputsManager;
  72244. /**
  72245. * Add mouse input support to the input manager.
  72246. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72247. * @returns the current input manager
  72248. */
  72249. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72250. /**
  72251. * Removes the mouse input support from the manager
  72252. * @returns the current input manager
  72253. */
  72254. removeMouse(): FreeCameraInputsManager;
  72255. /**
  72256. * Add touch input support to the input manager.
  72257. * @returns the current input manager
  72258. */
  72259. addTouch(): FreeCameraInputsManager;
  72260. }
  72261. }
  72262. declare module BABYLON {
  72263. /**
  72264. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72265. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72266. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72267. */
  72268. export class FreeCamera extends TargetCamera {
  72269. /**
  72270. * Define the collision ellipsoid of the camera.
  72271. * This is helpful to simulate a camera body like the player body around the camera
  72272. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72273. */
  72274. ellipsoid: Vector3;
  72275. /**
  72276. * Define an offset for the position of the ellipsoid around the camera.
  72277. * This can be helpful to determine the center of the body near the gravity center of the body
  72278. * instead of its head.
  72279. */
  72280. ellipsoidOffset: Vector3;
  72281. /**
  72282. * Enable or disable collisions of the camera with the rest of the scene objects.
  72283. */
  72284. checkCollisions: boolean;
  72285. /**
  72286. * Enable or disable gravity on the camera.
  72287. */
  72288. applyGravity: boolean;
  72289. /**
  72290. * Define the input manager associated to the camera.
  72291. */
  72292. inputs: FreeCameraInputsManager;
  72293. /**
  72294. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72295. * Higher values reduce sensitivity.
  72296. */
  72297. /**
  72298. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72299. * Higher values reduce sensitivity.
  72300. */
  72301. angularSensibility: number;
  72302. /**
  72303. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72304. */
  72305. keysUp: number[];
  72306. /**
  72307. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72308. */
  72309. keysDown: number[];
  72310. /**
  72311. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72312. */
  72313. keysLeft: number[];
  72314. /**
  72315. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72316. */
  72317. keysRight: number[];
  72318. /**
  72319. * Event raised when the camera collide with a mesh in the scene.
  72320. */
  72321. onCollide: (collidedMesh: AbstractMesh) => void;
  72322. private _collider;
  72323. private _needMoveForGravity;
  72324. private _oldPosition;
  72325. private _diffPosition;
  72326. private _newPosition;
  72327. /** @hidden */
  72328. _localDirection: Vector3;
  72329. /** @hidden */
  72330. _transformedDirection: Vector3;
  72331. /**
  72332. * Instantiates a Free Camera.
  72333. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72334. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72335. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72336. * @param name Define the name of the camera in the scene
  72337. * @param position Define the start position of the camera in the scene
  72338. * @param scene Define the scene the camera belongs to
  72339. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72340. */
  72341. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72342. /**
  72343. * Attached controls to the current camera.
  72344. * @param element Defines the element the controls should be listened from
  72345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72346. */
  72347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72348. /**
  72349. * Detach the current controls from the camera.
  72350. * The camera will stop reacting to inputs.
  72351. * @param element Defines the element to stop listening the inputs from
  72352. */
  72353. detachControl(element: HTMLElement): void;
  72354. private _collisionMask;
  72355. /**
  72356. * Define a collision mask to limit the list of object the camera can collide with
  72357. */
  72358. collisionMask: number;
  72359. /** @hidden */
  72360. _collideWithWorld(displacement: Vector3): void;
  72361. private _onCollisionPositionChange;
  72362. /** @hidden */
  72363. _checkInputs(): void;
  72364. /** @hidden */
  72365. _decideIfNeedsToMove(): boolean;
  72366. /** @hidden */
  72367. _updatePosition(): void;
  72368. /**
  72369. * Destroy the camera and release the current resources hold by it.
  72370. */
  72371. dispose(): void;
  72372. /**
  72373. * Gets the current object class name.
  72374. * @return the class name
  72375. */
  72376. getClassName(): string;
  72377. }
  72378. }
  72379. declare module BABYLON {
  72380. /**
  72381. * Represents a gamepad control stick position
  72382. */
  72383. export class StickValues {
  72384. /**
  72385. * The x component of the control stick
  72386. */
  72387. x: number;
  72388. /**
  72389. * The y component of the control stick
  72390. */
  72391. y: number;
  72392. /**
  72393. * Initializes the gamepad x and y control stick values
  72394. * @param x The x component of the gamepad control stick value
  72395. * @param y The y component of the gamepad control stick value
  72396. */
  72397. constructor(
  72398. /**
  72399. * The x component of the control stick
  72400. */
  72401. x: number,
  72402. /**
  72403. * The y component of the control stick
  72404. */
  72405. y: number);
  72406. }
  72407. /**
  72408. * An interface which manages callbacks for gamepad button changes
  72409. */
  72410. export interface GamepadButtonChanges {
  72411. /**
  72412. * Called when a gamepad has been changed
  72413. */
  72414. changed: boolean;
  72415. /**
  72416. * Called when a gamepad press event has been triggered
  72417. */
  72418. pressChanged: boolean;
  72419. /**
  72420. * Called when a touch event has been triggered
  72421. */
  72422. touchChanged: boolean;
  72423. /**
  72424. * Called when a value has changed
  72425. */
  72426. valueChanged: boolean;
  72427. }
  72428. /**
  72429. * Represents a gamepad
  72430. */
  72431. export class Gamepad {
  72432. /**
  72433. * The id of the gamepad
  72434. */
  72435. id: string;
  72436. /**
  72437. * The index of the gamepad
  72438. */
  72439. index: number;
  72440. /**
  72441. * The browser gamepad
  72442. */
  72443. browserGamepad: any;
  72444. /**
  72445. * Specifies what type of gamepad this represents
  72446. */
  72447. type: number;
  72448. private _leftStick;
  72449. private _rightStick;
  72450. /** @hidden */
  72451. _isConnected: boolean;
  72452. private _leftStickAxisX;
  72453. private _leftStickAxisY;
  72454. private _rightStickAxisX;
  72455. private _rightStickAxisY;
  72456. /**
  72457. * Triggered when the left control stick has been changed
  72458. */
  72459. private _onleftstickchanged;
  72460. /**
  72461. * Triggered when the right control stick has been changed
  72462. */
  72463. private _onrightstickchanged;
  72464. /**
  72465. * Represents a gamepad controller
  72466. */
  72467. static GAMEPAD: number;
  72468. /**
  72469. * Represents a generic controller
  72470. */
  72471. static GENERIC: number;
  72472. /**
  72473. * Represents an XBox controller
  72474. */
  72475. static XBOX: number;
  72476. /**
  72477. * Represents a pose-enabled controller
  72478. */
  72479. static POSE_ENABLED: number;
  72480. /**
  72481. * Specifies whether the left control stick should be Y-inverted
  72482. */
  72483. protected _invertLeftStickY: boolean;
  72484. /**
  72485. * Specifies if the gamepad has been connected
  72486. */
  72487. readonly isConnected: boolean;
  72488. /**
  72489. * Initializes the gamepad
  72490. * @param id The id of the gamepad
  72491. * @param index The index of the gamepad
  72492. * @param browserGamepad The browser gamepad
  72493. * @param leftStickX The x component of the left joystick
  72494. * @param leftStickY The y component of the left joystick
  72495. * @param rightStickX The x component of the right joystick
  72496. * @param rightStickY The y component of the right joystick
  72497. */
  72498. constructor(
  72499. /**
  72500. * The id of the gamepad
  72501. */
  72502. id: string,
  72503. /**
  72504. * The index of the gamepad
  72505. */
  72506. index: number,
  72507. /**
  72508. * The browser gamepad
  72509. */
  72510. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72511. /**
  72512. * Callback triggered when the left joystick has changed
  72513. * @param callback
  72514. */
  72515. onleftstickchanged(callback: (values: StickValues) => void): void;
  72516. /**
  72517. * Callback triggered when the right joystick has changed
  72518. * @param callback
  72519. */
  72520. onrightstickchanged(callback: (values: StickValues) => void): void;
  72521. /**
  72522. * Gets the left joystick
  72523. */
  72524. /**
  72525. * Sets the left joystick values
  72526. */
  72527. leftStick: StickValues;
  72528. /**
  72529. * Gets the right joystick
  72530. */
  72531. /**
  72532. * Sets the right joystick value
  72533. */
  72534. rightStick: StickValues;
  72535. /**
  72536. * Updates the gamepad joystick positions
  72537. */
  72538. update(): void;
  72539. /**
  72540. * Disposes the gamepad
  72541. */
  72542. dispose(): void;
  72543. }
  72544. /**
  72545. * Represents a generic gamepad
  72546. */
  72547. export class GenericPad extends Gamepad {
  72548. private _buttons;
  72549. private _onbuttondown;
  72550. private _onbuttonup;
  72551. /**
  72552. * Observable triggered when a button has been pressed
  72553. */
  72554. onButtonDownObservable: Observable<number>;
  72555. /**
  72556. * Observable triggered when a button has been released
  72557. */
  72558. onButtonUpObservable: Observable<number>;
  72559. /**
  72560. * Callback triggered when a button has been pressed
  72561. * @param callback Called when a button has been pressed
  72562. */
  72563. onbuttondown(callback: (buttonPressed: number) => void): void;
  72564. /**
  72565. * Callback triggered when a button has been released
  72566. * @param callback Called when a button has been released
  72567. */
  72568. onbuttonup(callback: (buttonReleased: number) => void): void;
  72569. /**
  72570. * Initializes the generic gamepad
  72571. * @param id The id of the generic gamepad
  72572. * @param index The index of the generic gamepad
  72573. * @param browserGamepad The browser gamepad
  72574. */
  72575. constructor(id: string, index: number, browserGamepad: any);
  72576. private _setButtonValue;
  72577. /**
  72578. * Updates the generic gamepad
  72579. */
  72580. update(): void;
  72581. /**
  72582. * Disposes the generic gamepad
  72583. */
  72584. dispose(): void;
  72585. }
  72586. }
  72587. declare module BABYLON {
  72588. /**
  72589. * Defines the types of pose enabled controllers that are supported
  72590. */
  72591. export enum PoseEnabledControllerType {
  72592. /**
  72593. * HTC Vive
  72594. */
  72595. VIVE = 0,
  72596. /**
  72597. * Oculus Rift
  72598. */
  72599. OCULUS = 1,
  72600. /**
  72601. * Windows mixed reality
  72602. */
  72603. WINDOWS = 2,
  72604. /**
  72605. * Samsung gear VR
  72606. */
  72607. GEAR_VR = 3,
  72608. /**
  72609. * Google Daydream
  72610. */
  72611. DAYDREAM = 4,
  72612. /**
  72613. * Generic
  72614. */
  72615. GENERIC = 5
  72616. }
  72617. /**
  72618. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72619. */
  72620. export interface MutableGamepadButton {
  72621. /**
  72622. * Value of the button/trigger
  72623. */
  72624. value: number;
  72625. /**
  72626. * If the button/trigger is currently touched
  72627. */
  72628. touched: boolean;
  72629. /**
  72630. * If the button/trigger is currently pressed
  72631. */
  72632. pressed: boolean;
  72633. }
  72634. /**
  72635. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72636. * @hidden
  72637. */
  72638. export interface ExtendedGamepadButton extends GamepadButton {
  72639. /**
  72640. * If the button/trigger is currently pressed
  72641. */
  72642. readonly pressed: boolean;
  72643. /**
  72644. * If the button/trigger is currently touched
  72645. */
  72646. readonly touched: boolean;
  72647. /**
  72648. * Value of the button/trigger
  72649. */
  72650. readonly value: number;
  72651. }
  72652. /** @hidden */
  72653. export interface _GamePadFactory {
  72654. /**
  72655. * Returns wether or not the current gamepad can be created for this type of controller.
  72656. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72657. * @returns true if it can be created, otherwise false
  72658. */
  72659. canCreate(gamepadInfo: any): boolean;
  72660. /**
  72661. * Creates a new instance of the Gamepad.
  72662. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72663. * @returns the new gamepad instance
  72664. */
  72665. create(gamepadInfo: any): Gamepad;
  72666. }
  72667. /**
  72668. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72669. */
  72670. export class PoseEnabledControllerHelper {
  72671. /** @hidden */
  72672. static _ControllerFactories: _GamePadFactory[];
  72673. /** @hidden */
  72674. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72675. /**
  72676. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72677. * @param vrGamepad the gamepad to initialized
  72678. * @returns a vr controller of the type the gamepad identified as
  72679. */
  72680. static InitiateController(vrGamepad: any): Gamepad;
  72681. }
  72682. /**
  72683. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72684. */
  72685. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72686. private _deviceRoomPosition;
  72687. private _deviceRoomRotationQuaternion;
  72688. /**
  72689. * The device position in babylon space
  72690. */
  72691. devicePosition: Vector3;
  72692. /**
  72693. * The device rotation in babylon space
  72694. */
  72695. deviceRotationQuaternion: Quaternion;
  72696. /**
  72697. * The scale factor of the device in babylon space
  72698. */
  72699. deviceScaleFactor: number;
  72700. /**
  72701. * (Likely devicePosition should be used instead) The device position in its room space
  72702. */
  72703. position: Vector3;
  72704. /**
  72705. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72706. */
  72707. rotationQuaternion: Quaternion;
  72708. /**
  72709. * The type of controller (Eg. Windows mixed reality)
  72710. */
  72711. controllerType: PoseEnabledControllerType;
  72712. protected _calculatedPosition: Vector3;
  72713. private _calculatedRotation;
  72714. /**
  72715. * The raw pose from the device
  72716. */
  72717. rawPose: DevicePose;
  72718. private _trackPosition;
  72719. private _maxRotationDistFromHeadset;
  72720. private _draggedRoomRotation;
  72721. /**
  72722. * @hidden
  72723. */
  72724. _disableTrackPosition(fixedPosition: Vector3): void;
  72725. /**
  72726. * Internal, the mesh attached to the controller
  72727. * @hidden
  72728. */
  72729. _mesh: Nullable<AbstractMesh>;
  72730. private _poseControlledCamera;
  72731. private _leftHandSystemQuaternion;
  72732. /**
  72733. * Internal, matrix used to convert room space to babylon space
  72734. * @hidden
  72735. */
  72736. _deviceToWorld: Matrix;
  72737. /**
  72738. * Node to be used when casting a ray from the controller
  72739. * @hidden
  72740. */
  72741. _pointingPoseNode: Nullable<TransformNode>;
  72742. /**
  72743. * Name of the child mesh that can be used to cast a ray from the controller
  72744. */
  72745. static readonly POINTING_POSE: string;
  72746. /**
  72747. * Creates a new PoseEnabledController from a gamepad
  72748. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72749. */
  72750. constructor(browserGamepad: any);
  72751. private _workingMatrix;
  72752. /**
  72753. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72754. */
  72755. update(): void;
  72756. /**
  72757. * Updates only the pose device and mesh without doing any button event checking
  72758. */
  72759. protected _updatePoseAndMesh(): void;
  72760. /**
  72761. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72762. * @param poseData raw pose fromthe device
  72763. */
  72764. updateFromDevice(poseData: DevicePose): void;
  72765. /**
  72766. * @hidden
  72767. */
  72768. _meshAttachedObservable: Observable<AbstractMesh>;
  72769. /**
  72770. * Attaches a mesh to the controller
  72771. * @param mesh the mesh to be attached
  72772. */
  72773. attachToMesh(mesh: AbstractMesh): void;
  72774. /**
  72775. * Attaches the controllers mesh to a camera
  72776. * @param camera the camera the mesh should be attached to
  72777. */
  72778. attachToPoseControlledCamera(camera: TargetCamera): void;
  72779. /**
  72780. * Disposes of the controller
  72781. */
  72782. dispose(): void;
  72783. /**
  72784. * The mesh that is attached to the controller
  72785. */
  72786. readonly mesh: Nullable<AbstractMesh>;
  72787. /**
  72788. * Gets the ray of the controller in the direction the controller is pointing
  72789. * @param length the length the resulting ray should be
  72790. * @returns a ray in the direction the controller is pointing
  72791. */
  72792. getForwardRay(length?: number): Ray;
  72793. }
  72794. }
  72795. declare module BABYLON {
  72796. /**
  72797. * Defines the WebVRController object that represents controllers tracked in 3D space
  72798. */
  72799. export abstract class WebVRController extends PoseEnabledController {
  72800. /**
  72801. * Internal, the default controller model for the controller
  72802. */
  72803. protected _defaultModel: AbstractMesh;
  72804. /**
  72805. * Fired when the trigger state has changed
  72806. */
  72807. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72808. /**
  72809. * Fired when the main button state has changed
  72810. */
  72811. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72812. /**
  72813. * Fired when the secondary button state has changed
  72814. */
  72815. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72816. /**
  72817. * Fired when the pad state has changed
  72818. */
  72819. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72820. /**
  72821. * Fired when controllers stick values have changed
  72822. */
  72823. onPadValuesChangedObservable: Observable<StickValues>;
  72824. /**
  72825. * Array of button availible on the controller
  72826. */
  72827. protected _buttons: Array<MutableGamepadButton>;
  72828. private _onButtonStateChange;
  72829. /**
  72830. * Fired when a controller button's state has changed
  72831. * @param callback the callback containing the button that was modified
  72832. */
  72833. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72834. /**
  72835. * X and Y axis corrisponding to the controllers joystick
  72836. */
  72837. pad: StickValues;
  72838. /**
  72839. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72840. */
  72841. hand: string;
  72842. /**
  72843. * The default controller model for the controller
  72844. */
  72845. readonly defaultModel: AbstractMesh;
  72846. /**
  72847. * Creates a new WebVRController from a gamepad
  72848. * @param vrGamepad the gamepad that the WebVRController should be created from
  72849. */
  72850. constructor(vrGamepad: any);
  72851. /**
  72852. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72853. */
  72854. update(): void;
  72855. /**
  72856. * Function to be called when a button is modified
  72857. */
  72858. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72859. /**
  72860. * Loads a mesh and attaches it to the controller
  72861. * @param scene the scene the mesh should be added to
  72862. * @param meshLoaded callback for when the mesh has been loaded
  72863. */
  72864. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72865. private _setButtonValue;
  72866. private _changes;
  72867. private _checkChanges;
  72868. /**
  72869. * Disposes of th webVRCOntroller
  72870. */
  72871. dispose(): void;
  72872. }
  72873. }
  72874. declare module BABYLON {
  72875. /**
  72876. * The HemisphericLight simulates the ambient environment light,
  72877. * so the passed direction is the light reflection direction, not the incoming direction.
  72878. */
  72879. export class HemisphericLight extends Light {
  72880. /**
  72881. * The groundColor is the light in the opposite direction to the one specified during creation.
  72882. * 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.
  72883. */
  72884. groundColor: Color3;
  72885. /**
  72886. * The light reflection direction, not the incoming direction.
  72887. */
  72888. direction: Vector3;
  72889. /**
  72890. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72891. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72892. * The HemisphericLight can't cast shadows.
  72893. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72894. * @param name The friendly name of the light
  72895. * @param direction The direction of the light reflection
  72896. * @param scene The scene the light belongs to
  72897. */
  72898. constructor(name: string, direction: Vector3, scene: Scene);
  72899. protected _buildUniformLayout(): void;
  72900. /**
  72901. * Returns the string "HemisphericLight".
  72902. * @return The class name
  72903. */
  72904. getClassName(): string;
  72905. /**
  72906. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72907. * Returns the updated direction.
  72908. * @param target The target the direction should point to
  72909. * @return The computed direction
  72910. */
  72911. setDirectionToTarget(target: Vector3): Vector3;
  72912. /**
  72913. * Returns the shadow generator associated to the light.
  72914. * @returns Always null for hemispheric lights because it does not support shadows.
  72915. */
  72916. getShadowGenerator(): Nullable<IShadowGenerator>;
  72917. /**
  72918. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72919. * @param effect The effect to update
  72920. * @param lightIndex The index of the light in the effect to update
  72921. * @returns The hemispheric light
  72922. */
  72923. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72924. /**
  72925. * Computes the world matrix of the node
  72926. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72927. * @param useWasUpdatedFlag defines a reserved property
  72928. * @returns the world matrix
  72929. */
  72930. computeWorldMatrix(): Matrix;
  72931. /**
  72932. * Returns the integer 3.
  72933. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72934. */
  72935. getTypeID(): number;
  72936. /**
  72937. * Prepares the list of defines specific to the light type.
  72938. * @param defines the list of defines
  72939. * @param lightIndex defines the index of the light for the effect
  72940. */
  72941. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72942. }
  72943. }
  72944. declare module BABYLON {
  72945. /** @hidden */
  72946. export var vrMultiviewToSingleviewPixelShader: {
  72947. name: string;
  72948. shader: string;
  72949. };
  72950. }
  72951. declare module BABYLON {
  72952. /**
  72953. * Renders to multiple views with a single draw call
  72954. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72955. */
  72956. export class MultiviewRenderTarget extends RenderTargetTexture {
  72957. /**
  72958. * Creates a multiview render target
  72959. * @param scene scene used with the render target
  72960. * @param size the size of the render target (used for each view)
  72961. */
  72962. constructor(scene: Scene, size?: number | {
  72963. width: number;
  72964. height: number;
  72965. } | {
  72966. ratio: number;
  72967. });
  72968. /**
  72969. * @hidden
  72970. * @param faceIndex the face index, if its a cube texture
  72971. */
  72972. _bindFrameBuffer(faceIndex?: number): void;
  72973. /**
  72974. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72975. * @returns the view count
  72976. */
  72977. getViewCount(): number;
  72978. }
  72979. }
  72980. declare module BABYLON {
  72981. interface Engine {
  72982. /**
  72983. * Creates a new multiview render target
  72984. * @param width defines the width of the texture
  72985. * @param height defines the height of the texture
  72986. * @returns the created multiview texture
  72987. */
  72988. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72989. /**
  72990. * Binds a multiview framebuffer to be drawn to
  72991. * @param multiviewTexture texture to bind
  72992. */
  72993. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72994. }
  72995. interface Camera {
  72996. /**
  72997. * @hidden
  72998. * 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)
  72999. */
  73000. _useMultiviewToSingleView: boolean;
  73001. /**
  73002. * @hidden
  73003. * 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)
  73004. */
  73005. _multiviewTexture: Nullable<RenderTargetTexture>;
  73006. /**
  73007. * @hidden
  73008. * ensures the multiview texture of the camera exists and has the specified width/height
  73009. * @param width height to set on the multiview texture
  73010. * @param height width to set on the multiview texture
  73011. */
  73012. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73013. }
  73014. interface Scene {
  73015. /** @hidden */
  73016. _transformMatrixR: Matrix;
  73017. /** @hidden */
  73018. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73019. /** @hidden */
  73020. _createMultiviewUbo(): void;
  73021. /** @hidden */
  73022. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73023. /** @hidden */
  73024. _renderMultiviewToSingleView(camera: Camera): void;
  73025. }
  73026. }
  73027. declare module BABYLON {
  73028. /**
  73029. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73030. * This will not be used for webXR as it supports displaying texture arrays directly
  73031. */
  73032. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73033. /**
  73034. * Initializes a VRMultiviewToSingleview
  73035. * @param name name of the post process
  73036. * @param camera camera to be applied to
  73037. * @param scaleFactor scaling factor to the size of the output texture
  73038. */
  73039. constructor(name: string, camera: Camera, scaleFactor: number);
  73040. }
  73041. }
  73042. declare module BABYLON {
  73043. /**
  73044. * Defines the interface used by display changed events
  73045. */
  73046. interface IDisplayChangedEventArgs {
  73047. /** Gets the vrDisplay object (if any) */
  73048. vrDisplay: Nullable<any>;
  73049. /** Gets a boolean indicating if webVR is supported */
  73050. vrSupported: boolean;
  73051. }
  73052. interface Engine {
  73053. /** @hidden */
  73054. _vrDisplay: any;
  73055. /** @hidden */
  73056. _vrSupported: boolean;
  73057. /** @hidden */
  73058. _oldSize: Size;
  73059. /** @hidden */
  73060. _oldHardwareScaleFactor: number;
  73061. /** @hidden */
  73062. _vrExclusivePointerMode: boolean;
  73063. /** @hidden */
  73064. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73065. /** @hidden */
  73066. _onVRDisplayPointerRestricted: () => void;
  73067. /** @hidden */
  73068. _onVRDisplayPointerUnrestricted: () => void;
  73069. /** @hidden */
  73070. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73071. /** @hidden */
  73072. _onVrDisplayDisconnect: Nullable<() => void>;
  73073. /** @hidden */
  73074. _onVrDisplayPresentChange: Nullable<() => void>;
  73075. /**
  73076. * Observable signaled when VR display mode changes
  73077. */
  73078. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73079. /**
  73080. * Observable signaled when VR request present is complete
  73081. */
  73082. onVRRequestPresentComplete: Observable<boolean>;
  73083. /**
  73084. * Observable signaled when VR request present starts
  73085. */
  73086. onVRRequestPresentStart: Observable<Engine>;
  73087. /**
  73088. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73089. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73090. */
  73091. isInVRExclusivePointerMode: boolean;
  73092. /**
  73093. * Gets a boolean indicating if a webVR device was detected
  73094. * @returns true if a webVR device was detected
  73095. */
  73096. isVRDevicePresent(): boolean;
  73097. /**
  73098. * Gets the current webVR device
  73099. * @returns the current webVR device (or null)
  73100. */
  73101. getVRDevice(): any;
  73102. /**
  73103. * Initializes a webVR display and starts listening to display change events
  73104. * The onVRDisplayChangedObservable will be notified upon these changes
  73105. * @returns A promise containing a VRDisplay and if vr is supported
  73106. */
  73107. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73108. /** @hidden */
  73109. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73110. /**
  73111. * Call this function to switch to webVR mode
  73112. * Will do nothing if webVR is not supported or if there is no webVR device
  73113. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73114. */
  73115. enableVR(): void;
  73116. /** @hidden */
  73117. _onVRFullScreenTriggered(): void;
  73118. }
  73119. }
  73120. declare module BABYLON {
  73121. /**
  73122. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73123. * IMPORTANT!! The data is right-hand data.
  73124. * @export
  73125. * @interface DevicePose
  73126. */
  73127. export interface DevicePose {
  73128. /**
  73129. * The position of the device, values in array are [x,y,z].
  73130. */
  73131. readonly position: Nullable<Float32Array>;
  73132. /**
  73133. * The linearVelocity of the device, values in array are [x,y,z].
  73134. */
  73135. readonly linearVelocity: Nullable<Float32Array>;
  73136. /**
  73137. * The linearAcceleration of the device, values in array are [x,y,z].
  73138. */
  73139. readonly linearAcceleration: Nullable<Float32Array>;
  73140. /**
  73141. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73142. */
  73143. readonly orientation: Nullable<Float32Array>;
  73144. /**
  73145. * The angularVelocity of the device, values in array are [x,y,z].
  73146. */
  73147. readonly angularVelocity: Nullable<Float32Array>;
  73148. /**
  73149. * The angularAcceleration of the device, values in array are [x,y,z].
  73150. */
  73151. readonly angularAcceleration: Nullable<Float32Array>;
  73152. }
  73153. /**
  73154. * Interface representing a pose controlled object in Babylon.
  73155. * A pose controlled object has both regular pose values as well as pose values
  73156. * from an external device such as a VR head mounted display
  73157. */
  73158. export interface PoseControlled {
  73159. /**
  73160. * The position of the object in babylon space.
  73161. */
  73162. position: Vector3;
  73163. /**
  73164. * The rotation quaternion of the object in babylon space.
  73165. */
  73166. rotationQuaternion: Quaternion;
  73167. /**
  73168. * The position of the device in babylon space.
  73169. */
  73170. devicePosition?: Vector3;
  73171. /**
  73172. * The rotation quaternion of the device in babylon space.
  73173. */
  73174. deviceRotationQuaternion: Quaternion;
  73175. /**
  73176. * The raw pose coming from the device.
  73177. */
  73178. rawPose: Nullable<DevicePose>;
  73179. /**
  73180. * The scale of the device to be used when translating from device space to babylon space.
  73181. */
  73182. deviceScaleFactor: number;
  73183. /**
  73184. * Updates the poseControlled values based on the input device pose.
  73185. * @param poseData the pose data to update the object with
  73186. */
  73187. updateFromDevice(poseData: DevicePose): void;
  73188. }
  73189. /**
  73190. * Set of options to customize the webVRCamera
  73191. */
  73192. export interface WebVROptions {
  73193. /**
  73194. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73195. */
  73196. trackPosition?: boolean;
  73197. /**
  73198. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73199. */
  73200. positionScale?: number;
  73201. /**
  73202. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73203. */
  73204. displayName?: string;
  73205. /**
  73206. * Should the native controller meshes be initialized. (default: true)
  73207. */
  73208. controllerMeshes?: boolean;
  73209. /**
  73210. * Creating a default HemiLight only on controllers. (default: true)
  73211. */
  73212. defaultLightingOnControllers?: boolean;
  73213. /**
  73214. * If you don't want to use the default VR button of the helper. (default: false)
  73215. */
  73216. useCustomVRButton?: boolean;
  73217. /**
  73218. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73219. */
  73220. customVRButton?: HTMLButtonElement;
  73221. /**
  73222. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73223. */
  73224. rayLength?: number;
  73225. /**
  73226. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73227. */
  73228. defaultHeight?: number;
  73229. /**
  73230. * If multiview should be used if availible (default: false)
  73231. */
  73232. useMultiview?: boolean;
  73233. }
  73234. /**
  73235. * This represents a WebVR camera.
  73236. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73237. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73238. */
  73239. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73240. private webVROptions;
  73241. /**
  73242. * @hidden
  73243. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73244. */
  73245. _vrDevice: any;
  73246. /**
  73247. * The rawPose of the vrDevice.
  73248. */
  73249. rawPose: Nullable<DevicePose>;
  73250. private _onVREnabled;
  73251. private _specsVersion;
  73252. private _attached;
  73253. private _frameData;
  73254. protected _descendants: Array<Node>;
  73255. private _deviceRoomPosition;
  73256. /** @hidden */
  73257. _deviceRoomRotationQuaternion: Quaternion;
  73258. private _standingMatrix;
  73259. /**
  73260. * Represents device position in babylon space.
  73261. */
  73262. devicePosition: Vector3;
  73263. /**
  73264. * Represents device rotation in babylon space.
  73265. */
  73266. deviceRotationQuaternion: Quaternion;
  73267. /**
  73268. * The scale of the device to be used when translating from device space to babylon space.
  73269. */
  73270. deviceScaleFactor: number;
  73271. private _deviceToWorld;
  73272. private _worldToDevice;
  73273. /**
  73274. * References to the webVR controllers for the vrDevice.
  73275. */
  73276. controllers: Array<WebVRController>;
  73277. /**
  73278. * Emits an event when a controller is attached.
  73279. */
  73280. onControllersAttachedObservable: Observable<WebVRController[]>;
  73281. /**
  73282. * Emits an event when a controller's mesh has been loaded;
  73283. */
  73284. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73285. /**
  73286. * Emits an event when the HMD's pose has been updated.
  73287. */
  73288. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73289. private _poseSet;
  73290. /**
  73291. * If the rig cameras be used as parent instead of this camera.
  73292. */
  73293. rigParenting: boolean;
  73294. private _lightOnControllers;
  73295. private _defaultHeight?;
  73296. /**
  73297. * Instantiates a WebVRFreeCamera.
  73298. * @param name The name of the WebVRFreeCamera
  73299. * @param position The starting anchor position for the camera
  73300. * @param scene The scene the camera belongs to
  73301. * @param webVROptions a set of customizable options for the webVRCamera
  73302. */
  73303. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73304. /**
  73305. * Gets the device distance from the ground in meters.
  73306. * @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.
  73307. */
  73308. deviceDistanceToRoomGround(): number;
  73309. /**
  73310. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73311. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73312. */
  73313. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73314. /**
  73315. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73316. * @returns A promise with a boolean set to if the standing matrix is supported.
  73317. */
  73318. useStandingMatrixAsync(): Promise<boolean>;
  73319. /**
  73320. * Disposes the camera
  73321. */
  73322. dispose(): void;
  73323. /**
  73324. * Gets a vrController by name.
  73325. * @param name The name of the controller to retreive
  73326. * @returns the controller matching the name specified or null if not found
  73327. */
  73328. getControllerByName(name: string): Nullable<WebVRController>;
  73329. private _leftController;
  73330. /**
  73331. * The controller corrisponding to the users left hand.
  73332. */
  73333. readonly leftController: Nullable<WebVRController>;
  73334. private _rightController;
  73335. /**
  73336. * The controller corrisponding to the users right hand.
  73337. */
  73338. readonly rightController: Nullable<WebVRController>;
  73339. /**
  73340. * Casts a ray forward from the vrCamera's gaze.
  73341. * @param length Length of the ray (default: 100)
  73342. * @returns the ray corrisponding to the gaze
  73343. */
  73344. getForwardRay(length?: number): Ray;
  73345. /**
  73346. * @hidden
  73347. * Updates the camera based on device's frame data
  73348. */
  73349. _checkInputs(): void;
  73350. /**
  73351. * Updates the poseControlled values based on the input device pose.
  73352. * @param poseData Pose coming from the device
  73353. */
  73354. updateFromDevice(poseData: DevicePose): void;
  73355. private _htmlElementAttached;
  73356. private _detachIfAttached;
  73357. /**
  73358. * WebVR's attach control will start broadcasting frames to the device.
  73359. * Note that in certain browsers (chrome for example) this function must be called
  73360. * within a user-interaction callback. Example:
  73361. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73362. *
  73363. * @param element html element to attach the vrDevice to
  73364. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73365. */
  73366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73367. /**
  73368. * Detaches the camera from the html element and disables VR
  73369. *
  73370. * @param element html element to detach from
  73371. */
  73372. detachControl(element: HTMLElement): void;
  73373. /**
  73374. * @returns the name of this class
  73375. */
  73376. getClassName(): string;
  73377. /**
  73378. * Calls resetPose on the vrDisplay
  73379. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73380. */
  73381. resetToCurrentRotation(): void;
  73382. /**
  73383. * @hidden
  73384. * Updates the rig cameras (left and right eye)
  73385. */
  73386. _updateRigCameras(): void;
  73387. private _workingVector;
  73388. private _oneVector;
  73389. private _workingMatrix;
  73390. private updateCacheCalled;
  73391. private _correctPositionIfNotTrackPosition;
  73392. /**
  73393. * @hidden
  73394. * Updates the cached values of the camera
  73395. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73396. */
  73397. _updateCache(ignoreParentClass?: boolean): void;
  73398. /**
  73399. * @hidden
  73400. * Get current device position in babylon world
  73401. */
  73402. _computeDevicePosition(): void;
  73403. /**
  73404. * Updates the current device position and rotation in the babylon world
  73405. */
  73406. update(): void;
  73407. /**
  73408. * @hidden
  73409. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73410. * @returns an identity matrix
  73411. */
  73412. _getViewMatrix(): Matrix;
  73413. private _tmpMatrix;
  73414. /**
  73415. * This function is called by the two RIG cameras.
  73416. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73417. * @hidden
  73418. */
  73419. _getWebVRViewMatrix(): Matrix;
  73420. /** @hidden */
  73421. _getWebVRProjectionMatrix(): Matrix;
  73422. private _onGamepadConnectedObserver;
  73423. private _onGamepadDisconnectedObserver;
  73424. private _updateCacheWhenTrackingDisabledObserver;
  73425. /**
  73426. * Initializes the controllers and their meshes
  73427. */
  73428. initControllers(): void;
  73429. }
  73430. }
  73431. declare module BABYLON {
  73432. /**
  73433. * Size options for a post process
  73434. */
  73435. export type PostProcessOptions = {
  73436. width: number;
  73437. height: number;
  73438. };
  73439. /**
  73440. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73441. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73442. */
  73443. export class PostProcess {
  73444. /** Name of the PostProcess. */
  73445. name: string;
  73446. /**
  73447. * Gets or sets the unique id of the post process
  73448. */
  73449. uniqueId: number;
  73450. /**
  73451. * Width of the texture to apply the post process on
  73452. */
  73453. width: number;
  73454. /**
  73455. * Height of the texture to apply the post process on
  73456. */
  73457. height: number;
  73458. /**
  73459. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73460. * @hidden
  73461. */
  73462. _outputTexture: Nullable<InternalTexture>;
  73463. /**
  73464. * Sampling mode used by the shader
  73465. * See https://doc.babylonjs.com/classes/3.1/texture
  73466. */
  73467. renderTargetSamplingMode: number;
  73468. /**
  73469. * Clear color to use when screen clearing
  73470. */
  73471. clearColor: Color4;
  73472. /**
  73473. * If the buffer needs to be cleared before applying the post process. (default: true)
  73474. * Should be set to false if shader will overwrite all previous pixels.
  73475. */
  73476. autoClear: boolean;
  73477. /**
  73478. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73479. */
  73480. alphaMode: number;
  73481. /**
  73482. * Sets the setAlphaBlendConstants of the babylon engine
  73483. */
  73484. alphaConstants: Color4;
  73485. /**
  73486. * Animations to be used for the post processing
  73487. */
  73488. animations: Animation[];
  73489. /**
  73490. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73491. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73492. */
  73493. enablePixelPerfectMode: boolean;
  73494. /**
  73495. * Force the postprocess to be applied without taking in account viewport
  73496. */
  73497. forceFullscreenViewport: boolean;
  73498. /**
  73499. * List of inspectable custom properties (used by the Inspector)
  73500. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73501. */
  73502. inspectableCustomProperties: IInspectable[];
  73503. /**
  73504. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73505. *
  73506. * | Value | Type | Description |
  73507. * | ----- | ----------------------------------- | ----------- |
  73508. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73509. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73510. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73511. *
  73512. */
  73513. scaleMode: number;
  73514. /**
  73515. * Force textures to be a power of two (default: false)
  73516. */
  73517. alwaysForcePOT: boolean;
  73518. private _samples;
  73519. /**
  73520. * Number of sample textures (default: 1)
  73521. */
  73522. samples: number;
  73523. /**
  73524. * Modify the scale of the post process to be the same as the viewport (default: false)
  73525. */
  73526. adaptScaleToCurrentViewport: boolean;
  73527. private _camera;
  73528. private _scene;
  73529. private _engine;
  73530. private _options;
  73531. private _reusable;
  73532. private _textureType;
  73533. /**
  73534. * Smart array of input and output textures for the post process.
  73535. * @hidden
  73536. */
  73537. _textures: SmartArray<InternalTexture>;
  73538. /**
  73539. * The index in _textures that corresponds to the output texture.
  73540. * @hidden
  73541. */
  73542. _currentRenderTextureInd: number;
  73543. private _effect;
  73544. private _samplers;
  73545. private _fragmentUrl;
  73546. private _vertexUrl;
  73547. private _parameters;
  73548. private _scaleRatio;
  73549. protected _indexParameters: any;
  73550. private _shareOutputWithPostProcess;
  73551. private _texelSize;
  73552. private _forcedOutputTexture;
  73553. /**
  73554. * Returns the fragment url or shader name used in the post process.
  73555. * @returns the fragment url or name in the shader store.
  73556. */
  73557. getEffectName(): string;
  73558. /**
  73559. * An event triggered when the postprocess is activated.
  73560. */
  73561. onActivateObservable: Observable<Camera>;
  73562. private _onActivateObserver;
  73563. /**
  73564. * A function that is added to the onActivateObservable
  73565. */
  73566. onActivate: Nullable<(camera: Camera) => void>;
  73567. /**
  73568. * An event triggered when the postprocess changes its size.
  73569. */
  73570. onSizeChangedObservable: Observable<PostProcess>;
  73571. private _onSizeChangedObserver;
  73572. /**
  73573. * A function that is added to the onSizeChangedObservable
  73574. */
  73575. onSizeChanged: (postProcess: PostProcess) => void;
  73576. /**
  73577. * An event triggered when the postprocess applies its effect.
  73578. */
  73579. onApplyObservable: Observable<Effect>;
  73580. private _onApplyObserver;
  73581. /**
  73582. * A function that is added to the onApplyObservable
  73583. */
  73584. onApply: (effect: Effect) => void;
  73585. /**
  73586. * An event triggered before rendering the postprocess
  73587. */
  73588. onBeforeRenderObservable: Observable<Effect>;
  73589. private _onBeforeRenderObserver;
  73590. /**
  73591. * A function that is added to the onBeforeRenderObservable
  73592. */
  73593. onBeforeRender: (effect: Effect) => void;
  73594. /**
  73595. * An event triggered after rendering the postprocess
  73596. */
  73597. onAfterRenderObservable: Observable<Effect>;
  73598. private _onAfterRenderObserver;
  73599. /**
  73600. * A function that is added to the onAfterRenderObservable
  73601. */
  73602. onAfterRender: (efect: Effect) => void;
  73603. /**
  73604. * 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
  73605. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73606. */
  73607. inputTexture: InternalTexture;
  73608. /**
  73609. * Gets the camera which post process is applied to.
  73610. * @returns The camera the post process is applied to.
  73611. */
  73612. getCamera(): Camera;
  73613. /**
  73614. * Gets the texel size of the postprocess.
  73615. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73616. */
  73617. readonly texelSize: Vector2;
  73618. /**
  73619. * Creates a new instance PostProcess
  73620. * @param name The name of the PostProcess.
  73621. * @param fragmentUrl The url of the fragment shader to be used.
  73622. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73623. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73624. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73625. * @param camera The camera to apply the render pass to.
  73626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73627. * @param engine The engine which the post process will be applied. (default: current engine)
  73628. * @param reusable If the post process can be reused on the same frame. (default: false)
  73629. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73630. * @param textureType Type of textures used when performing the post process. (default: 0)
  73631. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73632. * @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
  73633. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73634. */
  73635. constructor(
  73636. /** Name of the PostProcess. */
  73637. 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);
  73638. /**
  73639. * Gets a string idenfifying the name of the class
  73640. * @returns "PostProcess" string
  73641. */
  73642. getClassName(): string;
  73643. /**
  73644. * Gets the engine which this post process belongs to.
  73645. * @returns The engine the post process was enabled with.
  73646. */
  73647. getEngine(): Engine;
  73648. /**
  73649. * The effect that is created when initializing the post process.
  73650. * @returns The created effect corrisponding the the postprocess.
  73651. */
  73652. getEffect(): Effect;
  73653. /**
  73654. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73655. * @param postProcess The post process to share the output with.
  73656. * @returns This post process.
  73657. */
  73658. shareOutputWith(postProcess: PostProcess): PostProcess;
  73659. /**
  73660. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73661. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73662. */
  73663. useOwnOutput(): void;
  73664. /**
  73665. * Updates the effect with the current post process compile time values and recompiles the shader.
  73666. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73667. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73668. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73669. * @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
  73670. * @param onCompiled Called when the shader has been compiled.
  73671. * @param onError Called if there is an error when compiling a shader.
  73672. */
  73673. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73674. /**
  73675. * The post process is reusable if it can be used multiple times within one frame.
  73676. * @returns If the post process is reusable
  73677. */
  73678. isReusable(): boolean;
  73679. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73680. markTextureDirty(): void;
  73681. /**
  73682. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73683. * 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.
  73684. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73685. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73686. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73687. * @returns The target texture that was bound to be written to.
  73688. */
  73689. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73690. /**
  73691. * If the post process is supported.
  73692. */
  73693. readonly isSupported: boolean;
  73694. /**
  73695. * The aspect ratio of the output texture.
  73696. */
  73697. readonly aspectRatio: number;
  73698. /**
  73699. * Get a value indicating if the post-process is ready to be used
  73700. * @returns true if the post-process is ready (shader is compiled)
  73701. */
  73702. isReady(): boolean;
  73703. /**
  73704. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73705. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73706. */
  73707. apply(): Nullable<Effect>;
  73708. private _disposeTextures;
  73709. /**
  73710. * Disposes the post process.
  73711. * @param camera The camera to dispose the post process on.
  73712. */
  73713. dispose(camera?: Camera): void;
  73714. }
  73715. }
  73716. declare module BABYLON {
  73717. /**
  73718. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73719. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73720. */
  73721. export class PostProcessManager {
  73722. private _scene;
  73723. private _indexBuffer;
  73724. private _vertexBuffers;
  73725. /**
  73726. * Creates a new instance PostProcess
  73727. * @param scene The scene that the post process is associated with.
  73728. */
  73729. constructor(scene: Scene);
  73730. private _prepareBuffers;
  73731. private _buildIndexBuffer;
  73732. /**
  73733. * Rebuilds the vertex buffers of the manager.
  73734. * @hidden
  73735. */
  73736. _rebuild(): void;
  73737. /**
  73738. * Prepares a frame to be run through a post process.
  73739. * @param sourceTexture The input texture to the post procesess. (default: null)
  73740. * @param postProcesses An array of post processes to be run. (default: null)
  73741. * @returns True if the post processes were able to be run.
  73742. * @hidden
  73743. */
  73744. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73745. /**
  73746. * Manually render a set of post processes to a texture.
  73747. * @param postProcesses An array of post processes to be run.
  73748. * @param targetTexture The target texture to render to.
  73749. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73750. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73751. * @param lodLevel defines which lod of the texture to render to
  73752. */
  73753. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73754. /**
  73755. * Finalize the result of the output of the postprocesses.
  73756. * @param doNotPresent If true the result will not be displayed to the screen.
  73757. * @param targetTexture The target texture to render to.
  73758. * @param faceIndex The index of the face to bind the target texture to.
  73759. * @param postProcesses The array of post processes to render.
  73760. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73761. * @hidden
  73762. */
  73763. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73764. /**
  73765. * Disposes of the post process manager.
  73766. */
  73767. dispose(): void;
  73768. }
  73769. }
  73770. declare module BABYLON {
  73771. interface AbstractScene {
  73772. /**
  73773. * The list of layers (background and foreground) of the scene
  73774. */
  73775. layers: Array<Layer>;
  73776. }
  73777. /**
  73778. * Defines the layer scene component responsible to manage any layers
  73779. * in a given scene.
  73780. */
  73781. export class LayerSceneComponent implements ISceneComponent {
  73782. /**
  73783. * The component name helpfull to identify the component in the list of scene components.
  73784. */
  73785. readonly name: string;
  73786. /**
  73787. * The scene the component belongs to.
  73788. */
  73789. scene: Scene;
  73790. private _engine;
  73791. /**
  73792. * Creates a new instance of the component for the given scene
  73793. * @param scene Defines the scene to register the component in
  73794. */
  73795. constructor(scene: Scene);
  73796. /**
  73797. * Registers the component in a given scene
  73798. */
  73799. register(): void;
  73800. /**
  73801. * Rebuilds the elements related to this component in case of
  73802. * context lost for instance.
  73803. */
  73804. rebuild(): void;
  73805. /**
  73806. * Disposes the component and the associated ressources.
  73807. */
  73808. dispose(): void;
  73809. private _draw;
  73810. private _drawCameraPredicate;
  73811. private _drawCameraBackground;
  73812. private _drawCameraForeground;
  73813. private _drawRenderTargetPredicate;
  73814. private _drawRenderTargetBackground;
  73815. private _drawRenderTargetForeground;
  73816. }
  73817. }
  73818. declare module BABYLON {
  73819. /** @hidden */
  73820. export var layerPixelShader: {
  73821. name: string;
  73822. shader: string;
  73823. };
  73824. }
  73825. declare module BABYLON {
  73826. /** @hidden */
  73827. export var layerVertexShader: {
  73828. name: string;
  73829. shader: string;
  73830. };
  73831. }
  73832. declare module BABYLON {
  73833. /**
  73834. * This represents a full screen 2d layer.
  73835. * This can be useful to display a picture in the background of your scene for instance.
  73836. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73837. */
  73838. export class Layer {
  73839. /**
  73840. * Define the name of the layer.
  73841. */
  73842. name: string;
  73843. /**
  73844. * Define the texture the layer should display.
  73845. */
  73846. texture: Nullable<Texture>;
  73847. /**
  73848. * Is the layer in background or foreground.
  73849. */
  73850. isBackground: boolean;
  73851. /**
  73852. * Define the color of the layer (instead of texture).
  73853. */
  73854. color: Color4;
  73855. /**
  73856. * Define the scale of the layer in order to zoom in out of the texture.
  73857. */
  73858. scale: Vector2;
  73859. /**
  73860. * Define an offset for the layer in order to shift the texture.
  73861. */
  73862. offset: Vector2;
  73863. /**
  73864. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73865. */
  73866. alphaBlendingMode: number;
  73867. /**
  73868. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73869. * Alpha test will not mix with the background color in case of transparency.
  73870. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73871. */
  73872. alphaTest: boolean;
  73873. /**
  73874. * Define a mask to restrict the layer to only some of the scene cameras.
  73875. */
  73876. layerMask: number;
  73877. /**
  73878. * Define the list of render target the layer is visible into.
  73879. */
  73880. renderTargetTextures: RenderTargetTexture[];
  73881. /**
  73882. * Define if the layer is only used in renderTarget or if it also
  73883. * renders in the main frame buffer of the canvas.
  73884. */
  73885. renderOnlyInRenderTargetTextures: boolean;
  73886. private _scene;
  73887. private _vertexBuffers;
  73888. private _indexBuffer;
  73889. private _effect;
  73890. private _alphaTestEffect;
  73891. /**
  73892. * An event triggered when the layer is disposed.
  73893. */
  73894. onDisposeObservable: Observable<Layer>;
  73895. private _onDisposeObserver;
  73896. /**
  73897. * Back compatibility with callback before the onDisposeObservable existed.
  73898. * The set callback will be triggered when the layer has been disposed.
  73899. */
  73900. onDispose: () => void;
  73901. /**
  73902. * An event triggered before rendering the scene
  73903. */
  73904. onBeforeRenderObservable: Observable<Layer>;
  73905. private _onBeforeRenderObserver;
  73906. /**
  73907. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73908. * The set callback will be triggered just before rendering the layer.
  73909. */
  73910. onBeforeRender: () => void;
  73911. /**
  73912. * An event triggered after rendering the scene
  73913. */
  73914. onAfterRenderObservable: Observable<Layer>;
  73915. private _onAfterRenderObserver;
  73916. /**
  73917. * Back compatibility with callback before the onAfterRenderObservable existed.
  73918. * The set callback will be triggered just after rendering the layer.
  73919. */
  73920. onAfterRender: () => void;
  73921. /**
  73922. * Instantiates a new layer.
  73923. * This represents a full screen 2d layer.
  73924. * This can be useful to display a picture in the background of your scene for instance.
  73925. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73926. * @param name Define the name of the layer in the scene
  73927. * @param imgUrl Define the url of the texture to display in the layer
  73928. * @param scene Define the scene the layer belongs to
  73929. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73930. * @param color Defines a color for the layer
  73931. */
  73932. constructor(
  73933. /**
  73934. * Define the name of the layer.
  73935. */
  73936. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73937. private _createIndexBuffer;
  73938. /** @hidden */
  73939. _rebuild(): void;
  73940. /**
  73941. * Renders the layer in the scene.
  73942. */
  73943. render(): void;
  73944. /**
  73945. * Disposes and releases the associated ressources.
  73946. */
  73947. dispose(): void;
  73948. }
  73949. }
  73950. declare module BABYLON {
  73951. interface AbstractScene {
  73952. /**
  73953. * The list of procedural textures added to the scene
  73954. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73955. */
  73956. proceduralTextures: Array<ProceduralTexture>;
  73957. }
  73958. /**
  73959. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73960. * in a given scene.
  73961. */
  73962. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73963. /**
  73964. * The component name helpfull to identify the component in the list of scene components.
  73965. */
  73966. readonly name: string;
  73967. /**
  73968. * The scene the component belongs to.
  73969. */
  73970. scene: Scene;
  73971. /**
  73972. * Creates a new instance of the component for the given scene
  73973. * @param scene Defines the scene to register the component in
  73974. */
  73975. constructor(scene: Scene);
  73976. /**
  73977. * Registers the component in a given scene
  73978. */
  73979. register(): void;
  73980. /**
  73981. * Rebuilds the elements related to this component in case of
  73982. * context lost for instance.
  73983. */
  73984. rebuild(): void;
  73985. /**
  73986. * Disposes the component and the associated ressources.
  73987. */
  73988. dispose(): void;
  73989. private _beforeClear;
  73990. }
  73991. }
  73992. declare module BABYLON {
  73993. interface Engine {
  73994. /**
  73995. * Creates a new render target cube texture
  73996. * @param size defines the size of the texture
  73997. * @param options defines the options used to create the texture
  73998. * @returns a new render target cube texture stored in an InternalTexture
  73999. */
  74000. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74001. }
  74002. }
  74003. declare module BABYLON {
  74004. /** @hidden */
  74005. export var proceduralVertexShader: {
  74006. name: string;
  74007. shader: string;
  74008. };
  74009. }
  74010. declare module BABYLON {
  74011. /**
  74012. * 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.
  74013. * This is the base class of any Procedural texture and contains most of the shareable code.
  74014. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74015. */
  74016. export class ProceduralTexture extends Texture {
  74017. isCube: boolean;
  74018. /**
  74019. * Define if the texture is enabled or not (disabled texture will not render)
  74020. */
  74021. isEnabled: boolean;
  74022. /**
  74023. * Define if the texture must be cleared before rendering (default is true)
  74024. */
  74025. autoClear: boolean;
  74026. /**
  74027. * Callback called when the texture is generated
  74028. */
  74029. onGenerated: () => void;
  74030. /**
  74031. * Event raised when the texture is generated
  74032. */
  74033. onGeneratedObservable: Observable<ProceduralTexture>;
  74034. /** @hidden */
  74035. _generateMipMaps: boolean;
  74036. /** @hidden **/
  74037. _effect: Effect;
  74038. /** @hidden */
  74039. _textures: {
  74040. [key: string]: Texture;
  74041. };
  74042. private _size;
  74043. private _currentRefreshId;
  74044. private _refreshRate;
  74045. private _vertexBuffers;
  74046. private _indexBuffer;
  74047. private _uniforms;
  74048. private _samplers;
  74049. private _fragment;
  74050. private _floats;
  74051. private _ints;
  74052. private _floatsArrays;
  74053. private _colors3;
  74054. private _colors4;
  74055. private _vectors2;
  74056. private _vectors3;
  74057. private _matrices;
  74058. private _fallbackTexture;
  74059. private _fallbackTextureUsed;
  74060. private _engine;
  74061. private _cachedDefines;
  74062. private _contentUpdateId;
  74063. private _contentData;
  74064. /**
  74065. * Instantiates a new procedural texture.
  74066. * 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.
  74067. * This is the base class of any Procedural texture and contains most of the shareable code.
  74068. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74069. * @param name Define the name of the texture
  74070. * @param size Define the size of the texture to create
  74071. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74072. * @param scene Define the scene the texture belongs to
  74073. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74074. * @param generateMipMaps Define if the texture should creates mip maps or not
  74075. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74076. */
  74077. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74078. /**
  74079. * The effect that is created when initializing the post process.
  74080. * @returns The created effect corrisponding the the postprocess.
  74081. */
  74082. getEffect(): Effect;
  74083. /**
  74084. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74085. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74086. */
  74087. getContent(): Nullable<ArrayBufferView>;
  74088. private _createIndexBuffer;
  74089. /** @hidden */
  74090. _rebuild(): void;
  74091. /**
  74092. * Resets the texture in order to recreate its associated resources.
  74093. * This can be called in case of context loss
  74094. */
  74095. reset(): void;
  74096. protected _getDefines(): string;
  74097. /**
  74098. * Is the texture ready to be used ? (rendered at least once)
  74099. * @returns true if ready, otherwise, false.
  74100. */
  74101. isReady(): boolean;
  74102. /**
  74103. * Resets the refresh counter of the texture and start bak from scratch.
  74104. * Could be useful to regenerate the texture if it is setup to render only once.
  74105. */
  74106. resetRefreshCounter(): void;
  74107. /**
  74108. * Set the fragment shader to use in order to render the texture.
  74109. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74110. */
  74111. setFragment(fragment: any): void;
  74112. /**
  74113. * Define the refresh rate of the texture or the rendering frequency.
  74114. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74115. */
  74116. refreshRate: number;
  74117. /** @hidden */
  74118. _shouldRender(): boolean;
  74119. /**
  74120. * Get the size the texture is rendering at.
  74121. * @returns the size (texture is always squared)
  74122. */
  74123. getRenderSize(): number;
  74124. /**
  74125. * Resize the texture to new value.
  74126. * @param size Define the new size the texture should have
  74127. * @param generateMipMaps Define whether the new texture should create mip maps
  74128. */
  74129. resize(size: number, generateMipMaps: boolean): void;
  74130. private _checkUniform;
  74131. /**
  74132. * Set a texture in the shader program used to render.
  74133. * @param name Define the name of the uniform samplers as defined in the shader
  74134. * @param texture Define the texture to bind to this sampler
  74135. * @return the texture itself allowing "fluent" like uniform updates
  74136. */
  74137. setTexture(name: string, texture: Texture): ProceduralTexture;
  74138. /**
  74139. * Set a float in the shader.
  74140. * @param name Define the name of the uniform as defined in the shader
  74141. * @param value Define the value to give to the uniform
  74142. * @return the texture itself allowing "fluent" like uniform updates
  74143. */
  74144. setFloat(name: string, value: number): ProceduralTexture;
  74145. /**
  74146. * Set a int in the shader.
  74147. * @param name Define the name of the uniform as defined in the shader
  74148. * @param value Define the value to give to the uniform
  74149. * @return the texture itself allowing "fluent" like uniform updates
  74150. */
  74151. setInt(name: string, value: number): ProceduralTexture;
  74152. /**
  74153. * Set an array of floats in the shader.
  74154. * @param name Define the name of the uniform as defined in the shader
  74155. * @param value Define the value to give to the uniform
  74156. * @return the texture itself allowing "fluent" like uniform updates
  74157. */
  74158. setFloats(name: string, value: number[]): ProceduralTexture;
  74159. /**
  74160. * Set a vec3 in the shader from a Color3.
  74161. * @param name Define the name of the uniform as defined in the shader
  74162. * @param value Define the value to give to the uniform
  74163. * @return the texture itself allowing "fluent" like uniform updates
  74164. */
  74165. setColor3(name: string, value: Color3): ProceduralTexture;
  74166. /**
  74167. * Set a vec4 in the shader from a Color4.
  74168. * @param name Define the name of the uniform as defined in the shader
  74169. * @param value Define the value to give to the uniform
  74170. * @return the texture itself allowing "fluent" like uniform updates
  74171. */
  74172. setColor4(name: string, value: Color4): ProceduralTexture;
  74173. /**
  74174. * Set a vec2 in the shader from a Vector2.
  74175. * @param name Define the name of the uniform as defined in the shader
  74176. * @param value Define the value to give to the uniform
  74177. * @return the texture itself allowing "fluent" like uniform updates
  74178. */
  74179. setVector2(name: string, value: Vector2): ProceduralTexture;
  74180. /**
  74181. * Set a vec3 in the shader from a Vector3.
  74182. * @param name Define the name of the uniform as defined in the shader
  74183. * @param value Define the value to give to the uniform
  74184. * @return the texture itself allowing "fluent" like uniform updates
  74185. */
  74186. setVector3(name: string, value: Vector3): ProceduralTexture;
  74187. /**
  74188. * Set a mat4 in the shader from a MAtrix.
  74189. * @param name Define the name of the uniform as defined in the shader
  74190. * @param value Define the value to give to the uniform
  74191. * @return the texture itself allowing "fluent" like uniform updates
  74192. */
  74193. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74194. /**
  74195. * Render the texture to its associated render target.
  74196. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74197. */
  74198. render(useCameraPostProcess?: boolean): void;
  74199. /**
  74200. * Clone the texture.
  74201. * @returns the cloned texture
  74202. */
  74203. clone(): ProceduralTexture;
  74204. /**
  74205. * Dispose the texture and release its asoociated resources.
  74206. */
  74207. dispose(): void;
  74208. }
  74209. }
  74210. declare module BABYLON {
  74211. /**
  74212. * This represents the base class for particle system in Babylon.
  74213. * 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.
  74214. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74215. * @example https://doc.babylonjs.com/babylon101/particles
  74216. */
  74217. export class BaseParticleSystem {
  74218. /**
  74219. * Source color is added to the destination color without alpha affecting the result
  74220. */
  74221. static BLENDMODE_ONEONE: number;
  74222. /**
  74223. * Blend current color and particle color using particle’s alpha
  74224. */
  74225. static BLENDMODE_STANDARD: number;
  74226. /**
  74227. * Add current color and particle color multiplied by particle’s alpha
  74228. */
  74229. static BLENDMODE_ADD: number;
  74230. /**
  74231. * Multiply current color with particle color
  74232. */
  74233. static BLENDMODE_MULTIPLY: number;
  74234. /**
  74235. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74236. */
  74237. static BLENDMODE_MULTIPLYADD: number;
  74238. /**
  74239. * List of animations used by the particle system.
  74240. */
  74241. animations: Animation[];
  74242. /**
  74243. * The id of the Particle system.
  74244. */
  74245. id: string;
  74246. /**
  74247. * The friendly name of the Particle system.
  74248. */
  74249. name: string;
  74250. /**
  74251. * The rendering group used by the Particle system to chose when to render.
  74252. */
  74253. renderingGroupId: number;
  74254. /**
  74255. * The emitter represents the Mesh or position we are attaching the particle system to.
  74256. */
  74257. emitter: Nullable<AbstractMesh | Vector3>;
  74258. /**
  74259. * The maximum number of particles to emit per frame
  74260. */
  74261. emitRate: number;
  74262. /**
  74263. * If you want to launch only a few particles at once, that can be done, as well.
  74264. */
  74265. manualEmitCount: number;
  74266. /**
  74267. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74268. */
  74269. updateSpeed: number;
  74270. /**
  74271. * The amount of time the particle system is running (depends of the overall update speed).
  74272. */
  74273. targetStopDuration: number;
  74274. /**
  74275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74276. */
  74277. disposeOnStop: boolean;
  74278. /**
  74279. * Minimum power of emitting particles.
  74280. */
  74281. minEmitPower: number;
  74282. /**
  74283. * Maximum power of emitting particles.
  74284. */
  74285. maxEmitPower: number;
  74286. /**
  74287. * Minimum life time of emitting particles.
  74288. */
  74289. minLifeTime: number;
  74290. /**
  74291. * Maximum life time of emitting particles.
  74292. */
  74293. maxLifeTime: number;
  74294. /**
  74295. * Minimum Size of emitting particles.
  74296. */
  74297. minSize: number;
  74298. /**
  74299. * Maximum Size of emitting particles.
  74300. */
  74301. maxSize: number;
  74302. /**
  74303. * Minimum scale of emitting particles on X axis.
  74304. */
  74305. minScaleX: number;
  74306. /**
  74307. * Maximum scale of emitting particles on X axis.
  74308. */
  74309. maxScaleX: number;
  74310. /**
  74311. * Minimum scale of emitting particles on Y axis.
  74312. */
  74313. minScaleY: number;
  74314. /**
  74315. * Maximum scale of emitting particles on Y axis.
  74316. */
  74317. maxScaleY: number;
  74318. /**
  74319. * Gets or sets the minimal initial rotation in radians.
  74320. */
  74321. minInitialRotation: number;
  74322. /**
  74323. * Gets or sets the maximal initial rotation in radians.
  74324. */
  74325. maxInitialRotation: number;
  74326. /**
  74327. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74328. */
  74329. minAngularSpeed: number;
  74330. /**
  74331. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74332. */
  74333. maxAngularSpeed: number;
  74334. /**
  74335. * The texture used to render each particle. (this can be a spritesheet)
  74336. */
  74337. particleTexture: Nullable<Texture>;
  74338. /**
  74339. * The layer mask we are rendering the particles through.
  74340. */
  74341. layerMask: number;
  74342. /**
  74343. * This can help using your own shader to render the particle system.
  74344. * The according effect will be created
  74345. */
  74346. customShader: any;
  74347. /**
  74348. * By default particle system starts as soon as they are created. This prevents the
  74349. * automatic start to happen and let you decide when to start emitting particles.
  74350. */
  74351. preventAutoStart: boolean;
  74352. private _noiseTexture;
  74353. /**
  74354. * Gets or sets a texture used to add random noise to particle positions
  74355. */
  74356. noiseTexture: Nullable<ProceduralTexture>;
  74357. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74358. noiseStrength: Vector3;
  74359. /**
  74360. * Callback triggered when the particle animation is ending.
  74361. */
  74362. onAnimationEnd: Nullable<() => void>;
  74363. /**
  74364. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74365. */
  74366. blendMode: number;
  74367. /**
  74368. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74369. * to override the particles.
  74370. */
  74371. forceDepthWrite: boolean;
  74372. /** 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 */
  74373. preWarmCycles: number;
  74374. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74375. preWarmStepOffset: number;
  74376. /**
  74377. * 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)
  74378. */
  74379. spriteCellChangeSpeed: number;
  74380. /**
  74381. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74382. */
  74383. startSpriteCellID: number;
  74384. /**
  74385. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74386. */
  74387. endSpriteCellID: number;
  74388. /**
  74389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74390. */
  74391. spriteCellWidth: number;
  74392. /**
  74393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74394. */
  74395. spriteCellHeight: number;
  74396. /**
  74397. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74398. */
  74399. spriteRandomStartCell: boolean;
  74400. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74401. translationPivot: Vector2;
  74402. /** @hidden */
  74403. protected _isAnimationSheetEnabled: boolean;
  74404. /**
  74405. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74406. */
  74407. beginAnimationOnStart: boolean;
  74408. /**
  74409. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74410. */
  74411. beginAnimationFrom: number;
  74412. /**
  74413. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74414. */
  74415. beginAnimationTo: number;
  74416. /**
  74417. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74418. */
  74419. beginAnimationLoop: boolean;
  74420. /**
  74421. * Gets or sets a world offset applied to all particles
  74422. */
  74423. worldOffset: Vector3;
  74424. /**
  74425. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74426. */
  74427. isAnimationSheetEnabled: boolean;
  74428. /**
  74429. * Get hosting scene
  74430. * @returns the scene
  74431. */
  74432. getScene(): Scene;
  74433. /**
  74434. * You can use gravity if you want to give an orientation to your particles.
  74435. */
  74436. gravity: Vector3;
  74437. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74438. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74439. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74440. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74441. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74442. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74443. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74444. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74445. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74446. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74447. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74448. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74449. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74450. /**
  74451. * Defines the delay in milliseconds before starting the system (0 by default)
  74452. */
  74453. startDelay: number;
  74454. /**
  74455. * Gets the current list of drag gradients.
  74456. * You must use addDragGradient and removeDragGradient to udpate this list
  74457. * @returns the list of drag gradients
  74458. */
  74459. getDragGradients(): Nullable<Array<FactorGradient>>;
  74460. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74461. limitVelocityDamping: number;
  74462. /**
  74463. * Gets the current list of limit velocity gradients.
  74464. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74465. * @returns the list of limit velocity gradients
  74466. */
  74467. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74468. /**
  74469. * Gets the current list of color gradients.
  74470. * You must use addColorGradient and removeColorGradient to udpate this list
  74471. * @returns the list of color gradients
  74472. */
  74473. getColorGradients(): Nullable<Array<ColorGradient>>;
  74474. /**
  74475. * Gets the current list of size gradients.
  74476. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74477. * @returns the list of size gradients
  74478. */
  74479. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74480. /**
  74481. * Gets the current list of color remap gradients.
  74482. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74483. * @returns the list of color remap gradients
  74484. */
  74485. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74486. /**
  74487. * Gets the current list of alpha remap gradients.
  74488. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74489. * @returns the list of alpha remap gradients
  74490. */
  74491. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74492. /**
  74493. * Gets the current list of life time gradients.
  74494. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74495. * @returns the list of life time gradients
  74496. */
  74497. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74498. /**
  74499. * Gets the current list of angular speed gradients.
  74500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74501. * @returns the list of angular speed gradients
  74502. */
  74503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74504. /**
  74505. * Gets the current list of velocity gradients.
  74506. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74507. * @returns the list of velocity gradients
  74508. */
  74509. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74510. /**
  74511. * Gets the current list of start size gradients.
  74512. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74513. * @returns the list of start size gradients
  74514. */
  74515. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74516. /**
  74517. * Gets the current list of emit rate gradients.
  74518. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74519. * @returns the list of emit rate gradients
  74520. */
  74521. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74522. /**
  74523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74525. */
  74526. direction1: Vector3;
  74527. /**
  74528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74530. */
  74531. direction2: Vector3;
  74532. /**
  74533. * 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.
  74534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74535. */
  74536. minEmitBox: Vector3;
  74537. /**
  74538. * 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.
  74539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74540. */
  74541. maxEmitBox: Vector3;
  74542. /**
  74543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74544. */
  74545. color1: Color4;
  74546. /**
  74547. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74548. */
  74549. color2: Color4;
  74550. /**
  74551. * Color the particle will have at the end of its lifetime
  74552. */
  74553. colorDead: Color4;
  74554. /**
  74555. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74556. */
  74557. textureMask: Color4;
  74558. /**
  74559. * The particle emitter type defines the emitter used by the particle system.
  74560. * It can be for example box, sphere, or cone...
  74561. */
  74562. particleEmitterType: IParticleEmitterType;
  74563. /** @hidden */
  74564. _isSubEmitter: boolean;
  74565. /**
  74566. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74567. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74568. */
  74569. billboardMode: number;
  74570. protected _isBillboardBased: boolean;
  74571. /**
  74572. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74573. */
  74574. isBillboardBased: boolean;
  74575. /**
  74576. * The scene the particle system belongs to.
  74577. */
  74578. protected _scene: Scene;
  74579. /**
  74580. * Local cache of defines for image processing.
  74581. */
  74582. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74583. /**
  74584. * Default configuration related to image processing available in the standard Material.
  74585. */
  74586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74587. /**
  74588. * Gets the image processing configuration used either in this material.
  74589. */
  74590. /**
  74591. * Sets the Default image processing configuration used either in the this material.
  74592. *
  74593. * If sets to null, the scene one is in use.
  74594. */
  74595. imageProcessingConfiguration: ImageProcessingConfiguration;
  74596. /**
  74597. * Attaches a new image processing configuration to the Standard Material.
  74598. * @param configuration
  74599. */
  74600. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74601. /** @hidden */
  74602. protected _reset(): void;
  74603. /** @hidden */
  74604. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74605. /**
  74606. * Instantiates a particle system.
  74607. * 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.
  74608. * @param name The name of the particle system
  74609. */
  74610. constructor(name: string);
  74611. /**
  74612. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74615. * @returns the emitter
  74616. */
  74617. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74618. /**
  74619. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74620. * @param radius The radius of the hemisphere to emit from
  74621. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74622. * @returns the emitter
  74623. */
  74624. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74625. /**
  74626. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74627. * @param radius The radius of the sphere to emit from
  74628. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74629. * @returns the emitter
  74630. */
  74631. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74632. /**
  74633. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74634. * @param radius The radius of the sphere to emit from
  74635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74637. * @returns the emitter
  74638. */
  74639. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74640. /**
  74641. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74642. * @param radius The radius of the emission cylinder
  74643. * @param height The height of the emission cylinder
  74644. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74645. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74646. * @returns the emitter
  74647. */
  74648. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74649. /**
  74650. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74651. * @param radius The radius of the cylinder to emit from
  74652. * @param height The height of the emission cylinder
  74653. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74656. * @returns the emitter
  74657. */
  74658. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74659. /**
  74660. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74661. * @param radius The radius of the cone to emit from
  74662. * @param angle The base angle of the cone
  74663. * @returns the emitter
  74664. */
  74665. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74666. /**
  74667. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74670. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74671. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74672. * @returns the emitter
  74673. */
  74674. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74675. }
  74676. }
  74677. declare module BABYLON {
  74678. /**
  74679. * Type of sub emitter
  74680. */
  74681. export enum SubEmitterType {
  74682. /**
  74683. * Attached to the particle over it's lifetime
  74684. */
  74685. ATTACHED = 0,
  74686. /**
  74687. * Created when the particle dies
  74688. */
  74689. END = 1
  74690. }
  74691. /**
  74692. * Sub emitter class used to emit particles from an existing particle
  74693. */
  74694. export class SubEmitter {
  74695. /**
  74696. * the particle system to be used by the sub emitter
  74697. */
  74698. particleSystem: ParticleSystem;
  74699. /**
  74700. * Type of the submitter (Default: END)
  74701. */
  74702. type: SubEmitterType;
  74703. /**
  74704. * 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)
  74705. * Note: This only is supported when using an emitter of type Mesh
  74706. */
  74707. inheritDirection: boolean;
  74708. /**
  74709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74710. */
  74711. inheritedVelocityAmount: number;
  74712. /**
  74713. * Creates a sub emitter
  74714. * @param particleSystem the particle system to be used by the sub emitter
  74715. */
  74716. constructor(
  74717. /**
  74718. * the particle system to be used by the sub emitter
  74719. */
  74720. particleSystem: ParticleSystem);
  74721. /**
  74722. * Clones the sub emitter
  74723. * @returns the cloned sub emitter
  74724. */
  74725. clone(): SubEmitter;
  74726. /**
  74727. * Serialize current object to a JSON object
  74728. * @returns the serialized object
  74729. */
  74730. serialize(): any;
  74731. /** @hidden */
  74732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74733. /**
  74734. * Creates a new SubEmitter from a serialized JSON version
  74735. * @param serializationObject defines the JSON object to read from
  74736. * @param scene defines the hosting scene
  74737. * @param rootUrl defines the rootUrl for data loading
  74738. * @returns a new SubEmitter
  74739. */
  74740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74741. /** Release associated resources */
  74742. dispose(): void;
  74743. }
  74744. }
  74745. declare module BABYLON {
  74746. /** @hidden */
  74747. export var clipPlaneFragmentDeclaration: {
  74748. name: string;
  74749. shader: string;
  74750. };
  74751. }
  74752. declare module BABYLON {
  74753. /** @hidden */
  74754. export var imageProcessingDeclaration: {
  74755. name: string;
  74756. shader: string;
  74757. };
  74758. }
  74759. declare module BABYLON {
  74760. /** @hidden */
  74761. export var imageProcessingFunctions: {
  74762. name: string;
  74763. shader: string;
  74764. };
  74765. }
  74766. declare module BABYLON {
  74767. /** @hidden */
  74768. export var clipPlaneFragment: {
  74769. name: string;
  74770. shader: string;
  74771. };
  74772. }
  74773. declare module BABYLON {
  74774. /** @hidden */
  74775. export var particlesPixelShader: {
  74776. name: string;
  74777. shader: string;
  74778. };
  74779. }
  74780. declare module BABYLON {
  74781. /** @hidden */
  74782. export var clipPlaneVertexDeclaration: {
  74783. name: string;
  74784. shader: string;
  74785. };
  74786. }
  74787. declare module BABYLON {
  74788. /** @hidden */
  74789. export var clipPlaneVertex: {
  74790. name: string;
  74791. shader: string;
  74792. };
  74793. }
  74794. declare module BABYLON {
  74795. /** @hidden */
  74796. export var particlesVertexShader: {
  74797. name: string;
  74798. shader: string;
  74799. };
  74800. }
  74801. declare module BABYLON {
  74802. /**
  74803. * This represents a particle system in Babylon.
  74804. * 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.
  74805. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74806. * @example https://doc.babylonjs.com/babylon101/particles
  74807. */
  74808. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74809. /**
  74810. * Billboard mode will only apply to Y axis
  74811. */
  74812. static readonly BILLBOARDMODE_Y: number;
  74813. /**
  74814. * Billboard mode will apply to all axes
  74815. */
  74816. static readonly BILLBOARDMODE_ALL: number;
  74817. /**
  74818. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74819. */
  74820. static readonly BILLBOARDMODE_STRETCHED: number;
  74821. /**
  74822. * This function can be defined to provide custom update for active particles.
  74823. * This function will be called instead of regular update (age, position, color, etc.).
  74824. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74825. */
  74826. updateFunction: (particles: Particle[]) => void;
  74827. private _emitterWorldMatrix;
  74828. /**
  74829. * This function can be defined to specify initial direction for every new particle.
  74830. * It by default use the emitterType defined function
  74831. */
  74832. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74833. /**
  74834. * This function can be defined to specify initial position for every new particle.
  74835. * It by default use the emitterType defined function
  74836. */
  74837. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74838. /**
  74839. * @hidden
  74840. */
  74841. _inheritedVelocityOffset: Vector3;
  74842. /**
  74843. * An event triggered when the system is disposed
  74844. */
  74845. onDisposeObservable: Observable<ParticleSystem>;
  74846. private _onDisposeObserver;
  74847. /**
  74848. * Sets a callback that will be triggered when the system is disposed
  74849. */
  74850. onDispose: () => void;
  74851. private _particles;
  74852. private _epsilon;
  74853. private _capacity;
  74854. private _stockParticles;
  74855. private _newPartsExcess;
  74856. private _vertexData;
  74857. private _vertexBuffer;
  74858. private _vertexBuffers;
  74859. private _spriteBuffer;
  74860. private _indexBuffer;
  74861. private _effect;
  74862. private _customEffect;
  74863. private _cachedDefines;
  74864. private _scaledColorStep;
  74865. private _colorDiff;
  74866. private _scaledDirection;
  74867. private _scaledGravity;
  74868. private _currentRenderId;
  74869. private _alive;
  74870. private _useInstancing;
  74871. private _started;
  74872. private _stopped;
  74873. private _actualFrame;
  74874. private _scaledUpdateSpeed;
  74875. private _vertexBufferSize;
  74876. /** @hidden */
  74877. _currentEmitRateGradient: Nullable<FactorGradient>;
  74878. /** @hidden */
  74879. _currentEmitRate1: number;
  74880. /** @hidden */
  74881. _currentEmitRate2: number;
  74882. /** @hidden */
  74883. _currentStartSizeGradient: Nullable<FactorGradient>;
  74884. /** @hidden */
  74885. _currentStartSize1: number;
  74886. /** @hidden */
  74887. _currentStartSize2: number;
  74888. private readonly _rawTextureWidth;
  74889. private _rampGradientsTexture;
  74890. private _useRampGradients;
  74891. /** Gets or sets a boolean indicating that ramp gradients must be used
  74892. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74893. */
  74894. useRampGradients: boolean;
  74895. /**
  74896. * 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.
  74897. * 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: [])
  74898. */
  74899. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74900. private _subEmitters;
  74901. /**
  74902. * @hidden
  74903. * If the particle systems emitter should be disposed when the particle system is disposed
  74904. */
  74905. _disposeEmitterOnDispose: boolean;
  74906. /**
  74907. * The current active Sub-systems, this property is used by the root particle system only.
  74908. */
  74909. activeSubSystems: Array<ParticleSystem>;
  74910. private _rootParticleSystem;
  74911. /**
  74912. * Gets the current list of active particles
  74913. */
  74914. readonly particles: Particle[];
  74915. /**
  74916. * Returns the string "ParticleSystem"
  74917. * @returns a string containing the class name
  74918. */
  74919. getClassName(): string;
  74920. /**
  74921. * Instantiates a particle system.
  74922. * 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.
  74923. * @param name The name of the particle system
  74924. * @param capacity The max number of particles alive at the same time
  74925. * @param scene The scene the particle system belongs to
  74926. * @param customEffect a custom effect used to change the way particles are rendered by default
  74927. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74928. * @param epsilon Offset used to render the particles
  74929. */
  74930. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74931. private _addFactorGradient;
  74932. private _removeFactorGradient;
  74933. /**
  74934. * Adds a new life time gradient
  74935. * @param gradient defines the gradient to use (between 0 and 1)
  74936. * @param factor defines the life time factor to affect to the specified gradient
  74937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74938. * @returns the current particle system
  74939. */
  74940. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74941. /**
  74942. * Remove a specific life time gradient
  74943. * @param gradient defines the gradient to remove
  74944. * @returns the current particle system
  74945. */
  74946. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74947. /**
  74948. * Adds a new size gradient
  74949. * @param gradient defines the gradient to use (between 0 and 1)
  74950. * @param factor defines the size factor to affect to the specified gradient
  74951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74952. * @returns the current particle system
  74953. */
  74954. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74955. /**
  74956. * Remove a specific size gradient
  74957. * @param gradient defines the gradient to remove
  74958. * @returns the current particle system
  74959. */
  74960. removeSizeGradient(gradient: number): IParticleSystem;
  74961. /**
  74962. * Adds a new color remap gradient
  74963. * @param gradient defines the gradient to use (between 0 and 1)
  74964. * @param min defines the color remap minimal range
  74965. * @param max defines the color remap maximal range
  74966. * @returns the current particle system
  74967. */
  74968. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74969. /**
  74970. * Remove a specific color remap gradient
  74971. * @param gradient defines the gradient to remove
  74972. * @returns the current particle system
  74973. */
  74974. removeColorRemapGradient(gradient: number): IParticleSystem;
  74975. /**
  74976. * Adds a new alpha remap gradient
  74977. * @param gradient defines the gradient to use (between 0 and 1)
  74978. * @param min defines the alpha remap minimal range
  74979. * @param max defines the alpha remap maximal range
  74980. * @returns the current particle system
  74981. */
  74982. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74983. /**
  74984. * Remove a specific alpha remap gradient
  74985. * @param gradient defines the gradient to remove
  74986. * @returns the current particle system
  74987. */
  74988. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74989. /**
  74990. * Adds a new angular speed gradient
  74991. * @param gradient defines the gradient to use (between 0 and 1)
  74992. * @param factor defines the angular speed to affect to the specified gradient
  74993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74994. * @returns the current particle system
  74995. */
  74996. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74997. /**
  74998. * Remove a specific angular speed gradient
  74999. * @param gradient defines the gradient to remove
  75000. * @returns the current particle system
  75001. */
  75002. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75003. /**
  75004. * Adds a new velocity gradient
  75005. * @param gradient defines the gradient to use (between 0 and 1)
  75006. * @param factor defines the velocity to affect to the specified gradient
  75007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75008. * @returns the current particle system
  75009. */
  75010. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75011. /**
  75012. * Remove a specific velocity gradient
  75013. * @param gradient defines the gradient to remove
  75014. * @returns the current particle system
  75015. */
  75016. removeVelocityGradient(gradient: number): IParticleSystem;
  75017. /**
  75018. * Adds a new limit velocity gradient
  75019. * @param gradient defines the gradient to use (between 0 and 1)
  75020. * @param factor defines the limit velocity value to affect to the specified gradient
  75021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75022. * @returns the current particle system
  75023. */
  75024. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75025. /**
  75026. * Remove a specific limit velocity gradient
  75027. * @param gradient defines the gradient to remove
  75028. * @returns the current particle system
  75029. */
  75030. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75031. /**
  75032. * Adds a new drag gradient
  75033. * @param gradient defines the gradient to use (between 0 and 1)
  75034. * @param factor defines the drag value to affect to the specified gradient
  75035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75036. * @returns the current particle system
  75037. */
  75038. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75039. /**
  75040. * Remove a specific drag gradient
  75041. * @param gradient defines the gradient to remove
  75042. * @returns the current particle system
  75043. */
  75044. removeDragGradient(gradient: number): IParticleSystem;
  75045. /**
  75046. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75047. * @param gradient defines the gradient to use (between 0 and 1)
  75048. * @param factor defines the emit rate value to affect to the specified gradient
  75049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75050. * @returns the current particle system
  75051. */
  75052. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75053. /**
  75054. * Remove a specific emit rate gradient
  75055. * @param gradient defines the gradient to remove
  75056. * @returns the current particle system
  75057. */
  75058. removeEmitRateGradient(gradient: number): IParticleSystem;
  75059. /**
  75060. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75061. * @param gradient defines the gradient to use (between 0 and 1)
  75062. * @param factor defines the start size value to affect to the specified gradient
  75063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75064. * @returns the current particle system
  75065. */
  75066. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75067. /**
  75068. * Remove a specific start size gradient
  75069. * @param gradient defines the gradient to remove
  75070. * @returns the current particle system
  75071. */
  75072. removeStartSizeGradient(gradient: number): IParticleSystem;
  75073. private _createRampGradientTexture;
  75074. /**
  75075. * Gets the current list of ramp gradients.
  75076. * You must use addRampGradient and removeRampGradient to udpate this list
  75077. * @returns the list of ramp gradients
  75078. */
  75079. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75080. /**
  75081. * Adds a new ramp gradient used to remap particle colors
  75082. * @param gradient defines the gradient to use (between 0 and 1)
  75083. * @param color defines the color to affect to the specified gradient
  75084. * @returns the current particle system
  75085. */
  75086. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75087. /**
  75088. * Remove a specific ramp gradient
  75089. * @param gradient defines the gradient to remove
  75090. * @returns the current particle system
  75091. */
  75092. removeRampGradient(gradient: number): ParticleSystem;
  75093. /**
  75094. * Adds a new color gradient
  75095. * @param gradient defines the gradient to use (between 0 and 1)
  75096. * @param color1 defines the color to affect to the specified gradient
  75097. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75098. * @returns this particle system
  75099. */
  75100. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75101. /**
  75102. * Remove a specific color gradient
  75103. * @param gradient defines the gradient to remove
  75104. * @returns this particle system
  75105. */
  75106. removeColorGradient(gradient: number): IParticleSystem;
  75107. private _fetchR;
  75108. protected _reset(): void;
  75109. private _resetEffect;
  75110. private _createVertexBuffers;
  75111. private _createIndexBuffer;
  75112. /**
  75113. * Gets the maximum number of particles active at the same time.
  75114. * @returns The max number of active particles.
  75115. */
  75116. getCapacity(): number;
  75117. /**
  75118. * Gets whether there are still active particles in the system.
  75119. * @returns True if it is alive, otherwise false.
  75120. */
  75121. isAlive(): boolean;
  75122. /**
  75123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75124. * @returns True if it has been started, otherwise false.
  75125. */
  75126. isStarted(): boolean;
  75127. private _prepareSubEmitterInternalArray;
  75128. /**
  75129. * Starts the particle system and begins to emit
  75130. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75131. */
  75132. start(delay?: number): void;
  75133. /**
  75134. * Stops the particle system.
  75135. * @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.
  75136. */
  75137. stop(stopSubEmitters?: boolean): void;
  75138. /**
  75139. * Remove all active particles
  75140. */
  75141. reset(): void;
  75142. /**
  75143. * @hidden (for internal use only)
  75144. */
  75145. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75146. /**
  75147. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75148. * Its lifetime will start back at 0.
  75149. */
  75150. recycleParticle: (particle: Particle) => void;
  75151. private _stopSubEmitters;
  75152. private _createParticle;
  75153. private _removeFromRoot;
  75154. private _emitFromParticle;
  75155. private _update;
  75156. /** @hidden */
  75157. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75158. /** @hidden */
  75159. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75160. /** @hidden */
  75161. private _getEffect;
  75162. /**
  75163. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75164. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75165. */
  75166. animate(preWarmOnly?: boolean): void;
  75167. private _appendParticleVertices;
  75168. /**
  75169. * Rebuilds the particle system.
  75170. */
  75171. rebuild(): void;
  75172. /**
  75173. * Is this system ready to be used/rendered
  75174. * @return true if the system is ready
  75175. */
  75176. isReady(): boolean;
  75177. private _render;
  75178. /**
  75179. * Renders the particle system in its current state.
  75180. * @returns the current number of particles
  75181. */
  75182. render(): number;
  75183. /**
  75184. * Disposes the particle system and free the associated resources
  75185. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75186. */
  75187. dispose(disposeTexture?: boolean): void;
  75188. /**
  75189. * Clones the particle system.
  75190. * @param name The name of the cloned object
  75191. * @param newEmitter The new emitter to use
  75192. * @returns the cloned particle system
  75193. */
  75194. clone(name: string, newEmitter: any): ParticleSystem;
  75195. /**
  75196. * Serializes the particle system to a JSON object.
  75197. * @returns the JSON object
  75198. */
  75199. serialize(): any;
  75200. /** @hidden */
  75201. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75202. /** @hidden */
  75203. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75204. /**
  75205. * Parses a JSON object to create a particle system.
  75206. * @param parsedParticleSystem The JSON object to parse
  75207. * @param scene The scene to create the particle system in
  75208. * @param rootUrl The root url to use to load external dependencies like texture
  75209. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75210. * @returns the Parsed particle system
  75211. */
  75212. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75213. }
  75214. }
  75215. declare module BABYLON {
  75216. /**
  75217. * A particle represents one of the element emitted by a particle system.
  75218. * This is mainly define by its coordinates, direction, velocity and age.
  75219. */
  75220. export class Particle {
  75221. /**
  75222. * The particle system the particle belongs to.
  75223. */
  75224. particleSystem: ParticleSystem;
  75225. private static _Count;
  75226. /**
  75227. * Unique ID of the particle
  75228. */
  75229. id: number;
  75230. /**
  75231. * The world position of the particle in the scene.
  75232. */
  75233. position: Vector3;
  75234. /**
  75235. * The world direction of the particle in the scene.
  75236. */
  75237. direction: Vector3;
  75238. /**
  75239. * The color of the particle.
  75240. */
  75241. color: Color4;
  75242. /**
  75243. * The color change of the particle per step.
  75244. */
  75245. colorStep: Color4;
  75246. /**
  75247. * Defines how long will the life of the particle be.
  75248. */
  75249. lifeTime: number;
  75250. /**
  75251. * The current age of the particle.
  75252. */
  75253. age: number;
  75254. /**
  75255. * The current size of the particle.
  75256. */
  75257. size: number;
  75258. /**
  75259. * The current scale of the particle.
  75260. */
  75261. scale: Vector2;
  75262. /**
  75263. * The current angle of the particle.
  75264. */
  75265. angle: number;
  75266. /**
  75267. * Defines how fast is the angle changing.
  75268. */
  75269. angularSpeed: number;
  75270. /**
  75271. * Defines the cell index used by the particle to be rendered from a sprite.
  75272. */
  75273. cellIndex: number;
  75274. /**
  75275. * The information required to support color remapping
  75276. */
  75277. remapData: Vector4;
  75278. /** @hidden */
  75279. _randomCellOffset?: number;
  75280. /** @hidden */
  75281. _initialDirection: Nullable<Vector3>;
  75282. /** @hidden */
  75283. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75284. /** @hidden */
  75285. _initialStartSpriteCellID: number;
  75286. /** @hidden */
  75287. _initialEndSpriteCellID: number;
  75288. /** @hidden */
  75289. _currentColorGradient: Nullable<ColorGradient>;
  75290. /** @hidden */
  75291. _currentColor1: Color4;
  75292. /** @hidden */
  75293. _currentColor2: Color4;
  75294. /** @hidden */
  75295. _currentSizeGradient: Nullable<FactorGradient>;
  75296. /** @hidden */
  75297. _currentSize1: number;
  75298. /** @hidden */
  75299. _currentSize2: number;
  75300. /** @hidden */
  75301. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75302. /** @hidden */
  75303. _currentAngularSpeed1: number;
  75304. /** @hidden */
  75305. _currentAngularSpeed2: number;
  75306. /** @hidden */
  75307. _currentVelocityGradient: Nullable<FactorGradient>;
  75308. /** @hidden */
  75309. _currentVelocity1: number;
  75310. /** @hidden */
  75311. _currentVelocity2: number;
  75312. /** @hidden */
  75313. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75314. /** @hidden */
  75315. _currentLimitVelocity1: number;
  75316. /** @hidden */
  75317. _currentLimitVelocity2: number;
  75318. /** @hidden */
  75319. _currentDragGradient: Nullable<FactorGradient>;
  75320. /** @hidden */
  75321. _currentDrag1: number;
  75322. /** @hidden */
  75323. _currentDrag2: number;
  75324. /** @hidden */
  75325. _randomNoiseCoordinates1: Vector3;
  75326. /** @hidden */
  75327. _randomNoiseCoordinates2: Vector3;
  75328. /**
  75329. * Creates a new instance Particle
  75330. * @param particleSystem the particle system the particle belongs to
  75331. */
  75332. constructor(
  75333. /**
  75334. * The particle system the particle belongs to.
  75335. */
  75336. particleSystem: ParticleSystem);
  75337. private updateCellInfoFromSystem;
  75338. /**
  75339. * Defines how the sprite cell index is updated for the particle
  75340. */
  75341. updateCellIndex(): void;
  75342. /** @hidden */
  75343. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75344. /** @hidden */
  75345. _inheritParticleInfoToSubEmitters(): void;
  75346. /** @hidden */
  75347. _reset(): void;
  75348. /**
  75349. * Copy the properties of particle to another one.
  75350. * @param other the particle to copy the information to.
  75351. */
  75352. copyTo(other: Particle): void;
  75353. }
  75354. }
  75355. declare module BABYLON {
  75356. /**
  75357. * Particle emitter represents a volume emitting particles.
  75358. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75359. */
  75360. export interface IParticleEmitterType {
  75361. /**
  75362. * Called by the particle System when the direction is computed for the created particle.
  75363. * @param worldMatrix is the world matrix of the particle system
  75364. * @param directionToUpdate is the direction vector to update with the result
  75365. * @param particle is the particle we are computed the direction for
  75366. */
  75367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75368. /**
  75369. * Called by the particle System when the position is computed for the created particle.
  75370. * @param worldMatrix is the world matrix of the particle system
  75371. * @param positionToUpdate is the position vector to update with the result
  75372. * @param particle is the particle we are computed the position for
  75373. */
  75374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75375. /**
  75376. * Clones the current emitter and returns a copy of it
  75377. * @returns the new emitter
  75378. */
  75379. clone(): IParticleEmitterType;
  75380. /**
  75381. * Called by the GPUParticleSystem to setup the update shader
  75382. * @param effect defines the update shader
  75383. */
  75384. applyToShader(effect: Effect): void;
  75385. /**
  75386. * Returns a string to use to update the GPU particles update shader
  75387. * @returns the effect defines string
  75388. */
  75389. getEffectDefines(): string;
  75390. /**
  75391. * Returns a string representing the class name
  75392. * @returns a string containing the class name
  75393. */
  75394. getClassName(): string;
  75395. /**
  75396. * Serializes the particle system to a JSON object.
  75397. * @returns the JSON object
  75398. */
  75399. serialize(): any;
  75400. /**
  75401. * Parse properties from a JSON object
  75402. * @param serializationObject defines the JSON object
  75403. */
  75404. parse(serializationObject: any): void;
  75405. }
  75406. }
  75407. declare module BABYLON {
  75408. /**
  75409. * Particle emitter emitting particles from the inside of a box.
  75410. * It emits the particles randomly between 2 given directions.
  75411. */
  75412. export class BoxParticleEmitter implements IParticleEmitterType {
  75413. /**
  75414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75415. */
  75416. direction1: Vector3;
  75417. /**
  75418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75419. */
  75420. direction2: Vector3;
  75421. /**
  75422. * 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.
  75423. */
  75424. minEmitBox: Vector3;
  75425. /**
  75426. * 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.
  75427. */
  75428. maxEmitBox: Vector3;
  75429. /**
  75430. * Creates a new instance BoxParticleEmitter
  75431. */
  75432. constructor();
  75433. /**
  75434. * Called by the particle System when the direction is computed for the created particle.
  75435. * @param worldMatrix is the world matrix of the particle system
  75436. * @param directionToUpdate is the direction vector to update with the result
  75437. * @param particle is the particle we are computed the direction for
  75438. */
  75439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75440. /**
  75441. * Called by the particle System when the position is computed for the created particle.
  75442. * @param worldMatrix is the world matrix of the particle system
  75443. * @param positionToUpdate is the position vector to update with the result
  75444. * @param particle is the particle we are computed the position for
  75445. */
  75446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75447. /**
  75448. * Clones the current emitter and returns a copy of it
  75449. * @returns the new emitter
  75450. */
  75451. clone(): BoxParticleEmitter;
  75452. /**
  75453. * Called by the GPUParticleSystem to setup the update shader
  75454. * @param effect defines the update shader
  75455. */
  75456. applyToShader(effect: Effect): void;
  75457. /**
  75458. * Returns a string to use to update the GPU particles update shader
  75459. * @returns a string containng the defines string
  75460. */
  75461. getEffectDefines(): string;
  75462. /**
  75463. * Returns the string "BoxParticleEmitter"
  75464. * @returns a string containing the class name
  75465. */
  75466. getClassName(): string;
  75467. /**
  75468. * Serializes the particle system to a JSON object.
  75469. * @returns the JSON object
  75470. */
  75471. serialize(): any;
  75472. /**
  75473. * Parse properties from a JSON object
  75474. * @param serializationObject defines the JSON object
  75475. */
  75476. parse(serializationObject: any): void;
  75477. }
  75478. }
  75479. declare module BABYLON {
  75480. /**
  75481. * Particle emitter emitting particles from the inside of a cone.
  75482. * It emits the particles alongside the cone volume from the base to the particle.
  75483. * The emission direction might be randomized.
  75484. */
  75485. export class ConeParticleEmitter implements IParticleEmitterType {
  75486. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75487. directionRandomizer: number;
  75488. private _radius;
  75489. private _angle;
  75490. private _height;
  75491. /**
  75492. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75493. */
  75494. radiusRange: number;
  75495. /**
  75496. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75497. */
  75498. heightRange: number;
  75499. /**
  75500. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75501. */
  75502. emitFromSpawnPointOnly: boolean;
  75503. /**
  75504. * Gets or sets the radius of the emission cone
  75505. */
  75506. radius: number;
  75507. /**
  75508. * Gets or sets the angle of the emission cone
  75509. */
  75510. angle: number;
  75511. private _buildHeight;
  75512. /**
  75513. * Creates a new instance ConeParticleEmitter
  75514. * @param radius the radius of the emission cone (1 by default)
  75515. * @param angle the cone base angle (PI by default)
  75516. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75517. */
  75518. constructor(radius?: number, angle?: number,
  75519. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75520. directionRandomizer?: number);
  75521. /**
  75522. * Called by the particle System when the direction is computed for the created particle.
  75523. * @param worldMatrix is the world matrix of the particle system
  75524. * @param directionToUpdate is the direction vector to update with the result
  75525. * @param particle is the particle we are computed the direction for
  75526. */
  75527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75528. /**
  75529. * Called by the particle System when the position is computed for the created particle.
  75530. * @param worldMatrix is the world matrix of the particle system
  75531. * @param positionToUpdate is the position vector to update with the result
  75532. * @param particle is the particle we are computed the position for
  75533. */
  75534. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75535. /**
  75536. * Clones the current emitter and returns a copy of it
  75537. * @returns the new emitter
  75538. */
  75539. clone(): ConeParticleEmitter;
  75540. /**
  75541. * Called by the GPUParticleSystem to setup the update shader
  75542. * @param effect defines the update shader
  75543. */
  75544. applyToShader(effect: Effect): void;
  75545. /**
  75546. * Returns a string to use to update the GPU particles update shader
  75547. * @returns a string containng the defines string
  75548. */
  75549. getEffectDefines(): string;
  75550. /**
  75551. * Returns the string "ConeParticleEmitter"
  75552. * @returns a string containing the class name
  75553. */
  75554. getClassName(): string;
  75555. /**
  75556. * Serializes the particle system to a JSON object.
  75557. * @returns the JSON object
  75558. */
  75559. serialize(): any;
  75560. /**
  75561. * Parse properties from a JSON object
  75562. * @param serializationObject defines the JSON object
  75563. */
  75564. parse(serializationObject: any): void;
  75565. }
  75566. }
  75567. declare module BABYLON {
  75568. /**
  75569. * Particle emitter emitting particles from the inside of a cylinder.
  75570. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75571. */
  75572. export class CylinderParticleEmitter implements IParticleEmitterType {
  75573. /**
  75574. * The radius of the emission cylinder.
  75575. */
  75576. radius: number;
  75577. /**
  75578. * The height of the emission cylinder.
  75579. */
  75580. height: number;
  75581. /**
  75582. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75583. */
  75584. radiusRange: number;
  75585. /**
  75586. * How much to randomize the particle direction [0-1].
  75587. */
  75588. directionRandomizer: number;
  75589. /**
  75590. * Creates a new instance CylinderParticleEmitter
  75591. * @param radius the radius of the emission cylinder (1 by default)
  75592. * @param height the height of the emission cylinder (1 by default)
  75593. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75594. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75595. */
  75596. constructor(
  75597. /**
  75598. * The radius of the emission cylinder.
  75599. */
  75600. radius?: number,
  75601. /**
  75602. * The height of the emission cylinder.
  75603. */
  75604. height?: number,
  75605. /**
  75606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75607. */
  75608. radiusRange?: number,
  75609. /**
  75610. * How much to randomize the particle direction [0-1].
  75611. */
  75612. directionRandomizer?: number);
  75613. /**
  75614. * Called by the particle System when the direction is computed for the created particle.
  75615. * @param worldMatrix is the world matrix of the particle system
  75616. * @param directionToUpdate is the direction vector to update with the result
  75617. * @param particle is the particle we are computed the direction for
  75618. */
  75619. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75620. /**
  75621. * Called by the particle System when the position is computed for the created particle.
  75622. * @param worldMatrix is the world matrix of the particle system
  75623. * @param positionToUpdate is the position vector to update with the result
  75624. * @param particle is the particle we are computed the position for
  75625. */
  75626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75627. /**
  75628. * Clones the current emitter and returns a copy of it
  75629. * @returns the new emitter
  75630. */
  75631. clone(): CylinderParticleEmitter;
  75632. /**
  75633. * Called by the GPUParticleSystem to setup the update shader
  75634. * @param effect defines the update shader
  75635. */
  75636. applyToShader(effect: Effect): void;
  75637. /**
  75638. * Returns a string to use to update the GPU particles update shader
  75639. * @returns a string containng the defines string
  75640. */
  75641. getEffectDefines(): string;
  75642. /**
  75643. * Returns the string "CylinderParticleEmitter"
  75644. * @returns a string containing the class name
  75645. */
  75646. getClassName(): string;
  75647. /**
  75648. * Serializes the particle system to a JSON object.
  75649. * @returns the JSON object
  75650. */
  75651. serialize(): any;
  75652. /**
  75653. * Parse properties from a JSON object
  75654. * @param serializationObject defines the JSON object
  75655. */
  75656. parse(serializationObject: any): void;
  75657. }
  75658. /**
  75659. * Particle emitter emitting particles from the inside of a cylinder.
  75660. * It emits the particles randomly between two vectors.
  75661. */
  75662. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75663. /**
  75664. * The min limit of the emission direction.
  75665. */
  75666. direction1: Vector3;
  75667. /**
  75668. * The max limit of the emission direction.
  75669. */
  75670. direction2: Vector3;
  75671. /**
  75672. * Creates a new instance CylinderDirectedParticleEmitter
  75673. * @param radius the radius of the emission cylinder (1 by default)
  75674. * @param height the height of the emission cylinder (1 by default)
  75675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75676. * @param direction1 the min limit of the emission direction (up vector by default)
  75677. * @param direction2 the max limit of the emission direction (up vector by default)
  75678. */
  75679. constructor(radius?: number, height?: number, radiusRange?: number,
  75680. /**
  75681. * The min limit of the emission direction.
  75682. */
  75683. direction1?: Vector3,
  75684. /**
  75685. * The max limit of the emission direction.
  75686. */
  75687. direction2?: Vector3);
  75688. /**
  75689. * Called by the particle System when the direction is computed for the created particle.
  75690. * @param worldMatrix is the world matrix of the particle system
  75691. * @param directionToUpdate is the direction vector to update with the result
  75692. * @param particle is the particle we are computed the direction for
  75693. */
  75694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75695. /**
  75696. * Clones the current emitter and returns a copy of it
  75697. * @returns the new emitter
  75698. */
  75699. clone(): CylinderDirectedParticleEmitter;
  75700. /**
  75701. * Called by the GPUParticleSystem to setup the update shader
  75702. * @param effect defines the update shader
  75703. */
  75704. applyToShader(effect: Effect): void;
  75705. /**
  75706. * Returns a string to use to update the GPU particles update shader
  75707. * @returns a string containng the defines string
  75708. */
  75709. getEffectDefines(): string;
  75710. /**
  75711. * Returns the string "CylinderDirectedParticleEmitter"
  75712. * @returns a string containing the class name
  75713. */
  75714. getClassName(): string;
  75715. /**
  75716. * Serializes the particle system to a JSON object.
  75717. * @returns the JSON object
  75718. */
  75719. serialize(): any;
  75720. /**
  75721. * Parse properties from a JSON object
  75722. * @param serializationObject defines the JSON object
  75723. */
  75724. parse(serializationObject: any): void;
  75725. }
  75726. }
  75727. declare module BABYLON {
  75728. /**
  75729. * Particle emitter emitting particles from the inside of a hemisphere.
  75730. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75731. */
  75732. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75733. /**
  75734. * The radius of the emission hemisphere.
  75735. */
  75736. radius: number;
  75737. /**
  75738. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75739. */
  75740. radiusRange: number;
  75741. /**
  75742. * How much to randomize the particle direction [0-1].
  75743. */
  75744. directionRandomizer: number;
  75745. /**
  75746. * Creates a new instance HemisphericParticleEmitter
  75747. * @param radius the radius of the emission hemisphere (1 by default)
  75748. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75749. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75750. */
  75751. constructor(
  75752. /**
  75753. * The radius of the emission hemisphere.
  75754. */
  75755. radius?: number,
  75756. /**
  75757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75758. */
  75759. radiusRange?: number,
  75760. /**
  75761. * How much to randomize the particle direction [0-1].
  75762. */
  75763. directionRandomizer?: number);
  75764. /**
  75765. * Called by the particle System when the direction is computed for the created particle.
  75766. * @param worldMatrix is the world matrix of the particle system
  75767. * @param directionToUpdate is the direction vector to update with the result
  75768. * @param particle is the particle we are computed the direction for
  75769. */
  75770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75771. /**
  75772. * Called by the particle System when the position is computed for the created particle.
  75773. * @param worldMatrix is the world matrix of the particle system
  75774. * @param positionToUpdate is the position vector to update with the result
  75775. * @param particle is the particle we are computed the position for
  75776. */
  75777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75778. /**
  75779. * Clones the current emitter and returns a copy of it
  75780. * @returns the new emitter
  75781. */
  75782. clone(): HemisphericParticleEmitter;
  75783. /**
  75784. * Called by the GPUParticleSystem to setup the update shader
  75785. * @param effect defines the update shader
  75786. */
  75787. applyToShader(effect: Effect): void;
  75788. /**
  75789. * Returns a string to use to update the GPU particles update shader
  75790. * @returns a string containng the defines string
  75791. */
  75792. getEffectDefines(): string;
  75793. /**
  75794. * Returns the string "HemisphericParticleEmitter"
  75795. * @returns a string containing the class name
  75796. */
  75797. getClassName(): string;
  75798. /**
  75799. * Serializes the particle system to a JSON object.
  75800. * @returns the JSON object
  75801. */
  75802. serialize(): any;
  75803. /**
  75804. * Parse properties from a JSON object
  75805. * @param serializationObject defines the JSON object
  75806. */
  75807. parse(serializationObject: any): void;
  75808. }
  75809. }
  75810. declare module BABYLON {
  75811. /**
  75812. * Particle emitter emitting particles from a point.
  75813. * It emits the particles randomly between 2 given directions.
  75814. */
  75815. export class PointParticleEmitter implements IParticleEmitterType {
  75816. /**
  75817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75818. */
  75819. direction1: Vector3;
  75820. /**
  75821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75822. */
  75823. direction2: Vector3;
  75824. /**
  75825. * Creates a new instance PointParticleEmitter
  75826. */
  75827. constructor();
  75828. /**
  75829. * Called by the particle System when the direction is computed for the created particle.
  75830. * @param worldMatrix is the world matrix of the particle system
  75831. * @param directionToUpdate is the direction vector to update with the result
  75832. * @param particle is the particle we are computed the direction for
  75833. */
  75834. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75835. /**
  75836. * Called by the particle System when the position is computed for the created particle.
  75837. * @param worldMatrix is the world matrix of the particle system
  75838. * @param positionToUpdate is the position vector to update with the result
  75839. * @param particle is the particle we are computed the position for
  75840. */
  75841. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75842. /**
  75843. * Clones the current emitter and returns a copy of it
  75844. * @returns the new emitter
  75845. */
  75846. clone(): PointParticleEmitter;
  75847. /**
  75848. * Called by the GPUParticleSystem to setup the update shader
  75849. * @param effect defines the update shader
  75850. */
  75851. applyToShader(effect: Effect): void;
  75852. /**
  75853. * Returns a string to use to update the GPU particles update shader
  75854. * @returns a string containng the defines string
  75855. */
  75856. getEffectDefines(): string;
  75857. /**
  75858. * Returns the string "PointParticleEmitter"
  75859. * @returns a string containing the class name
  75860. */
  75861. getClassName(): string;
  75862. /**
  75863. * Serializes the particle system to a JSON object.
  75864. * @returns the JSON object
  75865. */
  75866. serialize(): any;
  75867. /**
  75868. * Parse properties from a JSON object
  75869. * @param serializationObject defines the JSON object
  75870. */
  75871. parse(serializationObject: any): void;
  75872. }
  75873. }
  75874. declare module BABYLON {
  75875. /**
  75876. * Particle emitter emitting particles from the inside of a sphere.
  75877. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75878. */
  75879. export class SphereParticleEmitter implements IParticleEmitterType {
  75880. /**
  75881. * The radius of the emission sphere.
  75882. */
  75883. radius: number;
  75884. /**
  75885. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75886. */
  75887. radiusRange: number;
  75888. /**
  75889. * How much to randomize the particle direction [0-1].
  75890. */
  75891. directionRandomizer: number;
  75892. /**
  75893. * Creates a new instance SphereParticleEmitter
  75894. * @param radius the radius of the emission sphere (1 by default)
  75895. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75897. */
  75898. constructor(
  75899. /**
  75900. * The radius of the emission sphere.
  75901. */
  75902. radius?: number,
  75903. /**
  75904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75905. */
  75906. radiusRange?: number,
  75907. /**
  75908. * How much to randomize the particle direction [0-1].
  75909. */
  75910. directionRandomizer?: number);
  75911. /**
  75912. * Called by the particle System when the direction is computed for the created particle.
  75913. * @param worldMatrix is the world matrix of the particle system
  75914. * @param directionToUpdate is the direction vector to update with the result
  75915. * @param particle is the particle we are computed the direction for
  75916. */
  75917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75918. /**
  75919. * Called by the particle System when the position is computed for the created particle.
  75920. * @param worldMatrix is the world matrix of the particle system
  75921. * @param positionToUpdate is the position vector to update with the result
  75922. * @param particle is the particle we are computed the position for
  75923. */
  75924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75925. /**
  75926. * Clones the current emitter and returns a copy of it
  75927. * @returns the new emitter
  75928. */
  75929. clone(): SphereParticleEmitter;
  75930. /**
  75931. * Called by the GPUParticleSystem to setup the update shader
  75932. * @param effect defines the update shader
  75933. */
  75934. applyToShader(effect: Effect): void;
  75935. /**
  75936. * Returns a string to use to update the GPU particles update shader
  75937. * @returns a string containng the defines string
  75938. */
  75939. getEffectDefines(): string;
  75940. /**
  75941. * Returns the string "SphereParticleEmitter"
  75942. * @returns a string containing the class name
  75943. */
  75944. getClassName(): string;
  75945. /**
  75946. * Serializes the particle system to a JSON object.
  75947. * @returns the JSON object
  75948. */
  75949. serialize(): any;
  75950. /**
  75951. * Parse properties from a JSON object
  75952. * @param serializationObject defines the JSON object
  75953. */
  75954. parse(serializationObject: any): void;
  75955. }
  75956. /**
  75957. * Particle emitter emitting particles from the inside of a sphere.
  75958. * It emits the particles randomly between two vectors.
  75959. */
  75960. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75961. /**
  75962. * The min limit of the emission direction.
  75963. */
  75964. direction1: Vector3;
  75965. /**
  75966. * The max limit of the emission direction.
  75967. */
  75968. direction2: Vector3;
  75969. /**
  75970. * Creates a new instance SphereDirectedParticleEmitter
  75971. * @param radius the radius of the emission sphere (1 by default)
  75972. * @param direction1 the min limit of the emission direction (up vector by default)
  75973. * @param direction2 the max limit of the emission direction (up vector by default)
  75974. */
  75975. constructor(radius?: number,
  75976. /**
  75977. * The min limit of the emission direction.
  75978. */
  75979. direction1?: Vector3,
  75980. /**
  75981. * The max limit of the emission direction.
  75982. */
  75983. direction2?: Vector3);
  75984. /**
  75985. * Called by the particle System when the direction is computed for the created particle.
  75986. * @param worldMatrix is the world matrix of the particle system
  75987. * @param directionToUpdate is the direction vector to update with the result
  75988. * @param particle is the particle we are computed the direction for
  75989. */
  75990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75991. /**
  75992. * Clones the current emitter and returns a copy of it
  75993. * @returns the new emitter
  75994. */
  75995. clone(): SphereDirectedParticleEmitter;
  75996. /**
  75997. * Called by the GPUParticleSystem to setup the update shader
  75998. * @param effect defines the update shader
  75999. */
  76000. applyToShader(effect: Effect): void;
  76001. /**
  76002. * Returns a string to use to update the GPU particles update shader
  76003. * @returns a string containng the defines string
  76004. */
  76005. getEffectDefines(): string;
  76006. /**
  76007. * Returns the string "SphereDirectedParticleEmitter"
  76008. * @returns a string containing the class name
  76009. */
  76010. getClassName(): string;
  76011. /**
  76012. * Serializes the particle system to a JSON object.
  76013. * @returns the JSON object
  76014. */
  76015. serialize(): any;
  76016. /**
  76017. * Parse properties from a JSON object
  76018. * @param serializationObject defines the JSON object
  76019. */
  76020. parse(serializationObject: any): void;
  76021. }
  76022. }
  76023. declare module BABYLON {
  76024. /**
  76025. * Interface representing a particle system in Babylon.js.
  76026. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76027. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76028. */
  76029. export interface IParticleSystem {
  76030. /**
  76031. * List of animations used by the particle system.
  76032. */
  76033. animations: Animation[];
  76034. /**
  76035. * The id of the Particle system.
  76036. */
  76037. id: string;
  76038. /**
  76039. * The name of the Particle system.
  76040. */
  76041. name: string;
  76042. /**
  76043. * The emitter represents the Mesh or position we are attaching the particle system to.
  76044. */
  76045. emitter: Nullable<AbstractMesh | Vector3>;
  76046. /**
  76047. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76048. */
  76049. isBillboardBased: boolean;
  76050. /**
  76051. * The rendering group used by the Particle system to chose when to render.
  76052. */
  76053. renderingGroupId: number;
  76054. /**
  76055. * The layer mask we are rendering the particles through.
  76056. */
  76057. layerMask: number;
  76058. /**
  76059. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76060. */
  76061. updateSpeed: number;
  76062. /**
  76063. * The amount of time the particle system is running (depends of the overall update speed).
  76064. */
  76065. targetStopDuration: number;
  76066. /**
  76067. * The texture used to render each particle. (this can be a spritesheet)
  76068. */
  76069. particleTexture: Nullable<Texture>;
  76070. /**
  76071. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76072. */
  76073. blendMode: number;
  76074. /**
  76075. * Minimum life time of emitting particles.
  76076. */
  76077. minLifeTime: number;
  76078. /**
  76079. * Maximum life time of emitting particles.
  76080. */
  76081. maxLifeTime: number;
  76082. /**
  76083. * Minimum Size of emitting particles.
  76084. */
  76085. minSize: number;
  76086. /**
  76087. * Maximum Size of emitting particles.
  76088. */
  76089. maxSize: number;
  76090. /**
  76091. * Minimum scale of emitting particles on X axis.
  76092. */
  76093. minScaleX: number;
  76094. /**
  76095. * Maximum scale of emitting particles on X axis.
  76096. */
  76097. maxScaleX: number;
  76098. /**
  76099. * Minimum scale of emitting particles on Y axis.
  76100. */
  76101. minScaleY: number;
  76102. /**
  76103. * Maximum scale of emitting particles on Y axis.
  76104. */
  76105. maxScaleY: number;
  76106. /**
  76107. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76108. */
  76109. color1: Color4;
  76110. /**
  76111. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76112. */
  76113. color2: Color4;
  76114. /**
  76115. * Color the particle will have at the end of its lifetime.
  76116. */
  76117. colorDead: Color4;
  76118. /**
  76119. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76120. */
  76121. emitRate: number;
  76122. /**
  76123. * You can use gravity if you want to give an orientation to your particles.
  76124. */
  76125. gravity: Vector3;
  76126. /**
  76127. * Minimum power of emitting particles.
  76128. */
  76129. minEmitPower: number;
  76130. /**
  76131. * Maximum power of emitting particles.
  76132. */
  76133. maxEmitPower: number;
  76134. /**
  76135. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76136. */
  76137. minAngularSpeed: number;
  76138. /**
  76139. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76140. */
  76141. maxAngularSpeed: number;
  76142. /**
  76143. * Gets or sets the minimal initial rotation in radians.
  76144. */
  76145. minInitialRotation: number;
  76146. /**
  76147. * Gets or sets the maximal initial rotation in radians.
  76148. */
  76149. maxInitialRotation: number;
  76150. /**
  76151. * The particle emitter type defines the emitter used by the particle system.
  76152. * It can be for example box, sphere, or cone...
  76153. */
  76154. particleEmitterType: Nullable<IParticleEmitterType>;
  76155. /**
  76156. * Defines the delay in milliseconds before starting the system (0 by default)
  76157. */
  76158. startDelay: number;
  76159. /**
  76160. * 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
  76161. */
  76162. preWarmCycles: number;
  76163. /**
  76164. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76165. */
  76166. preWarmStepOffset: number;
  76167. /**
  76168. * 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)
  76169. */
  76170. spriteCellChangeSpeed: number;
  76171. /**
  76172. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76173. */
  76174. startSpriteCellID: number;
  76175. /**
  76176. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76177. */
  76178. endSpriteCellID: number;
  76179. /**
  76180. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76181. */
  76182. spriteCellWidth: number;
  76183. /**
  76184. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76185. */
  76186. spriteCellHeight: number;
  76187. /**
  76188. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76189. */
  76190. spriteRandomStartCell: boolean;
  76191. /**
  76192. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76193. */
  76194. isAnimationSheetEnabled: boolean;
  76195. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76196. translationPivot: Vector2;
  76197. /**
  76198. * Gets or sets a texture used to add random noise to particle positions
  76199. */
  76200. noiseTexture: Nullable<BaseTexture>;
  76201. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76202. noiseStrength: Vector3;
  76203. /**
  76204. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76205. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76206. */
  76207. billboardMode: number;
  76208. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76209. limitVelocityDamping: number;
  76210. /**
  76211. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76212. */
  76213. beginAnimationOnStart: boolean;
  76214. /**
  76215. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76216. */
  76217. beginAnimationFrom: number;
  76218. /**
  76219. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76220. */
  76221. beginAnimationTo: number;
  76222. /**
  76223. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76224. */
  76225. beginAnimationLoop: boolean;
  76226. /**
  76227. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76228. */
  76229. disposeOnStop: boolean;
  76230. /**
  76231. * Gets the maximum number of particles active at the same time.
  76232. * @returns The max number of active particles.
  76233. */
  76234. getCapacity(): number;
  76235. /**
  76236. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76237. * @returns True if it has been started, otherwise false.
  76238. */
  76239. isStarted(): boolean;
  76240. /**
  76241. * Animates the particle system for this frame.
  76242. */
  76243. animate(): void;
  76244. /**
  76245. * Renders the particle system in its current state.
  76246. * @returns the current number of particles
  76247. */
  76248. render(): number;
  76249. /**
  76250. * Dispose the particle system and frees its associated resources.
  76251. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76252. */
  76253. dispose(disposeTexture?: boolean): void;
  76254. /**
  76255. * Clones the particle system.
  76256. * @param name The name of the cloned object
  76257. * @param newEmitter The new emitter to use
  76258. * @returns the cloned particle system
  76259. */
  76260. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76261. /**
  76262. * Serializes the particle system to a JSON object.
  76263. * @returns the JSON object
  76264. */
  76265. serialize(): any;
  76266. /**
  76267. * Rebuild the particle system
  76268. */
  76269. rebuild(): void;
  76270. /**
  76271. * Starts the particle system and begins to emit
  76272. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76273. */
  76274. start(delay?: number): void;
  76275. /**
  76276. * Stops the particle system.
  76277. */
  76278. stop(): void;
  76279. /**
  76280. * Remove all active particles
  76281. */
  76282. reset(): void;
  76283. /**
  76284. * Is this system ready to be used/rendered
  76285. * @return true if the system is ready
  76286. */
  76287. isReady(): boolean;
  76288. /**
  76289. * Adds a new color gradient
  76290. * @param gradient defines the gradient to use (between 0 and 1)
  76291. * @param color1 defines the color to affect to the specified gradient
  76292. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76293. * @returns the current particle system
  76294. */
  76295. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76296. /**
  76297. * Remove a specific color gradient
  76298. * @param gradient defines the gradient to remove
  76299. * @returns the current particle system
  76300. */
  76301. removeColorGradient(gradient: number): IParticleSystem;
  76302. /**
  76303. * Adds a new size gradient
  76304. * @param gradient defines the gradient to use (between 0 and 1)
  76305. * @param factor defines the size factor to affect to the specified gradient
  76306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76307. * @returns the current particle system
  76308. */
  76309. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76310. /**
  76311. * Remove a specific size gradient
  76312. * @param gradient defines the gradient to remove
  76313. * @returns the current particle system
  76314. */
  76315. removeSizeGradient(gradient: number): IParticleSystem;
  76316. /**
  76317. * Gets the current list of color gradients.
  76318. * You must use addColorGradient and removeColorGradient to udpate this list
  76319. * @returns the list of color gradients
  76320. */
  76321. getColorGradients(): Nullable<Array<ColorGradient>>;
  76322. /**
  76323. * Gets the current list of size gradients.
  76324. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76325. * @returns the list of size gradients
  76326. */
  76327. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76328. /**
  76329. * Gets the current list of angular speed gradients.
  76330. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76331. * @returns the list of angular speed gradients
  76332. */
  76333. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76334. /**
  76335. * Adds a new angular speed gradient
  76336. * @param gradient defines the gradient to use (between 0 and 1)
  76337. * @param factor defines the angular speed to affect to the specified gradient
  76338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76339. * @returns the current particle system
  76340. */
  76341. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76342. /**
  76343. * Remove a specific angular speed gradient
  76344. * @param gradient defines the gradient to remove
  76345. * @returns the current particle system
  76346. */
  76347. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76348. /**
  76349. * Gets the current list of velocity gradients.
  76350. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76351. * @returns the list of velocity gradients
  76352. */
  76353. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76354. /**
  76355. * Adds a new velocity gradient
  76356. * @param gradient defines the gradient to use (between 0 and 1)
  76357. * @param factor defines the velocity to affect to the specified gradient
  76358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76359. * @returns the current particle system
  76360. */
  76361. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76362. /**
  76363. * Remove a specific velocity gradient
  76364. * @param gradient defines the gradient to remove
  76365. * @returns the current particle system
  76366. */
  76367. removeVelocityGradient(gradient: number): IParticleSystem;
  76368. /**
  76369. * Gets the current list of limit velocity gradients.
  76370. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76371. * @returns the list of limit velocity gradients
  76372. */
  76373. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76374. /**
  76375. * Adds a new limit velocity gradient
  76376. * @param gradient defines the gradient to use (between 0 and 1)
  76377. * @param factor defines the limit velocity to affect to the specified gradient
  76378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76379. * @returns the current particle system
  76380. */
  76381. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76382. /**
  76383. * Remove a specific limit velocity gradient
  76384. * @param gradient defines the gradient to remove
  76385. * @returns the current particle system
  76386. */
  76387. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76388. /**
  76389. * Adds a new drag gradient
  76390. * @param gradient defines the gradient to use (between 0 and 1)
  76391. * @param factor defines the drag to affect to the specified gradient
  76392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76393. * @returns the current particle system
  76394. */
  76395. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76396. /**
  76397. * Remove a specific drag gradient
  76398. * @param gradient defines the gradient to remove
  76399. * @returns the current particle system
  76400. */
  76401. removeDragGradient(gradient: number): IParticleSystem;
  76402. /**
  76403. * Gets the current list of drag gradients.
  76404. * You must use addDragGradient and removeDragGradient to udpate this list
  76405. * @returns the list of drag gradients
  76406. */
  76407. getDragGradients(): Nullable<Array<FactorGradient>>;
  76408. /**
  76409. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76410. * @param gradient defines the gradient to use (between 0 and 1)
  76411. * @param factor defines the emit rate to affect to the specified gradient
  76412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76413. * @returns the current particle system
  76414. */
  76415. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76416. /**
  76417. * Remove a specific emit rate gradient
  76418. * @param gradient defines the gradient to remove
  76419. * @returns the current particle system
  76420. */
  76421. removeEmitRateGradient(gradient: number): IParticleSystem;
  76422. /**
  76423. * Gets the current list of emit rate gradients.
  76424. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76425. * @returns the list of emit rate gradients
  76426. */
  76427. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76428. /**
  76429. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76430. * @param gradient defines the gradient to use (between 0 and 1)
  76431. * @param factor defines the start size to affect to the specified gradient
  76432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76433. * @returns the current particle system
  76434. */
  76435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76436. /**
  76437. * Remove a specific start size gradient
  76438. * @param gradient defines the gradient to remove
  76439. * @returns the current particle system
  76440. */
  76441. removeStartSizeGradient(gradient: number): IParticleSystem;
  76442. /**
  76443. * Gets the current list of start size gradients.
  76444. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76445. * @returns the list of start size gradients
  76446. */
  76447. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76448. /**
  76449. * Adds a new life time gradient
  76450. * @param gradient defines the gradient to use (between 0 and 1)
  76451. * @param factor defines the life time factor to affect to the specified gradient
  76452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76453. * @returns the current particle system
  76454. */
  76455. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76456. /**
  76457. * Remove a specific life time gradient
  76458. * @param gradient defines the gradient to remove
  76459. * @returns the current particle system
  76460. */
  76461. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76462. /**
  76463. * Gets the current list of life time gradients.
  76464. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76465. * @returns the list of life time gradients
  76466. */
  76467. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76468. /**
  76469. * Gets the current list of color gradients.
  76470. * You must use addColorGradient and removeColorGradient to udpate this list
  76471. * @returns the list of color gradients
  76472. */
  76473. getColorGradients(): Nullable<Array<ColorGradient>>;
  76474. /**
  76475. * Adds a new ramp gradient used to remap particle colors
  76476. * @param gradient defines the gradient to use (between 0 and 1)
  76477. * @param color defines the color to affect to the specified gradient
  76478. * @returns the current particle system
  76479. */
  76480. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76481. /**
  76482. * Gets the current list of ramp gradients.
  76483. * You must use addRampGradient and removeRampGradient to udpate this list
  76484. * @returns the list of ramp gradients
  76485. */
  76486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76487. /** Gets or sets a boolean indicating that ramp gradients must be used
  76488. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76489. */
  76490. useRampGradients: boolean;
  76491. /**
  76492. * Adds a new color remap gradient
  76493. * @param gradient defines the gradient to use (between 0 and 1)
  76494. * @param min defines the color remap minimal range
  76495. * @param max defines the color remap maximal range
  76496. * @returns the current particle system
  76497. */
  76498. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76499. /**
  76500. * Gets the current list of color remap gradients.
  76501. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76502. * @returns the list of color remap gradients
  76503. */
  76504. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76505. /**
  76506. * Adds a new alpha remap gradient
  76507. * @param gradient defines the gradient to use (between 0 and 1)
  76508. * @param min defines the alpha remap minimal range
  76509. * @param max defines the alpha remap maximal range
  76510. * @returns the current particle system
  76511. */
  76512. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76513. /**
  76514. * Gets the current list of alpha remap gradients.
  76515. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76516. * @returns the list of alpha remap gradients
  76517. */
  76518. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76519. /**
  76520. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76523. * @returns the emitter
  76524. */
  76525. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76526. /**
  76527. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76528. * @param radius The radius of the hemisphere to emit from
  76529. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76530. * @returns the emitter
  76531. */
  76532. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76533. /**
  76534. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76535. * @param radius The radius of the sphere to emit from
  76536. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76537. * @returns the emitter
  76538. */
  76539. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76540. /**
  76541. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76542. * @param radius The radius of the sphere to emit from
  76543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76545. * @returns the emitter
  76546. */
  76547. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76548. /**
  76549. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76550. * @param radius The radius of the emission cylinder
  76551. * @param height The height of the emission cylinder
  76552. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76553. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76554. * @returns the emitter
  76555. */
  76556. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76557. /**
  76558. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76559. * @param radius The radius of the cylinder to emit from
  76560. * @param height The height of the emission cylinder
  76561. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76564. * @returns the emitter
  76565. */
  76566. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76567. /**
  76568. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76569. * @param radius The radius of the cone to emit from
  76570. * @param angle The base angle of the cone
  76571. * @returns the emitter
  76572. */
  76573. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76574. /**
  76575. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76578. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76579. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76580. * @returns the emitter
  76581. */
  76582. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76583. /**
  76584. * Get hosting scene
  76585. * @returns the scene
  76586. */
  76587. getScene(): Scene;
  76588. }
  76589. }
  76590. declare module BABYLON {
  76591. /**
  76592. * Creates an instance based on a source mesh.
  76593. */
  76594. export class InstancedMesh extends AbstractMesh {
  76595. private _sourceMesh;
  76596. private _currentLOD;
  76597. /** @hidden */
  76598. _indexInSourceMeshInstanceArray: number;
  76599. constructor(name: string, source: Mesh);
  76600. /**
  76601. * Returns the string "InstancedMesh".
  76602. */
  76603. getClassName(): string;
  76604. /** Gets the list of lights affecting that mesh */
  76605. readonly lightSources: Light[];
  76606. _resyncLightSources(): void;
  76607. _resyncLighSource(light: Light): void;
  76608. _removeLightSource(light: Light): void;
  76609. /**
  76610. * If the source mesh receives shadows
  76611. */
  76612. readonly receiveShadows: boolean;
  76613. /**
  76614. * The material of the source mesh
  76615. */
  76616. readonly material: Nullable<Material>;
  76617. /**
  76618. * Visibility of the source mesh
  76619. */
  76620. readonly visibility: number;
  76621. /**
  76622. * Skeleton of the source mesh
  76623. */
  76624. readonly skeleton: Nullable<Skeleton>;
  76625. /**
  76626. * Rendering ground id of the source mesh
  76627. */
  76628. renderingGroupId: number;
  76629. /**
  76630. * Returns the total number of vertices (integer).
  76631. */
  76632. getTotalVertices(): number;
  76633. /**
  76634. * Returns a positive integer : the total number of indices in this mesh geometry.
  76635. * @returns the numner of indices or zero if the mesh has no geometry.
  76636. */
  76637. getTotalIndices(): number;
  76638. /**
  76639. * The source mesh of the instance
  76640. */
  76641. readonly sourceMesh: Mesh;
  76642. /**
  76643. * Is this node ready to be used/rendered
  76644. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76645. * @return {boolean} is it ready
  76646. */
  76647. isReady(completeCheck?: boolean): boolean;
  76648. /**
  76649. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76650. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76651. * @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.
  76652. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76653. */
  76654. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76655. /**
  76656. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76657. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76658. * The `data` are either a numeric array either a Float32Array.
  76659. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76660. * 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).
  76661. * Note that a new underlying VertexBuffer object is created each call.
  76662. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76663. *
  76664. * Possible `kind` values :
  76665. * - VertexBuffer.PositionKind
  76666. * - VertexBuffer.UVKind
  76667. * - VertexBuffer.UV2Kind
  76668. * - VertexBuffer.UV3Kind
  76669. * - VertexBuffer.UV4Kind
  76670. * - VertexBuffer.UV5Kind
  76671. * - VertexBuffer.UV6Kind
  76672. * - VertexBuffer.ColorKind
  76673. * - VertexBuffer.MatricesIndicesKind
  76674. * - VertexBuffer.MatricesIndicesExtraKind
  76675. * - VertexBuffer.MatricesWeightsKind
  76676. * - VertexBuffer.MatricesWeightsExtraKind
  76677. *
  76678. * Returns the Mesh.
  76679. */
  76680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76681. /**
  76682. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76683. * If the mesh has no geometry, it is simply returned as it is.
  76684. * The `data` are either a numeric array either a Float32Array.
  76685. * No new underlying VertexBuffer object is created.
  76686. * 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.
  76687. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76688. *
  76689. * Possible `kind` values :
  76690. * - VertexBuffer.PositionKind
  76691. * - VertexBuffer.UVKind
  76692. * - VertexBuffer.UV2Kind
  76693. * - VertexBuffer.UV3Kind
  76694. * - VertexBuffer.UV4Kind
  76695. * - VertexBuffer.UV5Kind
  76696. * - VertexBuffer.UV6Kind
  76697. * - VertexBuffer.ColorKind
  76698. * - VertexBuffer.MatricesIndicesKind
  76699. * - VertexBuffer.MatricesIndicesExtraKind
  76700. * - VertexBuffer.MatricesWeightsKind
  76701. * - VertexBuffer.MatricesWeightsExtraKind
  76702. *
  76703. * Returns the Mesh.
  76704. */
  76705. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76706. /**
  76707. * Sets the mesh indices.
  76708. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76709. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76710. * This method creates a new index buffer each call.
  76711. * Returns the Mesh.
  76712. */
  76713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76714. /**
  76715. * Boolean : True if the mesh owns the requested kind of data.
  76716. */
  76717. isVerticesDataPresent(kind: string): boolean;
  76718. /**
  76719. * Returns an array of indices (IndicesArray).
  76720. */
  76721. getIndices(): Nullable<IndicesArray>;
  76722. readonly _positions: Nullable<Vector3[]>;
  76723. /**
  76724. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76725. * This means the mesh underlying bounding box and sphere are recomputed.
  76726. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76727. * @returns the current mesh
  76728. */
  76729. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76730. /** @hidden */
  76731. _preActivate(): InstancedMesh;
  76732. /** @hidden */
  76733. _activate(renderId: number): boolean;
  76734. getWorldMatrix(): Matrix;
  76735. /**
  76736. * Returns the current associated LOD AbstractMesh.
  76737. */
  76738. getLOD(camera: Camera): AbstractMesh;
  76739. /** @hidden */
  76740. _syncSubMeshes(): InstancedMesh;
  76741. /** @hidden */
  76742. _generatePointsArray(): boolean;
  76743. /**
  76744. * Creates a new InstancedMesh from the current mesh.
  76745. * - name (string) : the cloned mesh name
  76746. * - newParent (optional Node) : the optional Node to parent the clone to.
  76747. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76748. *
  76749. * Returns the clone.
  76750. */
  76751. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76752. /**
  76753. * Disposes the InstancedMesh.
  76754. * Returns nothing.
  76755. */
  76756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76757. }
  76758. }
  76759. declare module BABYLON {
  76760. /**
  76761. * Defines the options associated with the creation of a shader material.
  76762. */
  76763. export interface IShaderMaterialOptions {
  76764. /**
  76765. * Does the material work in alpha blend mode
  76766. */
  76767. needAlphaBlending: boolean;
  76768. /**
  76769. * Does the material work in alpha test mode
  76770. */
  76771. needAlphaTesting: boolean;
  76772. /**
  76773. * The list of attribute names used in the shader
  76774. */
  76775. attributes: string[];
  76776. /**
  76777. * The list of unifrom names used in the shader
  76778. */
  76779. uniforms: string[];
  76780. /**
  76781. * The list of UBO names used in the shader
  76782. */
  76783. uniformBuffers: string[];
  76784. /**
  76785. * The list of sampler names used in the shader
  76786. */
  76787. samplers: string[];
  76788. /**
  76789. * The list of defines used in the shader
  76790. */
  76791. defines: string[];
  76792. }
  76793. /**
  76794. * 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.
  76795. *
  76796. * This returned material effects how the mesh will look based on the code in the shaders.
  76797. *
  76798. * @see http://doc.babylonjs.com/how_to/shader_material
  76799. */
  76800. export class ShaderMaterial extends Material {
  76801. private _shaderPath;
  76802. private _options;
  76803. private _textures;
  76804. private _textureArrays;
  76805. private _floats;
  76806. private _ints;
  76807. private _floatsArrays;
  76808. private _colors3;
  76809. private _colors3Arrays;
  76810. private _colors4;
  76811. private _vectors2;
  76812. private _vectors3;
  76813. private _vectors4;
  76814. private _matrices;
  76815. private _matrices3x3;
  76816. private _matrices2x2;
  76817. private _vectors2Arrays;
  76818. private _vectors3Arrays;
  76819. private _cachedWorldViewMatrix;
  76820. private _renderId;
  76821. /**
  76822. * Instantiate a new shader material.
  76823. * 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.
  76824. * This returned material effects how the mesh will look based on the code in the shaders.
  76825. * @see http://doc.babylonjs.com/how_to/shader_material
  76826. * @param name Define the name of the material in the scene
  76827. * @param scene Define the scene the material belongs to
  76828. * @param shaderPath Defines the route to the shader code in one of three ways:
  76829. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76830. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76831. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76832. * @param options Define the options used to create the shader
  76833. */
  76834. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76835. /**
  76836. * Gets the options used to compile the shader.
  76837. * They can be modified to trigger a new compilation
  76838. */
  76839. readonly options: IShaderMaterialOptions;
  76840. /**
  76841. * Gets the current class name of the material e.g. "ShaderMaterial"
  76842. * Mainly use in serialization.
  76843. * @returns the class name
  76844. */
  76845. getClassName(): string;
  76846. /**
  76847. * Specifies if the material will require alpha blending
  76848. * @returns a boolean specifying if alpha blending is needed
  76849. */
  76850. needAlphaBlending(): boolean;
  76851. /**
  76852. * Specifies if this material should be rendered in alpha test mode
  76853. * @returns a boolean specifying if an alpha test is needed.
  76854. */
  76855. needAlphaTesting(): boolean;
  76856. private _checkUniform;
  76857. /**
  76858. * Set a texture in the shader.
  76859. * @param name Define the name of the uniform samplers as defined in the shader
  76860. * @param texture Define the texture to bind to this sampler
  76861. * @return the material itself allowing "fluent" like uniform updates
  76862. */
  76863. setTexture(name: string, texture: Texture): ShaderMaterial;
  76864. /**
  76865. * Set a texture array in the shader.
  76866. * @param name Define the name of the uniform sampler array as defined in the shader
  76867. * @param textures Define the list of textures to bind to this sampler
  76868. * @return the material itself allowing "fluent" like uniform updates
  76869. */
  76870. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76871. /**
  76872. * Set a float in the shader.
  76873. * @param name Define the name of the uniform as defined in the shader
  76874. * @param value Define the value to give to the uniform
  76875. * @return the material itself allowing "fluent" like uniform updates
  76876. */
  76877. setFloat(name: string, value: number): ShaderMaterial;
  76878. /**
  76879. * Set a int in the shader.
  76880. * @param name Define the name of the uniform as defined in the shader
  76881. * @param value Define the value to give to the uniform
  76882. * @return the material itself allowing "fluent" like uniform updates
  76883. */
  76884. setInt(name: string, value: number): ShaderMaterial;
  76885. /**
  76886. * Set an array of floats in the shader.
  76887. * @param name Define the name of the uniform as defined in the shader
  76888. * @param value Define the value to give to the uniform
  76889. * @return the material itself allowing "fluent" like uniform updates
  76890. */
  76891. setFloats(name: string, value: number[]): ShaderMaterial;
  76892. /**
  76893. * Set a vec3 in the shader from a Color3.
  76894. * @param name Define the name of the uniform as defined in the shader
  76895. * @param value Define the value to give to the uniform
  76896. * @return the material itself allowing "fluent" like uniform updates
  76897. */
  76898. setColor3(name: string, value: Color3): ShaderMaterial;
  76899. /**
  76900. * Set a vec3 array in the shader from a Color3 array.
  76901. * @param name Define the name of the uniform as defined in the shader
  76902. * @param value Define the value to give to the uniform
  76903. * @return the material itself allowing "fluent" like uniform updates
  76904. */
  76905. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76906. /**
  76907. * Set a vec4 in the shader from a Color4.
  76908. * @param name Define the name of the uniform as defined in the shader
  76909. * @param value Define the value to give to the uniform
  76910. * @return the material itself allowing "fluent" like uniform updates
  76911. */
  76912. setColor4(name: string, value: Color4): ShaderMaterial;
  76913. /**
  76914. * Set a vec2 in the shader from a Vector2.
  76915. * @param name Define the name of the uniform as defined in the shader
  76916. * @param value Define the value to give to the uniform
  76917. * @return the material itself allowing "fluent" like uniform updates
  76918. */
  76919. setVector2(name: string, value: Vector2): ShaderMaterial;
  76920. /**
  76921. * Set a vec3 in the shader from a Vector3.
  76922. * @param name Define the name of the uniform as defined in the shader
  76923. * @param value Define the value to give to the uniform
  76924. * @return the material itself allowing "fluent" like uniform updates
  76925. */
  76926. setVector3(name: string, value: Vector3): ShaderMaterial;
  76927. /**
  76928. * Set a vec4 in the shader from a Vector4.
  76929. * @param name Define the name of the uniform as defined in the shader
  76930. * @param value Define the value to give to the uniform
  76931. * @return the material itself allowing "fluent" like uniform updates
  76932. */
  76933. setVector4(name: string, value: Vector4): ShaderMaterial;
  76934. /**
  76935. * Set a mat4 in the shader from a Matrix.
  76936. * @param name Define the name of the uniform as defined in the shader
  76937. * @param value Define the value to give to the uniform
  76938. * @return the material itself allowing "fluent" like uniform updates
  76939. */
  76940. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76941. /**
  76942. * Set a mat3 in the shader from a Float32Array.
  76943. * @param name Define the name of the uniform as defined in the shader
  76944. * @param value Define the value to give to the uniform
  76945. * @return the material itself allowing "fluent" like uniform updates
  76946. */
  76947. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76948. /**
  76949. * Set a mat2 in the shader from a Float32Array.
  76950. * @param name Define the name of the uniform as defined in the shader
  76951. * @param value Define the value to give to the uniform
  76952. * @return the material itself allowing "fluent" like uniform updates
  76953. */
  76954. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76955. /**
  76956. * Set a vec2 array in the shader from a number array.
  76957. * @param name Define the name of the uniform as defined in the shader
  76958. * @param value Define the value to give to the uniform
  76959. * @return the material itself allowing "fluent" like uniform updates
  76960. */
  76961. setArray2(name: string, value: number[]): ShaderMaterial;
  76962. /**
  76963. * Set a vec3 array in the shader from a number array.
  76964. * @param name Define the name of the uniform as defined in the shader
  76965. * @param value Define the value to give to the uniform
  76966. * @return the material itself allowing "fluent" like uniform updates
  76967. */
  76968. setArray3(name: string, value: number[]): ShaderMaterial;
  76969. private _checkCache;
  76970. /**
  76971. * Specifies that the submesh is ready to be used
  76972. * @param mesh defines the mesh to check
  76973. * @param subMesh defines which submesh to check
  76974. * @param useInstances specifies that instances should be used
  76975. * @returns a boolean indicating that the submesh is ready or not
  76976. */
  76977. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76978. /**
  76979. * Checks if the material is ready to render the requested mesh
  76980. * @param mesh Define the mesh to render
  76981. * @param useInstances Define whether or not the material is used with instances
  76982. * @returns true if ready, otherwise false
  76983. */
  76984. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76985. /**
  76986. * Binds the world matrix to the material
  76987. * @param world defines the world transformation matrix
  76988. */
  76989. bindOnlyWorldMatrix(world: Matrix): void;
  76990. /**
  76991. * Binds the material to the mesh
  76992. * @param world defines the world transformation matrix
  76993. * @param mesh defines the mesh to bind the material to
  76994. */
  76995. bind(world: Matrix, mesh?: Mesh): void;
  76996. /**
  76997. * Gets the active textures from the material
  76998. * @returns an array of textures
  76999. */
  77000. getActiveTextures(): BaseTexture[];
  77001. /**
  77002. * Specifies if the material uses a texture
  77003. * @param texture defines the texture to check against the material
  77004. * @returns a boolean specifying if the material uses the texture
  77005. */
  77006. hasTexture(texture: BaseTexture): boolean;
  77007. /**
  77008. * Makes a duplicate of the material, and gives it a new name
  77009. * @param name defines the new name for the duplicated material
  77010. * @returns the cloned material
  77011. */
  77012. clone(name: string): ShaderMaterial;
  77013. /**
  77014. * Disposes the material
  77015. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77016. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77017. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77018. */
  77019. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77020. /**
  77021. * Serializes this material in a JSON representation
  77022. * @returns the serialized material object
  77023. */
  77024. serialize(): any;
  77025. /**
  77026. * Creates a shader material from parsed shader material data
  77027. * @param source defines the JSON represnetation of the material
  77028. * @param scene defines the hosting scene
  77029. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77030. * @returns a new material
  77031. */
  77032. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77033. }
  77034. }
  77035. declare module BABYLON {
  77036. /** @hidden */
  77037. export var colorPixelShader: {
  77038. name: string;
  77039. shader: string;
  77040. };
  77041. }
  77042. declare module BABYLON {
  77043. /** @hidden */
  77044. export var colorVertexShader: {
  77045. name: string;
  77046. shader: string;
  77047. };
  77048. }
  77049. declare module BABYLON {
  77050. /**
  77051. * Line mesh
  77052. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77053. */
  77054. export class LinesMesh extends Mesh {
  77055. /**
  77056. * If vertex color should be applied to the mesh
  77057. */
  77058. useVertexColor?: boolean | undefined;
  77059. /**
  77060. * If vertex alpha should be applied to the mesh
  77061. */
  77062. useVertexAlpha?: boolean | undefined;
  77063. /**
  77064. * Color of the line (Default: White)
  77065. */
  77066. color: Color3;
  77067. /**
  77068. * Alpha of the line (Default: 1)
  77069. */
  77070. alpha: number;
  77071. /**
  77072. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77073. * This margin is expressed in world space coordinates, so its value may vary.
  77074. * Default value is 0.1
  77075. */
  77076. intersectionThreshold: number;
  77077. private _colorShader;
  77078. /**
  77079. * Creates a new LinesMesh
  77080. * @param name defines the name
  77081. * @param scene defines the hosting scene
  77082. * @param parent defines the parent mesh if any
  77083. * @param source defines the optional source LinesMesh used to clone data from
  77084. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77085. * When false, achieved by calling a clone(), also passing False.
  77086. * This will make creation of children, recursive.
  77087. * @param useVertexColor defines if this LinesMesh supports vertex color
  77088. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77089. */
  77090. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77091. /**
  77092. * If vertex color should be applied to the mesh
  77093. */
  77094. useVertexColor?: boolean | undefined,
  77095. /**
  77096. * If vertex alpha should be applied to the mesh
  77097. */
  77098. useVertexAlpha?: boolean | undefined);
  77099. private _addClipPlaneDefine;
  77100. private _removeClipPlaneDefine;
  77101. isReady(): boolean;
  77102. /**
  77103. * Returns the string "LineMesh"
  77104. */
  77105. getClassName(): string;
  77106. /**
  77107. * @hidden
  77108. */
  77109. /**
  77110. * @hidden
  77111. */
  77112. material: Material;
  77113. /**
  77114. * @hidden
  77115. */
  77116. readonly checkCollisions: boolean;
  77117. /** @hidden */
  77118. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77119. /** @hidden */
  77120. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77121. /**
  77122. * Disposes of the line mesh
  77123. * @param doNotRecurse If children should be disposed
  77124. */
  77125. dispose(doNotRecurse?: boolean): void;
  77126. /**
  77127. * Returns a new LineMesh object cloned from the current one.
  77128. */
  77129. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77130. /**
  77131. * Creates a new InstancedLinesMesh object from the mesh model.
  77132. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77133. * @param name defines the name of the new instance
  77134. * @returns a new InstancedLinesMesh
  77135. */
  77136. createInstance(name: string): InstancedLinesMesh;
  77137. }
  77138. /**
  77139. * Creates an instance based on a source LinesMesh
  77140. */
  77141. export class InstancedLinesMesh extends InstancedMesh {
  77142. /**
  77143. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77144. * This margin is expressed in world space coordinates, so its value may vary.
  77145. * Initilized with the intersectionThreshold value of the source LinesMesh
  77146. */
  77147. intersectionThreshold: number;
  77148. constructor(name: string, source: LinesMesh);
  77149. /**
  77150. * Returns the string "InstancedLinesMesh".
  77151. */
  77152. getClassName(): string;
  77153. }
  77154. }
  77155. declare module BABYLON {
  77156. /** @hidden */
  77157. export var linePixelShader: {
  77158. name: string;
  77159. shader: string;
  77160. };
  77161. }
  77162. declare module BABYLON {
  77163. /** @hidden */
  77164. export var lineVertexShader: {
  77165. name: string;
  77166. shader: string;
  77167. };
  77168. }
  77169. declare module BABYLON {
  77170. interface AbstractMesh {
  77171. /**
  77172. * Disables the mesh edge rendering mode
  77173. * @returns the currentAbstractMesh
  77174. */
  77175. disableEdgesRendering(): AbstractMesh;
  77176. /**
  77177. * Enables the edge rendering mode on the mesh.
  77178. * This mode makes the mesh edges visible
  77179. * @param epsilon defines the maximal distance between two angles to detect a face
  77180. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77181. * @returns the currentAbstractMesh
  77182. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77183. */
  77184. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77185. /**
  77186. * Gets the edgesRenderer associated with the mesh
  77187. */
  77188. edgesRenderer: Nullable<EdgesRenderer>;
  77189. }
  77190. interface LinesMesh {
  77191. /**
  77192. * Enables the edge rendering mode on the mesh.
  77193. * This mode makes the mesh edges visible
  77194. * @param epsilon defines the maximal distance between two angles to detect a face
  77195. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77196. * @returns the currentAbstractMesh
  77197. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77198. */
  77199. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77200. }
  77201. interface InstancedLinesMesh {
  77202. /**
  77203. * Enables the edge rendering mode on the mesh.
  77204. * This mode makes the mesh edges visible
  77205. * @param epsilon defines the maximal distance between two angles to detect a face
  77206. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77207. * @returns the current InstancedLinesMesh
  77208. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77209. */
  77210. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77211. }
  77212. /**
  77213. * Defines the minimum contract an Edges renderer should follow.
  77214. */
  77215. export interface IEdgesRenderer extends IDisposable {
  77216. /**
  77217. * Gets or sets a boolean indicating if the edgesRenderer is active
  77218. */
  77219. isEnabled: boolean;
  77220. /**
  77221. * Renders the edges of the attached mesh,
  77222. */
  77223. render(): void;
  77224. /**
  77225. * Checks wether or not the edges renderer is ready to render.
  77226. * @return true if ready, otherwise false.
  77227. */
  77228. isReady(): boolean;
  77229. }
  77230. /**
  77231. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77232. */
  77233. export class EdgesRenderer implements IEdgesRenderer {
  77234. /**
  77235. * Define the size of the edges with an orthographic camera
  77236. */
  77237. edgesWidthScalerForOrthographic: number;
  77238. /**
  77239. * Define the size of the edges with a perspective camera
  77240. */
  77241. edgesWidthScalerForPerspective: number;
  77242. protected _source: AbstractMesh;
  77243. protected _linesPositions: number[];
  77244. protected _linesNormals: number[];
  77245. protected _linesIndices: number[];
  77246. protected _epsilon: number;
  77247. protected _indicesCount: number;
  77248. protected _lineShader: ShaderMaterial;
  77249. protected _ib: DataBuffer;
  77250. protected _buffers: {
  77251. [key: string]: Nullable<VertexBuffer>;
  77252. };
  77253. protected _checkVerticesInsteadOfIndices: boolean;
  77254. private _meshRebuildObserver;
  77255. private _meshDisposeObserver;
  77256. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77257. isEnabled: boolean;
  77258. /**
  77259. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77260. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77261. * @param source Mesh used to create edges
  77262. * @param epsilon sum of angles in adjacency to check for edge
  77263. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77264. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77265. */
  77266. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77267. protected _prepareRessources(): void;
  77268. /** @hidden */
  77269. _rebuild(): void;
  77270. /**
  77271. * Releases the required resources for the edges renderer
  77272. */
  77273. dispose(): void;
  77274. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77275. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77276. /**
  77277. * Checks if the pair of p0 and p1 is en edge
  77278. * @param faceIndex
  77279. * @param edge
  77280. * @param faceNormals
  77281. * @param p0
  77282. * @param p1
  77283. * @private
  77284. */
  77285. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77286. /**
  77287. * push line into the position, normal and index buffer
  77288. * @protected
  77289. */
  77290. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77291. /**
  77292. * Generates lines edges from adjacencjes
  77293. * @private
  77294. */
  77295. _generateEdgesLines(): void;
  77296. /**
  77297. * Checks wether or not the edges renderer is ready to render.
  77298. * @return true if ready, otherwise false.
  77299. */
  77300. isReady(): boolean;
  77301. /**
  77302. * Renders the edges of the attached mesh,
  77303. */
  77304. render(): void;
  77305. }
  77306. /**
  77307. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77308. */
  77309. export class LineEdgesRenderer extends EdgesRenderer {
  77310. /**
  77311. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77312. * @param source LineMesh used to generate edges
  77313. * @param epsilon not important (specified angle for edge detection)
  77314. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77315. */
  77316. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77317. /**
  77318. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77319. */
  77320. _generateEdgesLines(): void;
  77321. }
  77322. }
  77323. declare module BABYLON {
  77324. /**
  77325. * This represents the object necessary to create a rendering group.
  77326. * This is exclusively used and created by the rendering manager.
  77327. * To modify the behavior, you use the available helpers in your scene or meshes.
  77328. * @hidden
  77329. */
  77330. export class RenderingGroup {
  77331. index: number;
  77332. private _scene;
  77333. private _opaqueSubMeshes;
  77334. private _transparentSubMeshes;
  77335. private _alphaTestSubMeshes;
  77336. private _depthOnlySubMeshes;
  77337. private _particleSystems;
  77338. private _spriteManagers;
  77339. private _opaqueSortCompareFn;
  77340. private _alphaTestSortCompareFn;
  77341. private _transparentSortCompareFn;
  77342. private _renderOpaque;
  77343. private _renderAlphaTest;
  77344. private _renderTransparent;
  77345. /** @hidden */
  77346. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77347. onBeforeTransparentRendering: () => void;
  77348. /**
  77349. * Set the opaque sort comparison function.
  77350. * If null the sub meshes will be render in the order they were created
  77351. */
  77352. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77353. /**
  77354. * Set the alpha test sort comparison function.
  77355. * If null the sub meshes will be render in the order they were created
  77356. */
  77357. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77358. /**
  77359. * Set the transparent sort comparison function.
  77360. * If null the sub meshes will be render in the order they were created
  77361. */
  77362. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77363. /**
  77364. * Creates a new rendering group.
  77365. * @param index The rendering group index
  77366. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77367. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77368. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77369. */
  77370. 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>);
  77371. /**
  77372. * Render all the sub meshes contained in the group.
  77373. * @param customRenderFunction Used to override the default render behaviour of the group.
  77374. * @returns true if rendered some submeshes.
  77375. */
  77376. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77377. /**
  77378. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77379. * @param subMeshes The submeshes to render
  77380. */
  77381. private renderOpaqueSorted;
  77382. /**
  77383. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77384. * @param subMeshes The submeshes to render
  77385. */
  77386. private renderAlphaTestSorted;
  77387. /**
  77388. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77389. * @param subMeshes The submeshes to render
  77390. */
  77391. private renderTransparentSorted;
  77392. /**
  77393. * Renders the submeshes in a specified order.
  77394. * @param subMeshes The submeshes to sort before render
  77395. * @param sortCompareFn The comparison function use to sort
  77396. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77397. * @param transparent Specifies to activate blending if true
  77398. */
  77399. private static renderSorted;
  77400. /**
  77401. * Renders the submeshes in the order they were dispatched (no sort applied).
  77402. * @param subMeshes The submeshes to render
  77403. */
  77404. private static renderUnsorted;
  77405. /**
  77406. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77407. * are rendered back to front if in the same alpha index.
  77408. *
  77409. * @param a The first submesh
  77410. * @param b The second submesh
  77411. * @returns The result of the comparison
  77412. */
  77413. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77414. /**
  77415. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77416. * are rendered back to front.
  77417. *
  77418. * @param a The first submesh
  77419. * @param b The second submesh
  77420. * @returns The result of the comparison
  77421. */
  77422. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77423. /**
  77424. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77425. * are rendered front to back (prevent overdraw).
  77426. *
  77427. * @param a The first submesh
  77428. * @param b The second submesh
  77429. * @returns The result of the comparison
  77430. */
  77431. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77432. /**
  77433. * Resets the different lists of submeshes to prepare a new frame.
  77434. */
  77435. prepare(): void;
  77436. dispose(): void;
  77437. /**
  77438. * Inserts the submesh in its correct queue depending on its material.
  77439. * @param subMesh The submesh to dispatch
  77440. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77441. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77442. */
  77443. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77444. dispatchSprites(spriteManager: ISpriteManager): void;
  77445. dispatchParticles(particleSystem: IParticleSystem): void;
  77446. private _renderParticles;
  77447. private _renderSprites;
  77448. }
  77449. }
  77450. declare module BABYLON {
  77451. /**
  77452. * Interface describing the different options available in the rendering manager
  77453. * regarding Auto Clear between groups.
  77454. */
  77455. export interface IRenderingManagerAutoClearSetup {
  77456. /**
  77457. * Defines whether or not autoclear is enable.
  77458. */
  77459. autoClear: boolean;
  77460. /**
  77461. * Defines whether or not to autoclear the depth buffer.
  77462. */
  77463. depth: boolean;
  77464. /**
  77465. * Defines whether or not to autoclear the stencil buffer.
  77466. */
  77467. stencil: boolean;
  77468. }
  77469. /**
  77470. * This class is used by the onRenderingGroupObservable
  77471. */
  77472. export class RenderingGroupInfo {
  77473. /**
  77474. * The Scene that being rendered
  77475. */
  77476. scene: Scene;
  77477. /**
  77478. * The camera currently used for the rendering pass
  77479. */
  77480. camera: Nullable<Camera>;
  77481. /**
  77482. * The ID of the renderingGroup being processed
  77483. */
  77484. renderingGroupId: number;
  77485. }
  77486. /**
  77487. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77488. * It is enable to manage the different groups as well as the different necessary sort functions.
  77489. * This should not be used directly aside of the few static configurations
  77490. */
  77491. export class RenderingManager {
  77492. /**
  77493. * The max id used for rendering groups (not included)
  77494. */
  77495. static MAX_RENDERINGGROUPS: number;
  77496. /**
  77497. * The min id used for rendering groups (included)
  77498. */
  77499. static MIN_RENDERINGGROUPS: number;
  77500. /**
  77501. * Used to globally prevent autoclearing scenes.
  77502. */
  77503. static AUTOCLEAR: boolean;
  77504. /**
  77505. * @hidden
  77506. */
  77507. _useSceneAutoClearSetup: boolean;
  77508. private _scene;
  77509. private _renderingGroups;
  77510. private _depthStencilBufferAlreadyCleaned;
  77511. private _autoClearDepthStencil;
  77512. private _customOpaqueSortCompareFn;
  77513. private _customAlphaTestSortCompareFn;
  77514. private _customTransparentSortCompareFn;
  77515. private _renderingGroupInfo;
  77516. /**
  77517. * Instantiates a new rendering group for a particular scene
  77518. * @param scene Defines the scene the groups belongs to
  77519. */
  77520. constructor(scene: Scene);
  77521. private _clearDepthStencilBuffer;
  77522. /**
  77523. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77524. * @hidden
  77525. */
  77526. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77527. /**
  77528. * Resets the different information of the group to prepare a new frame
  77529. * @hidden
  77530. */
  77531. reset(): void;
  77532. /**
  77533. * Dispose and release the group and its associated resources.
  77534. * @hidden
  77535. */
  77536. dispose(): void;
  77537. /**
  77538. * Clear the info related to rendering groups preventing retention points during dispose.
  77539. */
  77540. freeRenderingGroups(): void;
  77541. private _prepareRenderingGroup;
  77542. /**
  77543. * Add a sprite manager to the rendering manager in order to render it this frame.
  77544. * @param spriteManager Define the sprite manager to render
  77545. */
  77546. dispatchSprites(spriteManager: ISpriteManager): void;
  77547. /**
  77548. * Add a particle system to the rendering manager in order to render it this frame.
  77549. * @param particleSystem Define the particle system to render
  77550. */
  77551. dispatchParticles(particleSystem: IParticleSystem): void;
  77552. /**
  77553. * Add a submesh to the manager in order to render it this frame
  77554. * @param subMesh The submesh to dispatch
  77555. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77556. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77557. */
  77558. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77559. /**
  77560. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77561. * This allowed control for front to back rendering or reversly depending of the special needs.
  77562. *
  77563. * @param renderingGroupId The rendering group id corresponding to its index
  77564. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77565. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77566. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77567. */
  77568. 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;
  77569. /**
  77570. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77571. *
  77572. * @param renderingGroupId The rendering group id corresponding to its index
  77573. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77574. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77575. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77576. */
  77577. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77578. /**
  77579. * Gets the current auto clear configuration for one rendering group of the rendering
  77580. * manager.
  77581. * @param index the rendering group index to get the information for
  77582. * @returns The auto clear setup for the requested rendering group
  77583. */
  77584. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77585. }
  77586. }
  77587. declare module BABYLON {
  77588. /**
  77589. * This Helps creating a texture that will be created from a camera in your scene.
  77590. * It is basically a dynamic texture that could be used to create special effects for instance.
  77591. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77592. */
  77593. export class RenderTargetTexture extends Texture {
  77594. isCube: boolean;
  77595. /**
  77596. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77597. */
  77598. static readonly REFRESHRATE_RENDER_ONCE: number;
  77599. /**
  77600. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77601. */
  77602. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77603. /**
  77604. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77605. * the central point of your effect and can save a lot of performances.
  77606. */
  77607. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77608. /**
  77609. * Use this predicate to dynamically define the list of mesh you want to render.
  77610. * If set, the renderList property will be overwritten.
  77611. */
  77612. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77613. private _renderList;
  77614. /**
  77615. * Use this list to define the list of mesh you want to render.
  77616. */
  77617. renderList: Nullable<Array<AbstractMesh>>;
  77618. private _hookArray;
  77619. /**
  77620. * Define if particles should be rendered in your texture.
  77621. */
  77622. renderParticles: boolean;
  77623. /**
  77624. * Define if sprites should be rendered in your texture.
  77625. */
  77626. renderSprites: boolean;
  77627. /**
  77628. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77629. */
  77630. coordinatesMode: number;
  77631. /**
  77632. * Define the camera used to render the texture.
  77633. */
  77634. activeCamera: Nullable<Camera>;
  77635. /**
  77636. * Override the render function of the texture with your own one.
  77637. */
  77638. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77639. /**
  77640. * Define if camera post processes should be use while rendering the texture.
  77641. */
  77642. useCameraPostProcesses: boolean;
  77643. /**
  77644. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77645. */
  77646. ignoreCameraViewport: boolean;
  77647. private _postProcessManager;
  77648. private _postProcesses;
  77649. private _resizeObserver;
  77650. /**
  77651. * An event triggered when the texture is unbind.
  77652. */
  77653. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77654. /**
  77655. * An event triggered when the texture is unbind.
  77656. */
  77657. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77658. private _onAfterUnbindObserver;
  77659. /**
  77660. * Set a after unbind callback in the texture.
  77661. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77662. */
  77663. onAfterUnbind: () => void;
  77664. /**
  77665. * An event triggered before rendering the texture
  77666. */
  77667. onBeforeRenderObservable: Observable<number>;
  77668. private _onBeforeRenderObserver;
  77669. /**
  77670. * Set a before render callback in the texture.
  77671. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77672. */
  77673. onBeforeRender: (faceIndex: number) => void;
  77674. /**
  77675. * An event triggered after rendering the texture
  77676. */
  77677. onAfterRenderObservable: Observable<number>;
  77678. private _onAfterRenderObserver;
  77679. /**
  77680. * Set a after render callback in the texture.
  77681. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77682. */
  77683. onAfterRender: (faceIndex: number) => void;
  77684. /**
  77685. * An event triggered after the texture clear
  77686. */
  77687. onClearObservable: Observable<Engine>;
  77688. private _onClearObserver;
  77689. /**
  77690. * Set a clear callback in the texture.
  77691. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77692. */
  77693. onClear: (Engine: Engine) => void;
  77694. /**
  77695. * Define the clear color of the Render Target if it should be different from the scene.
  77696. */
  77697. clearColor: Color4;
  77698. protected _size: number | {
  77699. width: number;
  77700. height: number;
  77701. };
  77702. protected _initialSizeParameter: number | {
  77703. width: number;
  77704. height: number;
  77705. } | {
  77706. ratio: number;
  77707. };
  77708. protected _sizeRatio: Nullable<number>;
  77709. /** @hidden */
  77710. _generateMipMaps: boolean;
  77711. protected _renderingManager: RenderingManager;
  77712. /** @hidden */
  77713. _waitingRenderList: string[];
  77714. protected _doNotChangeAspectRatio: boolean;
  77715. protected _currentRefreshId: number;
  77716. protected _refreshRate: number;
  77717. protected _textureMatrix: Matrix;
  77718. protected _samples: number;
  77719. protected _renderTargetOptions: RenderTargetCreationOptions;
  77720. /**
  77721. * Gets render target creation options that were used.
  77722. */
  77723. readonly renderTargetOptions: RenderTargetCreationOptions;
  77724. protected _engine: Engine;
  77725. protected _onRatioRescale(): void;
  77726. /**
  77727. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77728. * It must define where the camera used to render the texture is set
  77729. */
  77730. boundingBoxPosition: Vector3;
  77731. private _boundingBoxSize;
  77732. /**
  77733. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77734. * When defined, the cubemap will switch to local mode
  77735. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77736. * @example https://www.babylonjs-playground.com/#RNASML
  77737. */
  77738. boundingBoxSize: Vector3;
  77739. /**
  77740. * In case the RTT has been created with a depth texture, get the associated
  77741. * depth texture.
  77742. * Otherwise, return null.
  77743. */
  77744. depthStencilTexture: Nullable<InternalTexture>;
  77745. /**
  77746. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77747. * or used a shadow, depth texture...
  77748. * @param name The friendly name of the texture
  77749. * @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)
  77750. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77751. * @param generateMipMaps True if mip maps need to be generated after render.
  77752. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77753. * @param type The type of the buffer in the RTT (int, half float, float...)
  77754. * @param isCube True if a cube texture needs to be created
  77755. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77756. * @param generateDepthBuffer True to generate a depth buffer
  77757. * @param generateStencilBuffer True to generate a stencil buffer
  77758. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77759. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77760. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77761. */
  77762. constructor(name: string, size: number | {
  77763. width: number;
  77764. height: number;
  77765. } | {
  77766. ratio: number;
  77767. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77768. /**
  77769. * Creates a depth stencil texture.
  77770. * This is only available in WebGL 2 or with the depth texture extension available.
  77771. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77772. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77773. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77774. */
  77775. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77776. private _processSizeParameter;
  77777. /**
  77778. * Define the number of samples to use in case of MSAA.
  77779. * It defaults to one meaning no MSAA has been enabled.
  77780. */
  77781. samples: number;
  77782. /**
  77783. * Resets the refresh counter of the texture and start bak from scratch.
  77784. * Could be useful to regenerate the texture if it is setup to render only once.
  77785. */
  77786. resetRefreshCounter(): void;
  77787. /**
  77788. * Define the refresh rate of the texture or the rendering frequency.
  77789. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77790. */
  77791. refreshRate: number;
  77792. /**
  77793. * Adds a post process to the render target rendering passes.
  77794. * @param postProcess define the post process to add
  77795. */
  77796. addPostProcess(postProcess: PostProcess): void;
  77797. /**
  77798. * Clear all the post processes attached to the render target
  77799. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77800. */
  77801. clearPostProcesses(dispose?: boolean): void;
  77802. /**
  77803. * Remove one of the post process from the list of attached post processes to the texture
  77804. * @param postProcess define the post process to remove from the list
  77805. */
  77806. removePostProcess(postProcess: PostProcess): void;
  77807. /** @hidden */
  77808. _shouldRender(): boolean;
  77809. /**
  77810. * Gets the actual render size of the texture.
  77811. * @returns the width of the render size
  77812. */
  77813. getRenderSize(): number;
  77814. /**
  77815. * Gets the actual render width of the texture.
  77816. * @returns the width of the render size
  77817. */
  77818. getRenderWidth(): number;
  77819. /**
  77820. * Gets the actual render height of the texture.
  77821. * @returns the height of the render size
  77822. */
  77823. getRenderHeight(): number;
  77824. /**
  77825. * Get if the texture can be rescaled or not.
  77826. */
  77827. readonly canRescale: boolean;
  77828. /**
  77829. * Resize the texture using a ratio.
  77830. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77831. */
  77832. scale(ratio: number): void;
  77833. /**
  77834. * Get the texture reflection matrix used to rotate/transform the reflection.
  77835. * @returns the reflection matrix
  77836. */
  77837. getReflectionTextureMatrix(): Matrix;
  77838. /**
  77839. * Resize the texture to a new desired size.
  77840. * Be carrefull as it will recreate all the data in the new texture.
  77841. * @param size Define the new size. It can be:
  77842. * - a number for squared texture,
  77843. * - an object containing { width: number, height: number }
  77844. * - or an object containing a ratio { ratio: number }
  77845. */
  77846. resize(size: number | {
  77847. width: number;
  77848. height: number;
  77849. } | {
  77850. ratio: number;
  77851. }): void;
  77852. /**
  77853. * Renders all the objects from the render list into the texture.
  77854. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77855. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77856. */
  77857. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77858. private _bestReflectionRenderTargetDimension;
  77859. /**
  77860. * @hidden
  77861. * @param faceIndex face index to bind to if this is a cubetexture
  77862. */
  77863. _bindFrameBuffer(faceIndex?: number): void;
  77864. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77865. private renderToTarget;
  77866. /**
  77867. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77868. * This allowed control for front to back rendering or reversly depending of the special needs.
  77869. *
  77870. * @param renderingGroupId The rendering group id corresponding to its index
  77871. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77872. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77873. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77874. */
  77875. 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;
  77876. /**
  77877. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77878. *
  77879. * @param renderingGroupId The rendering group id corresponding to its index
  77880. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77881. */
  77882. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77883. /**
  77884. * Clones the texture.
  77885. * @returns the cloned texture
  77886. */
  77887. clone(): RenderTargetTexture;
  77888. /**
  77889. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77890. * @returns The JSON representation of the texture
  77891. */
  77892. serialize(): any;
  77893. /**
  77894. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77895. */
  77896. disposeFramebufferObjects(): void;
  77897. /**
  77898. * Dispose the texture and release its associated resources.
  77899. */
  77900. dispose(): void;
  77901. /** @hidden */
  77902. _rebuild(): void;
  77903. /**
  77904. * Clear the info related to rendering groups preventing retention point in material dispose.
  77905. */
  77906. freeRenderingGroups(): void;
  77907. /**
  77908. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77909. * @returns the view count
  77910. */
  77911. getViewCount(): number;
  77912. }
  77913. }
  77914. declare module BABYLON {
  77915. /**
  77916. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77917. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77918. * You can then easily use it as a reflectionTexture on a flat surface.
  77919. * In case the surface is not a plane, please consider relying on reflection probes.
  77920. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77921. */
  77922. export class MirrorTexture extends RenderTargetTexture {
  77923. private scene;
  77924. /**
  77925. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77926. * 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.
  77927. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77928. */
  77929. mirrorPlane: Plane;
  77930. /**
  77931. * Define the blur ratio used to blur the reflection if needed.
  77932. */
  77933. blurRatio: number;
  77934. /**
  77935. * Define the adaptive blur kernel used to blur the reflection if needed.
  77936. * This will autocompute the closest best match for the `blurKernel`
  77937. */
  77938. adaptiveBlurKernel: number;
  77939. /**
  77940. * Define the blur kernel used to blur the reflection if needed.
  77941. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77942. */
  77943. blurKernel: number;
  77944. /**
  77945. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77946. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77947. */
  77948. blurKernelX: number;
  77949. /**
  77950. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77951. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77952. */
  77953. blurKernelY: number;
  77954. private _autoComputeBlurKernel;
  77955. protected _onRatioRescale(): void;
  77956. private _updateGammaSpace;
  77957. private _imageProcessingConfigChangeObserver;
  77958. private _transformMatrix;
  77959. private _mirrorMatrix;
  77960. private _savedViewMatrix;
  77961. private _blurX;
  77962. private _blurY;
  77963. private _adaptiveBlurKernel;
  77964. private _blurKernelX;
  77965. private _blurKernelY;
  77966. private _blurRatio;
  77967. /**
  77968. * Instantiates a Mirror Texture.
  77969. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77970. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77971. * You can then easily use it as a reflectionTexture on a flat surface.
  77972. * In case the surface is not a plane, please consider relying on reflection probes.
  77973. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77974. * @param name
  77975. * @param size
  77976. * @param scene
  77977. * @param generateMipMaps
  77978. * @param type
  77979. * @param samplingMode
  77980. * @param generateDepthBuffer
  77981. */
  77982. constructor(name: string, size: number | {
  77983. width: number;
  77984. height: number;
  77985. } | {
  77986. ratio: number;
  77987. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77988. private _preparePostProcesses;
  77989. /**
  77990. * Clone the mirror texture.
  77991. * @returns the cloned texture
  77992. */
  77993. clone(): MirrorTexture;
  77994. /**
  77995. * Serialize the texture to a JSON representation you could use in Parse later on
  77996. * @returns the serialized JSON representation
  77997. */
  77998. serialize(): any;
  77999. /**
  78000. * Dispose the texture and release its associated resources.
  78001. */
  78002. dispose(): void;
  78003. }
  78004. }
  78005. declare module BABYLON {
  78006. /**
  78007. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78008. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78009. */
  78010. export class Texture extends BaseTexture {
  78011. /** @hidden */
  78012. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78013. /** @hidden */
  78014. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78015. /** @hidden */
  78016. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78017. /** nearest is mag = nearest and min = nearest and mip = linear */
  78018. static readonly NEAREST_SAMPLINGMODE: number;
  78019. /** nearest is mag = nearest and min = nearest and mip = linear */
  78020. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78021. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78022. static readonly BILINEAR_SAMPLINGMODE: number;
  78023. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78024. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78025. /** Trilinear is mag = linear and min = linear and mip = linear */
  78026. static readonly TRILINEAR_SAMPLINGMODE: number;
  78027. /** Trilinear is mag = linear and min = linear and mip = linear */
  78028. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78029. /** mag = nearest and min = nearest and mip = nearest */
  78030. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78031. /** mag = nearest and min = linear and mip = nearest */
  78032. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78033. /** mag = nearest and min = linear and mip = linear */
  78034. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78035. /** mag = nearest and min = linear and mip = none */
  78036. static readonly NEAREST_LINEAR: number;
  78037. /** mag = nearest and min = nearest and mip = none */
  78038. static readonly NEAREST_NEAREST: number;
  78039. /** mag = linear and min = nearest and mip = nearest */
  78040. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78041. /** mag = linear and min = nearest and mip = linear */
  78042. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78043. /** mag = linear and min = linear and mip = none */
  78044. static readonly LINEAR_LINEAR: number;
  78045. /** mag = linear and min = nearest and mip = none */
  78046. static readonly LINEAR_NEAREST: number;
  78047. /** Explicit coordinates mode */
  78048. static readonly EXPLICIT_MODE: number;
  78049. /** Spherical coordinates mode */
  78050. static readonly SPHERICAL_MODE: number;
  78051. /** Planar coordinates mode */
  78052. static readonly PLANAR_MODE: number;
  78053. /** Cubic coordinates mode */
  78054. static readonly CUBIC_MODE: number;
  78055. /** Projection coordinates mode */
  78056. static readonly PROJECTION_MODE: number;
  78057. /** Inverse Cubic coordinates mode */
  78058. static readonly SKYBOX_MODE: number;
  78059. /** Inverse Cubic coordinates mode */
  78060. static readonly INVCUBIC_MODE: number;
  78061. /** Equirectangular coordinates mode */
  78062. static readonly EQUIRECTANGULAR_MODE: number;
  78063. /** Equirectangular Fixed coordinates mode */
  78064. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78065. /** Equirectangular Fixed Mirrored coordinates mode */
  78066. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78067. /** Texture is not repeating outside of 0..1 UVs */
  78068. static readonly CLAMP_ADDRESSMODE: number;
  78069. /** Texture is repeating outside of 0..1 UVs */
  78070. static readonly WRAP_ADDRESSMODE: number;
  78071. /** Texture is repeating and mirrored */
  78072. static readonly MIRROR_ADDRESSMODE: number;
  78073. /**
  78074. * 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
  78075. */
  78076. static UseSerializedUrlIfAny: boolean;
  78077. /**
  78078. * Define the url of the texture.
  78079. */
  78080. url: Nullable<string>;
  78081. /**
  78082. * Define an offset on the texture to offset the u coordinates of the UVs
  78083. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78084. */
  78085. uOffset: number;
  78086. /**
  78087. * Define an offset on the texture to offset the v coordinates of the UVs
  78088. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78089. */
  78090. vOffset: number;
  78091. /**
  78092. * Define an offset on the texture to scale the u coordinates of the UVs
  78093. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78094. */
  78095. uScale: number;
  78096. /**
  78097. * Define an offset on the texture to scale the v coordinates of the UVs
  78098. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78099. */
  78100. vScale: number;
  78101. /**
  78102. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78103. * @see http://doc.babylonjs.com/how_to/more_materials
  78104. */
  78105. uAng: number;
  78106. /**
  78107. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78108. * @see http://doc.babylonjs.com/how_to/more_materials
  78109. */
  78110. vAng: number;
  78111. /**
  78112. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78113. * @see http://doc.babylonjs.com/how_to/more_materials
  78114. */
  78115. wAng: number;
  78116. /**
  78117. * Defines the center of rotation (U)
  78118. */
  78119. uRotationCenter: number;
  78120. /**
  78121. * Defines the center of rotation (V)
  78122. */
  78123. vRotationCenter: number;
  78124. /**
  78125. * Defines the center of rotation (W)
  78126. */
  78127. wRotationCenter: number;
  78128. /**
  78129. * Are mip maps generated for this texture or not.
  78130. */
  78131. readonly noMipmap: boolean;
  78132. /**
  78133. * List of inspectable custom properties (used by the Inspector)
  78134. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78135. */
  78136. inspectableCustomProperties: Nullable<IInspectable[]>;
  78137. private _noMipmap;
  78138. /** @hidden */
  78139. _invertY: boolean;
  78140. private _rowGenerationMatrix;
  78141. private _cachedTextureMatrix;
  78142. private _projectionModeMatrix;
  78143. private _t0;
  78144. private _t1;
  78145. private _t2;
  78146. private _cachedUOffset;
  78147. private _cachedVOffset;
  78148. private _cachedUScale;
  78149. private _cachedVScale;
  78150. private _cachedUAng;
  78151. private _cachedVAng;
  78152. private _cachedWAng;
  78153. private _cachedProjectionMatrixId;
  78154. private _cachedCoordinatesMode;
  78155. /** @hidden */
  78156. protected _initialSamplingMode: number;
  78157. /** @hidden */
  78158. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78159. private _deleteBuffer;
  78160. protected _format: Nullable<number>;
  78161. private _delayedOnLoad;
  78162. private _delayedOnError;
  78163. /**
  78164. * Observable triggered once the texture has been loaded.
  78165. */
  78166. onLoadObservable: Observable<Texture>;
  78167. protected _isBlocking: boolean;
  78168. /**
  78169. * Is the texture preventing material to render while loading.
  78170. * If false, a default texture will be used instead of the loading one during the preparation step.
  78171. */
  78172. isBlocking: boolean;
  78173. /**
  78174. * Get the current sampling mode associated with the texture.
  78175. */
  78176. readonly samplingMode: number;
  78177. /**
  78178. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78179. */
  78180. readonly invertY: boolean;
  78181. /**
  78182. * Instantiates a new texture.
  78183. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78184. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78185. * @param url define the url of the picture to load as a texture
  78186. * @param scene define the scene the texture will belong to
  78187. * @param noMipmap define if the texture will require mip maps or not
  78188. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78189. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78190. * @param onLoad define a callback triggered when the texture has been loaded
  78191. * @param onError define a callback triggered when an error occurred during the loading session
  78192. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78193. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78194. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78195. */
  78196. 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);
  78197. /**
  78198. * Update the url (and optional buffer) of this texture if url was null during construction.
  78199. * @param url the url of the texture
  78200. * @param buffer the buffer of the texture (defaults to null)
  78201. * @param onLoad callback called when the texture is loaded (defaults to null)
  78202. */
  78203. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78204. /**
  78205. * Finish the loading sequence of a texture flagged as delayed load.
  78206. * @hidden
  78207. */
  78208. delayLoad(): void;
  78209. private _prepareRowForTextureGeneration;
  78210. /**
  78211. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78212. * @returns the transform matrix of the texture.
  78213. */
  78214. getTextureMatrix(): Matrix;
  78215. /**
  78216. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78217. * @returns The reflection texture transform
  78218. */
  78219. getReflectionTextureMatrix(): Matrix;
  78220. /**
  78221. * Clones the texture.
  78222. * @returns the cloned texture
  78223. */
  78224. clone(): Texture;
  78225. /**
  78226. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78227. * @returns The JSON representation of the texture
  78228. */
  78229. serialize(): any;
  78230. /**
  78231. * Get the current class name of the texture useful for serialization or dynamic coding.
  78232. * @returns "Texture"
  78233. */
  78234. getClassName(): string;
  78235. /**
  78236. * Dispose the texture and release its associated resources.
  78237. */
  78238. dispose(): void;
  78239. /**
  78240. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78241. * @param parsedTexture Define the JSON representation of the texture
  78242. * @param scene Define the scene the parsed texture should be instantiated in
  78243. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78244. * @returns The parsed texture if successful
  78245. */
  78246. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78247. /**
  78248. * Creates a texture from its base 64 representation.
  78249. * @param data Define the base64 payload without the data: prefix
  78250. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78251. * @param scene Define the scene the texture should belong to
  78252. * @param noMipmap Forces the texture to not create mip map information if true
  78253. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78254. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78255. * @param onLoad define a callback triggered when the texture has been loaded
  78256. * @param onError define a callback triggered when an error occurred during the loading session
  78257. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78258. * @returns the created texture
  78259. */
  78260. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78261. /**
  78262. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78263. * @param data Define the base64 payload without the data: prefix
  78264. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78265. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78266. * @param scene Define the scene the texture should belong to
  78267. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78268. * @param noMipmap Forces the texture to not create mip map information if true
  78269. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78270. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78271. * @param onLoad define a callback triggered when the texture has been loaded
  78272. * @param onError define a callback triggered when an error occurred during the loading session
  78273. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78274. * @returns the created texture
  78275. */
  78276. 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;
  78277. }
  78278. }
  78279. declare module BABYLON {
  78280. interface Engine {
  78281. /**
  78282. * Creates a raw texture
  78283. * @param data defines the data to store in the texture
  78284. * @param width defines the width of the texture
  78285. * @param height defines the height of the texture
  78286. * @param format defines the format of the data
  78287. * @param generateMipMaps defines if the engine should generate the mip levels
  78288. * @param invertY defines if data must be stored with Y axis inverted
  78289. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78290. * @param compression defines the compression used (null by default)
  78291. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78292. * @returns the raw texture inside an InternalTexture
  78293. */
  78294. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78295. /**
  78296. * Update a raw texture
  78297. * @param texture defines the texture to update
  78298. * @param data defines the data to store in the texture
  78299. * @param format defines the format of the data
  78300. * @param invertY defines if data must be stored with Y axis inverted
  78301. */
  78302. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78303. /**
  78304. * Update a raw texture
  78305. * @param texture defines the texture to update
  78306. * @param data defines the data to store in the texture
  78307. * @param format defines the format of the data
  78308. * @param invertY defines if data must be stored with Y axis inverted
  78309. * @param compression defines the compression used (null by default)
  78310. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78311. */
  78312. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78313. /**
  78314. * Creates a new raw cube texture
  78315. * @param data defines the array of data to use to create each face
  78316. * @param size defines the size of the textures
  78317. * @param format defines the format of the data
  78318. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78319. * @param generateMipMaps defines if the engine should generate the mip levels
  78320. * @param invertY defines if data must be stored with Y axis inverted
  78321. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78322. * @param compression defines the compression used (null by default)
  78323. * @returns the cube texture as an InternalTexture
  78324. */
  78325. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78326. /**
  78327. * Update a raw cube texture
  78328. * @param texture defines the texture to udpdate
  78329. * @param data defines the data to store
  78330. * @param format defines the data format
  78331. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78332. * @param invertY defines if data must be stored with Y axis inverted
  78333. */
  78334. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78335. /**
  78336. * Update a raw cube texture
  78337. * @param texture defines the texture to udpdate
  78338. * @param data defines the data to store
  78339. * @param format defines the data format
  78340. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78341. * @param invertY defines if data must be stored with Y axis inverted
  78342. * @param compression defines the compression used (null by default)
  78343. */
  78344. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78345. /**
  78346. * Update a raw cube texture
  78347. * @param texture defines the texture to udpdate
  78348. * @param data defines the data to store
  78349. * @param format defines the data format
  78350. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78351. * @param invertY defines if data must be stored with Y axis inverted
  78352. * @param compression defines the compression used (null by default)
  78353. * @param level defines which level of the texture to update
  78354. */
  78355. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78356. /**
  78357. * Creates a new raw cube texture from a specified url
  78358. * @param url defines the url where the data is located
  78359. * @param scene defines the current scene
  78360. * @param size defines the size of the textures
  78361. * @param format defines the format of the data
  78362. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78363. * @param noMipmap defines if the engine should avoid generating the mip levels
  78364. * @param callback defines a callback used to extract texture data from loaded data
  78365. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78366. * @param onLoad defines a callback called when texture is loaded
  78367. * @param onError defines a callback called if there is an error
  78368. * @returns the cube texture as an InternalTexture
  78369. */
  78370. 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;
  78371. /**
  78372. * Creates a new raw cube texture from a specified url
  78373. * @param url defines the url where the data is located
  78374. * @param scene defines the current scene
  78375. * @param size defines the size of the textures
  78376. * @param format defines the format of the data
  78377. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78378. * @param noMipmap defines if the engine should avoid generating the mip levels
  78379. * @param callback defines a callback used to extract texture data from loaded data
  78380. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78381. * @param onLoad defines a callback called when texture is loaded
  78382. * @param onError defines a callback called if there is an error
  78383. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78384. * @param invertY defines if data must be stored with Y axis inverted
  78385. * @returns the cube texture as an InternalTexture
  78386. */
  78387. 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;
  78388. /**
  78389. * Creates a new raw 3D texture
  78390. * @param data defines the data used to create the texture
  78391. * @param width defines the width of the texture
  78392. * @param height defines the height of the texture
  78393. * @param depth defines the depth of the texture
  78394. * @param format defines the format of the texture
  78395. * @param generateMipMaps defines if the engine must generate mip levels
  78396. * @param invertY defines if data must be stored with Y axis inverted
  78397. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78398. * @param compression defines the compressed used (can be null)
  78399. * @param textureType defines the compressed used (can be null)
  78400. * @returns a new raw 3D texture (stored in an InternalTexture)
  78401. */
  78402. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78403. /**
  78404. * Update a raw 3D texture
  78405. * @param texture defines the texture to update
  78406. * @param data defines the data to store
  78407. * @param format defines the data format
  78408. * @param invertY defines if data must be stored with Y axis inverted
  78409. */
  78410. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78411. /**
  78412. * Update a raw 3D texture
  78413. * @param texture defines the texture to update
  78414. * @param data defines the data to store
  78415. * @param format defines the data format
  78416. * @param invertY defines if data must be stored with Y axis inverted
  78417. * @param compression defines the used compression (can be null)
  78418. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78419. */
  78420. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78421. }
  78422. }
  78423. declare module BABYLON {
  78424. /**
  78425. * Raw texture can help creating a texture directly from an array of data.
  78426. * This can be super useful if you either get the data from an uncompressed source or
  78427. * if you wish to create your texture pixel by pixel.
  78428. */
  78429. export class RawTexture extends Texture {
  78430. /**
  78431. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78432. */
  78433. format: number;
  78434. private _engine;
  78435. /**
  78436. * Instantiates a new RawTexture.
  78437. * Raw texture can help creating a texture directly from an array of data.
  78438. * This can be super useful if you either get the data from an uncompressed source or
  78439. * if you wish to create your texture pixel by pixel.
  78440. * @param data define the array of data to use to create the texture
  78441. * @param width define the width of the texture
  78442. * @param height define the height of the texture
  78443. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78444. * @param scene define the scene the texture belongs to
  78445. * @param generateMipMaps define whether mip maps should be generated or not
  78446. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78447. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78448. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78449. */
  78450. constructor(data: ArrayBufferView, width: number, height: number,
  78451. /**
  78452. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78453. */
  78454. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78455. /**
  78456. * Updates the texture underlying data.
  78457. * @param data Define the new data of the texture
  78458. */
  78459. update(data: ArrayBufferView): void;
  78460. /**
  78461. * Creates a luminance texture from some data.
  78462. * @param data Define the texture data
  78463. * @param width Define the width of the texture
  78464. * @param height Define the height of the texture
  78465. * @param scene Define the scene the texture belongs to
  78466. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78467. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78468. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78469. * @returns the luminance texture
  78470. */
  78471. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78472. /**
  78473. * Creates a luminance alpha texture from some data.
  78474. * @param data Define the texture data
  78475. * @param width Define the width of the texture
  78476. * @param height Define the height of the texture
  78477. * @param scene Define the scene the texture belongs to
  78478. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78479. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78480. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78481. * @returns the luminance alpha texture
  78482. */
  78483. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78484. /**
  78485. * Creates an alpha texture from some data.
  78486. * @param data Define the texture data
  78487. * @param width Define the width of the texture
  78488. * @param height Define the height of the texture
  78489. * @param scene Define the scene the texture belongs to
  78490. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78493. * @returns the alpha texture
  78494. */
  78495. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78496. /**
  78497. * Creates a RGB texture from some data.
  78498. * @param data Define the texture data
  78499. * @param width Define the width of the texture
  78500. * @param height Define the height of the texture
  78501. * @param scene Define the scene the texture belongs to
  78502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78505. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78506. * @returns the RGB alpha texture
  78507. */
  78508. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78509. /**
  78510. * Creates a RGBA texture from some data.
  78511. * @param data Define the texture data
  78512. * @param width Define the width of the texture
  78513. * @param height Define the height of the texture
  78514. * @param scene Define the scene the texture belongs to
  78515. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78516. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78517. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78518. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78519. * @returns the RGBA texture
  78520. */
  78521. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78522. /**
  78523. * Creates a R 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78532. * @returns the R texture
  78533. */
  78534. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78535. }
  78536. }
  78537. declare module BABYLON {
  78538. /**
  78539. * Defines a runtime animation
  78540. */
  78541. export class RuntimeAnimation {
  78542. private _events;
  78543. /**
  78544. * The current frame of the runtime animation
  78545. */
  78546. private _currentFrame;
  78547. /**
  78548. * The animation used by the runtime animation
  78549. */
  78550. private _animation;
  78551. /**
  78552. * The target of the runtime animation
  78553. */
  78554. private _target;
  78555. /**
  78556. * The initiating animatable
  78557. */
  78558. private _host;
  78559. /**
  78560. * The original value of the runtime animation
  78561. */
  78562. private _originalValue;
  78563. /**
  78564. * The original blend value of the runtime animation
  78565. */
  78566. private _originalBlendValue;
  78567. /**
  78568. * The offsets cache of the runtime animation
  78569. */
  78570. private _offsetsCache;
  78571. /**
  78572. * The high limits cache of the runtime animation
  78573. */
  78574. private _highLimitsCache;
  78575. /**
  78576. * Specifies if the runtime animation has been stopped
  78577. */
  78578. private _stopped;
  78579. /**
  78580. * The blending factor of the runtime animation
  78581. */
  78582. private _blendingFactor;
  78583. /**
  78584. * The BabylonJS scene
  78585. */
  78586. private _scene;
  78587. /**
  78588. * The current value of the runtime animation
  78589. */
  78590. private _currentValue;
  78591. /** @hidden */
  78592. _animationState: _IAnimationState;
  78593. /**
  78594. * The active target of the runtime animation
  78595. */
  78596. private _activeTargets;
  78597. private _currentActiveTarget;
  78598. private _directTarget;
  78599. /**
  78600. * The target path of the runtime animation
  78601. */
  78602. private _targetPath;
  78603. /**
  78604. * The weight of the runtime animation
  78605. */
  78606. private _weight;
  78607. /**
  78608. * The ratio offset of the runtime animation
  78609. */
  78610. private _ratioOffset;
  78611. /**
  78612. * The previous delay of the runtime animation
  78613. */
  78614. private _previousDelay;
  78615. /**
  78616. * The previous ratio of the runtime animation
  78617. */
  78618. private _previousRatio;
  78619. private _enableBlending;
  78620. private _keys;
  78621. private _minFrame;
  78622. private _maxFrame;
  78623. private _minValue;
  78624. private _maxValue;
  78625. private _targetIsArray;
  78626. /**
  78627. * Gets the current frame of the runtime animation
  78628. */
  78629. readonly currentFrame: number;
  78630. /**
  78631. * Gets the weight of the runtime animation
  78632. */
  78633. readonly weight: number;
  78634. /**
  78635. * Gets the current value of the runtime animation
  78636. */
  78637. readonly currentValue: any;
  78638. /**
  78639. * Gets the target path of the runtime animation
  78640. */
  78641. readonly targetPath: string;
  78642. /**
  78643. * Gets the actual target of the runtime animation
  78644. */
  78645. readonly target: any;
  78646. /** @hidden */
  78647. _onLoop: () => void;
  78648. /**
  78649. * Create a new RuntimeAnimation object
  78650. * @param target defines the target of the animation
  78651. * @param animation defines the source animation object
  78652. * @param scene defines the hosting scene
  78653. * @param host defines the initiating Animatable
  78654. */
  78655. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78656. private _preparePath;
  78657. /**
  78658. * Gets the animation from the runtime animation
  78659. */
  78660. readonly animation: Animation;
  78661. /**
  78662. * Resets the runtime animation to the beginning
  78663. * @param restoreOriginal defines whether to restore the target property to the original value
  78664. */
  78665. reset(restoreOriginal?: boolean): void;
  78666. /**
  78667. * Specifies if the runtime animation is stopped
  78668. * @returns Boolean specifying if the runtime animation is stopped
  78669. */
  78670. isStopped(): boolean;
  78671. /**
  78672. * Disposes of the runtime animation
  78673. */
  78674. dispose(): void;
  78675. /**
  78676. * Apply the interpolated value to the target
  78677. * @param currentValue defines the value computed by the animation
  78678. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78679. */
  78680. setValue(currentValue: any, weight: number): void;
  78681. private _getOriginalValues;
  78682. private _setValue;
  78683. /**
  78684. * Gets the loop pmode of the runtime animation
  78685. * @returns Loop Mode
  78686. */
  78687. private _getCorrectLoopMode;
  78688. /**
  78689. * Move the current animation to a given frame
  78690. * @param frame defines the frame to move to
  78691. */
  78692. goToFrame(frame: number): void;
  78693. /**
  78694. * @hidden Internal use only
  78695. */
  78696. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78697. /**
  78698. * Execute the current animation
  78699. * @param delay defines the delay to add to the current frame
  78700. * @param from defines the lower bound of the animation range
  78701. * @param to defines the upper bound of the animation range
  78702. * @param loop defines if the current animation must loop
  78703. * @param speedRatio defines the current speed ratio
  78704. * @param weight defines the weight of the animation (default is -1 so no weight)
  78705. * @param onLoop optional callback called when animation loops
  78706. * @returns a boolean indicating if the animation is running
  78707. */
  78708. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78709. }
  78710. }
  78711. declare module BABYLON {
  78712. /**
  78713. * Class used to store an actual running animation
  78714. */
  78715. export class Animatable {
  78716. /** defines the target object */
  78717. target: any;
  78718. /** defines the starting frame number (default is 0) */
  78719. fromFrame: number;
  78720. /** defines the ending frame number (default is 100) */
  78721. toFrame: number;
  78722. /** defines if the animation must loop (default is false) */
  78723. loopAnimation: boolean;
  78724. /** defines a callback to call when animation ends if it is not looping */
  78725. onAnimationEnd?: (() => void) | null | undefined;
  78726. /** defines a callback to call when animation loops */
  78727. onAnimationLoop?: (() => void) | null | undefined;
  78728. private _localDelayOffset;
  78729. private _pausedDelay;
  78730. private _runtimeAnimations;
  78731. private _paused;
  78732. private _scene;
  78733. private _speedRatio;
  78734. private _weight;
  78735. private _syncRoot;
  78736. /**
  78737. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78738. * This will only apply for non looping animation (default is true)
  78739. */
  78740. disposeOnEnd: boolean;
  78741. /**
  78742. * Gets a boolean indicating if the animation has started
  78743. */
  78744. animationStarted: boolean;
  78745. /**
  78746. * Observer raised when the animation ends
  78747. */
  78748. onAnimationEndObservable: Observable<Animatable>;
  78749. /**
  78750. * Observer raised when the animation loops
  78751. */
  78752. onAnimationLoopObservable: Observable<Animatable>;
  78753. /**
  78754. * Gets the root Animatable used to synchronize and normalize animations
  78755. */
  78756. readonly syncRoot: Nullable<Animatable>;
  78757. /**
  78758. * Gets the current frame of the first RuntimeAnimation
  78759. * Used to synchronize Animatables
  78760. */
  78761. readonly masterFrame: number;
  78762. /**
  78763. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78764. */
  78765. weight: number;
  78766. /**
  78767. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78768. */
  78769. speedRatio: number;
  78770. /**
  78771. * Creates a new Animatable
  78772. * @param scene defines the hosting scene
  78773. * @param target defines the target object
  78774. * @param fromFrame defines the starting frame number (default is 0)
  78775. * @param toFrame defines the ending frame number (default is 100)
  78776. * @param loopAnimation defines if the animation must loop (default is false)
  78777. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78778. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78779. * @param animations defines a group of animation to add to the new Animatable
  78780. * @param onAnimationLoop defines a callback to call when animation loops
  78781. */
  78782. constructor(scene: Scene,
  78783. /** defines the target object */
  78784. target: any,
  78785. /** defines the starting frame number (default is 0) */
  78786. fromFrame?: number,
  78787. /** defines the ending frame number (default is 100) */
  78788. toFrame?: number,
  78789. /** defines if the animation must loop (default is false) */
  78790. loopAnimation?: boolean, speedRatio?: number,
  78791. /** defines a callback to call when animation ends if it is not looping */
  78792. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78793. /** defines a callback to call when animation loops */
  78794. onAnimationLoop?: (() => void) | null | undefined);
  78795. /**
  78796. * Synchronize and normalize current Animatable with a source Animatable
  78797. * This is useful when using animation weights and when animations are not of the same length
  78798. * @param root defines the root Animatable to synchronize with
  78799. * @returns the current Animatable
  78800. */
  78801. syncWith(root: Animatable): Animatable;
  78802. /**
  78803. * Gets the list of runtime animations
  78804. * @returns an array of RuntimeAnimation
  78805. */
  78806. getAnimations(): RuntimeAnimation[];
  78807. /**
  78808. * Adds more animations to the current animatable
  78809. * @param target defines the target of the animations
  78810. * @param animations defines the new animations to add
  78811. */
  78812. appendAnimations(target: any, animations: Animation[]): void;
  78813. /**
  78814. * Gets the source animation for a specific property
  78815. * @param property defines the propertyu to look for
  78816. * @returns null or the source animation for the given property
  78817. */
  78818. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78819. /**
  78820. * Gets the runtime animation for a specific property
  78821. * @param property defines the propertyu to look for
  78822. * @returns null or the runtime animation for the given property
  78823. */
  78824. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78825. /**
  78826. * Resets the animatable to its original state
  78827. */
  78828. reset(): void;
  78829. /**
  78830. * Allows the animatable to blend with current running animations
  78831. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78832. * @param blendingSpeed defines the blending speed to use
  78833. */
  78834. enableBlending(blendingSpeed: number): void;
  78835. /**
  78836. * Disable animation blending
  78837. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78838. */
  78839. disableBlending(): void;
  78840. /**
  78841. * Jump directly to a given frame
  78842. * @param frame defines the frame to jump to
  78843. */
  78844. goToFrame(frame: number): void;
  78845. /**
  78846. * Pause the animation
  78847. */
  78848. pause(): void;
  78849. /**
  78850. * Restart the animation
  78851. */
  78852. restart(): void;
  78853. private _raiseOnAnimationEnd;
  78854. /**
  78855. * Stop and delete the current animation
  78856. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78857. * @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)
  78858. */
  78859. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78860. /**
  78861. * Wait asynchronously for the animation to end
  78862. * @returns a promise which will be fullfilled when the animation ends
  78863. */
  78864. waitAsync(): Promise<Animatable>;
  78865. /** @hidden */
  78866. _animate(delay: number): boolean;
  78867. }
  78868. interface Scene {
  78869. /** @hidden */
  78870. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78871. /** @hidden */
  78872. _processLateAnimationBindingsForMatrices(holder: {
  78873. totalWeight: number;
  78874. animations: RuntimeAnimation[];
  78875. originalValue: Matrix;
  78876. }): any;
  78877. /** @hidden */
  78878. _processLateAnimationBindingsForQuaternions(holder: {
  78879. totalWeight: number;
  78880. animations: RuntimeAnimation[];
  78881. originalValue: Quaternion;
  78882. }, refQuaternion: Quaternion): Quaternion;
  78883. /** @hidden */
  78884. _processLateAnimationBindings(): void;
  78885. /**
  78886. * Will start the animation sequence of a given target
  78887. * @param target defines the target
  78888. * @param from defines from which frame should animation start
  78889. * @param to defines until which frame should animation run.
  78890. * @param weight defines the weight to apply to the animation (1.0 by default)
  78891. * @param loop defines if the animation loops
  78892. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78893. * @param onAnimationEnd defines the function to be executed when the animation ends
  78894. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78895. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78896. * @param onAnimationLoop defines the callback to call when an animation loops
  78897. * @returns the animatable object created for this animation
  78898. */
  78899. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78900. /**
  78901. * Will start the animation sequence of a given target
  78902. * @param target defines the target
  78903. * @param from defines from which frame should animation start
  78904. * @param to defines until which frame should animation run.
  78905. * @param loop defines if the animation loops
  78906. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78907. * @param onAnimationEnd defines the function to be executed when the animation ends
  78908. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78909. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78910. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78911. * @param onAnimationLoop defines the callback to call when an animation loops
  78912. * @returns the animatable object created for this animation
  78913. */
  78914. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78915. /**
  78916. * Will start the animation sequence of a given target and its hierarchy
  78917. * @param target defines the target
  78918. * @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.
  78919. * @param from defines from which frame should animation start
  78920. * @param to defines until which frame should animation run.
  78921. * @param loop defines if the animation loops
  78922. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78923. * @param onAnimationEnd defines the function to be executed when the animation ends
  78924. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78925. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78926. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78927. * @param onAnimationLoop defines the callback to call when an animation loops
  78928. * @returns the list of created animatables
  78929. */
  78930. 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[];
  78931. /**
  78932. * Begin a new animation on a given node
  78933. * @param target defines the target where the animation will take place
  78934. * @param animations defines the list of animations to start
  78935. * @param from defines the initial value
  78936. * @param to defines the final value
  78937. * @param loop defines if you want animation to loop (off by default)
  78938. * @param speedRatio defines the speed ratio to apply to all animations
  78939. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78940. * @param onAnimationLoop defines the callback to call when an animation loops
  78941. * @returns the list of created animatables
  78942. */
  78943. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78944. /**
  78945. * Begin a new animation on a given node and its hierarchy
  78946. * @param target defines the root node where the animation will take place
  78947. * @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.
  78948. * @param animations defines the list of animations to start
  78949. * @param from defines the initial value
  78950. * @param to defines the final value
  78951. * @param loop defines if you want animation to loop (off by default)
  78952. * @param speedRatio defines the speed ratio to apply to all animations
  78953. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78954. * @param onAnimationLoop defines the callback to call when an animation loops
  78955. * @returns the list of animatables created for all nodes
  78956. */
  78957. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78958. /**
  78959. * Gets the animatable associated with a specific target
  78960. * @param target defines the target of the animatable
  78961. * @returns the required animatable if found
  78962. */
  78963. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78964. /**
  78965. * Gets all animatables associated with a given target
  78966. * @param target defines the target to look animatables for
  78967. * @returns an array of Animatables
  78968. */
  78969. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78970. /**
  78971. * Will stop the animation of the given target
  78972. * @param target - the target
  78973. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78974. * @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)
  78975. */
  78976. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78977. /**
  78978. * Stops and removes all animations that have been applied to the scene
  78979. */
  78980. stopAllAnimations(): void;
  78981. }
  78982. interface Bone {
  78983. /**
  78984. * Copy an animation range from another bone
  78985. * @param source defines the source bone
  78986. * @param rangeName defines the range name to copy
  78987. * @param frameOffset defines the frame offset
  78988. * @param rescaleAsRequired defines if rescaling must be applied if required
  78989. * @param skelDimensionsRatio defines the scaling ratio
  78990. * @returns true if operation was successful
  78991. */
  78992. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78993. }
  78994. }
  78995. declare module BABYLON {
  78996. /**
  78997. * Class used to handle skinning animations
  78998. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78999. */
  79000. export class Skeleton implements IAnimatable {
  79001. /** defines the skeleton name */
  79002. name: string;
  79003. /** defines the skeleton Id */
  79004. id: string;
  79005. /**
  79006. * Defines the list of child bones
  79007. */
  79008. bones: Bone[];
  79009. /**
  79010. * Defines an estimate of the dimension of the skeleton at rest
  79011. */
  79012. dimensionsAtRest: Vector3;
  79013. /**
  79014. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79015. */
  79016. needInitialSkinMatrix: boolean;
  79017. /**
  79018. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79019. */
  79020. overrideMesh: Nullable<AbstractMesh>;
  79021. /**
  79022. * Gets the list of animations attached to this skeleton
  79023. */
  79024. animations: Array<Animation>;
  79025. private _scene;
  79026. private _isDirty;
  79027. private _transformMatrices;
  79028. private _transformMatrixTexture;
  79029. private _meshesWithPoseMatrix;
  79030. private _animatables;
  79031. private _identity;
  79032. private _synchronizedWithMesh;
  79033. private _ranges;
  79034. private _lastAbsoluteTransformsUpdateId;
  79035. private _canUseTextureForBones;
  79036. private _uniqueId;
  79037. /** @hidden */
  79038. _numBonesWithLinkedTransformNode: number;
  79039. /**
  79040. * Specifies if the skeleton should be serialized
  79041. */
  79042. doNotSerialize: boolean;
  79043. private _useTextureToStoreBoneMatrices;
  79044. /**
  79045. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79046. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79047. */
  79048. useTextureToStoreBoneMatrices: boolean;
  79049. private _animationPropertiesOverride;
  79050. /**
  79051. * Gets or sets the animation properties override
  79052. */
  79053. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79054. /**
  79055. * List of inspectable custom properties (used by the Inspector)
  79056. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79057. */
  79058. inspectableCustomProperties: IInspectable[];
  79059. /**
  79060. * An observable triggered before computing the skeleton's matrices
  79061. */
  79062. onBeforeComputeObservable: Observable<Skeleton>;
  79063. /**
  79064. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79065. */
  79066. readonly isUsingTextureForMatrices: boolean;
  79067. /**
  79068. * Gets the unique ID of this skeleton
  79069. */
  79070. readonly uniqueId: number;
  79071. /**
  79072. * Creates a new skeleton
  79073. * @param name defines the skeleton name
  79074. * @param id defines the skeleton Id
  79075. * @param scene defines the hosting scene
  79076. */
  79077. constructor(
  79078. /** defines the skeleton name */
  79079. name: string,
  79080. /** defines the skeleton Id */
  79081. id: string, scene: Scene);
  79082. /**
  79083. * Gets the current object class name.
  79084. * @return the class name
  79085. */
  79086. getClassName(): string;
  79087. /**
  79088. * Returns an array containing the root bones
  79089. * @returns an array containing the root bones
  79090. */
  79091. getChildren(): Array<Bone>;
  79092. /**
  79093. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79094. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79095. * @returns a Float32Array containing matrices data
  79096. */
  79097. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79098. /**
  79099. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79100. * @returns a raw texture containing the data
  79101. */
  79102. getTransformMatrixTexture(): Nullable<RawTexture>;
  79103. /**
  79104. * Gets the current hosting scene
  79105. * @returns a scene object
  79106. */
  79107. getScene(): Scene;
  79108. /**
  79109. * Gets a string representing the current skeleton data
  79110. * @param fullDetails defines a boolean indicating if we want a verbose version
  79111. * @returns a string representing the current skeleton data
  79112. */
  79113. toString(fullDetails?: boolean): string;
  79114. /**
  79115. * Get bone's index searching by name
  79116. * @param name defines bone's name to search for
  79117. * @return the indice of the bone. Returns -1 if not found
  79118. */
  79119. getBoneIndexByName(name: string): number;
  79120. /**
  79121. * Creater a new animation range
  79122. * @param name defines the name of the range
  79123. * @param from defines the start key
  79124. * @param to defines the end key
  79125. */
  79126. createAnimationRange(name: string, from: number, to: number): void;
  79127. /**
  79128. * Delete a specific animation range
  79129. * @param name defines the name of the range
  79130. * @param deleteFrames defines if frames must be removed as well
  79131. */
  79132. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79133. /**
  79134. * Gets a specific animation range
  79135. * @param name defines the name of the range to look for
  79136. * @returns the requested animation range or null if not found
  79137. */
  79138. getAnimationRange(name: string): Nullable<AnimationRange>;
  79139. /**
  79140. * Gets the list of all animation ranges defined on this skeleton
  79141. * @returns an array
  79142. */
  79143. getAnimationRanges(): Nullable<AnimationRange>[];
  79144. /**
  79145. * Copy animation range from a source skeleton.
  79146. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79147. * @param source defines the source skeleton
  79148. * @param name defines the name of the range to copy
  79149. * @param rescaleAsRequired defines if rescaling must be applied if required
  79150. * @returns true if operation was successful
  79151. */
  79152. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79153. /**
  79154. * Forces the skeleton to go to rest pose
  79155. */
  79156. returnToRest(): void;
  79157. private _getHighestAnimationFrame;
  79158. /**
  79159. * Begin a specific animation range
  79160. * @param name defines the name of the range to start
  79161. * @param loop defines if looping must be turned on (false by default)
  79162. * @param speedRatio defines the speed ratio to apply (1 by default)
  79163. * @param onAnimationEnd defines a callback which will be called when animation will end
  79164. * @returns a new animatable
  79165. */
  79166. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79167. /** @hidden */
  79168. _markAsDirty(): void;
  79169. /** @hidden */
  79170. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79171. /** @hidden */
  79172. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79173. private _computeTransformMatrices;
  79174. /**
  79175. * Build all resources required to render a skeleton
  79176. */
  79177. prepare(): void;
  79178. /**
  79179. * Gets the list of animatables currently running for this skeleton
  79180. * @returns an array of animatables
  79181. */
  79182. getAnimatables(): IAnimatable[];
  79183. /**
  79184. * Clone the current skeleton
  79185. * @param name defines the name of the new skeleton
  79186. * @param id defines the id of the new skeleton
  79187. * @returns the new skeleton
  79188. */
  79189. clone(name: string, id: string): Skeleton;
  79190. /**
  79191. * Enable animation blending for this skeleton
  79192. * @param blendingSpeed defines the blending speed to apply
  79193. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79194. */
  79195. enableBlending(blendingSpeed?: number): void;
  79196. /**
  79197. * Releases all resources associated with the current skeleton
  79198. */
  79199. dispose(): void;
  79200. /**
  79201. * Serialize the skeleton in a JSON object
  79202. * @returns a JSON object
  79203. */
  79204. serialize(): any;
  79205. /**
  79206. * Creates a new skeleton from serialized data
  79207. * @param parsedSkeleton defines the serialized data
  79208. * @param scene defines the hosting scene
  79209. * @returns a new skeleton
  79210. */
  79211. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79212. /**
  79213. * Compute all node absolute transforms
  79214. * @param forceUpdate defines if computation must be done even if cache is up to date
  79215. */
  79216. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79217. /**
  79218. * Gets the root pose matrix
  79219. * @returns a matrix
  79220. */
  79221. getPoseMatrix(): Nullable<Matrix>;
  79222. /**
  79223. * Sorts bones per internal index
  79224. */
  79225. sortBones(): void;
  79226. private _sortBones;
  79227. }
  79228. }
  79229. declare module BABYLON {
  79230. /**
  79231. * Defines a target to use with MorphTargetManager
  79232. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79233. */
  79234. export class MorphTarget implements IAnimatable {
  79235. /** defines the name of the target */
  79236. name: string;
  79237. /**
  79238. * Gets or sets the list of animations
  79239. */
  79240. animations: Animation[];
  79241. private _scene;
  79242. private _positions;
  79243. private _normals;
  79244. private _tangents;
  79245. private _influence;
  79246. /**
  79247. * Observable raised when the influence changes
  79248. */
  79249. onInfluenceChanged: Observable<boolean>;
  79250. /** @hidden */
  79251. _onDataLayoutChanged: Observable<void>;
  79252. /**
  79253. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79254. */
  79255. influence: number;
  79256. /**
  79257. * Gets or sets the id of the morph Target
  79258. */
  79259. id: string;
  79260. private _animationPropertiesOverride;
  79261. /**
  79262. * Gets or sets the animation properties override
  79263. */
  79264. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79265. /**
  79266. * Creates a new MorphTarget
  79267. * @param name defines the name of the target
  79268. * @param influence defines the influence to use
  79269. * @param scene defines the scene the morphtarget belongs to
  79270. */
  79271. constructor(
  79272. /** defines the name of the target */
  79273. name: string, influence?: number, scene?: Nullable<Scene>);
  79274. /**
  79275. * Gets a boolean defining if the target contains position data
  79276. */
  79277. readonly hasPositions: boolean;
  79278. /**
  79279. * Gets a boolean defining if the target contains normal data
  79280. */
  79281. readonly hasNormals: boolean;
  79282. /**
  79283. * Gets a boolean defining if the target contains tangent data
  79284. */
  79285. readonly hasTangents: boolean;
  79286. /**
  79287. * Affects position data to this target
  79288. * @param data defines the position data to use
  79289. */
  79290. setPositions(data: Nullable<FloatArray>): void;
  79291. /**
  79292. * Gets the position data stored in this target
  79293. * @returns a FloatArray containing the position data (or null if not present)
  79294. */
  79295. getPositions(): Nullable<FloatArray>;
  79296. /**
  79297. * Affects normal data to this target
  79298. * @param data defines the normal data to use
  79299. */
  79300. setNormals(data: Nullable<FloatArray>): void;
  79301. /**
  79302. * Gets the normal data stored in this target
  79303. * @returns a FloatArray containing the normal data (or null if not present)
  79304. */
  79305. getNormals(): Nullable<FloatArray>;
  79306. /**
  79307. * Affects tangent data to this target
  79308. * @param data defines the tangent data to use
  79309. */
  79310. setTangents(data: Nullable<FloatArray>): void;
  79311. /**
  79312. * Gets the tangent data stored in this target
  79313. * @returns a FloatArray containing the tangent data (or null if not present)
  79314. */
  79315. getTangents(): Nullable<FloatArray>;
  79316. /**
  79317. * Serializes the current target into a Serialization object
  79318. * @returns the serialized object
  79319. */
  79320. serialize(): any;
  79321. /**
  79322. * Returns the string "MorphTarget"
  79323. * @returns "MorphTarget"
  79324. */
  79325. getClassName(): string;
  79326. /**
  79327. * Creates a new target from serialized data
  79328. * @param serializationObject defines the serialized data to use
  79329. * @returns a new MorphTarget
  79330. */
  79331. static Parse(serializationObject: any): MorphTarget;
  79332. /**
  79333. * Creates a MorphTarget from mesh data
  79334. * @param mesh defines the source mesh
  79335. * @param name defines the name to use for the new target
  79336. * @param influence defines the influence to attach to the target
  79337. * @returns a new MorphTarget
  79338. */
  79339. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79340. }
  79341. }
  79342. declare module BABYLON {
  79343. /**
  79344. * This class is used to deform meshes using morphing between different targets
  79345. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79346. */
  79347. export class MorphTargetManager {
  79348. private _targets;
  79349. private _targetInfluenceChangedObservers;
  79350. private _targetDataLayoutChangedObservers;
  79351. private _activeTargets;
  79352. private _scene;
  79353. private _influences;
  79354. private _supportsNormals;
  79355. private _supportsTangents;
  79356. private _vertexCount;
  79357. private _uniqueId;
  79358. private _tempInfluences;
  79359. /**
  79360. * Creates a new MorphTargetManager
  79361. * @param scene defines the current scene
  79362. */
  79363. constructor(scene?: Nullable<Scene>);
  79364. /**
  79365. * Gets the unique ID of this manager
  79366. */
  79367. readonly uniqueId: number;
  79368. /**
  79369. * Gets the number of vertices handled by this manager
  79370. */
  79371. readonly vertexCount: number;
  79372. /**
  79373. * Gets a boolean indicating if this manager supports morphing of normals
  79374. */
  79375. readonly supportsNormals: boolean;
  79376. /**
  79377. * Gets a boolean indicating if this manager supports morphing of tangents
  79378. */
  79379. readonly supportsTangents: boolean;
  79380. /**
  79381. * Gets the number of targets stored in this manager
  79382. */
  79383. readonly numTargets: number;
  79384. /**
  79385. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79386. */
  79387. readonly numInfluencers: number;
  79388. /**
  79389. * Gets the list of influences (one per target)
  79390. */
  79391. readonly influences: Float32Array;
  79392. /**
  79393. * Gets the active target at specified index. An active target is a target with an influence > 0
  79394. * @param index defines the index to check
  79395. * @returns the requested target
  79396. */
  79397. getActiveTarget(index: number): MorphTarget;
  79398. /**
  79399. * Gets the target at specified index
  79400. * @param index defines the index to check
  79401. * @returns the requested target
  79402. */
  79403. getTarget(index: number): MorphTarget;
  79404. /**
  79405. * Add a new target to this manager
  79406. * @param target defines the target to add
  79407. */
  79408. addTarget(target: MorphTarget): void;
  79409. /**
  79410. * Removes a target from the manager
  79411. * @param target defines the target to remove
  79412. */
  79413. removeTarget(target: MorphTarget): void;
  79414. /**
  79415. * Serializes the current manager into a Serialization object
  79416. * @returns the serialized object
  79417. */
  79418. serialize(): any;
  79419. private _syncActiveTargets;
  79420. /**
  79421. * Syncrhonize the targets with all the meshes using this morph target manager
  79422. */
  79423. synchronize(): void;
  79424. /**
  79425. * Creates a new MorphTargetManager from serialized data
  79426. * @param serializationObject defines the serialized data
  79427. * @param scene defines the hosting scene
  79428. * @returns the new MorphTargetManager
  79429. */
  79430. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79431. }
  79432. }
  79433. declare module BABYLON {
  79434. /**
  79435. * Class used to represent a specific level of detail of a mesh
  79436. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79437. */
  79438. export class MeshLODLevel {
  79439. /** Defines the distance where this level should star being displayed */
  79440. distance: number;
  79441. /** Defines the mesh to use to render this level */
  79442. mesh: Nullable<Mesh>;
  79443. /**
  79444. * Creates a new LOD level
  79445. * @param distance defines the distance where this level should star being displayed
  79446. * @param mesh defines the mesh to use to render this level
  79447. */
  79448. constructor(
  79449. /** Defines the distance where this level should star being displayed */
  79450. distance: number,
  79451. /** Defines the mesh to use to render this level */
  79452. mesh: Nullable<Mesh>);
  79453. }
  79454. }
  79455. declare module BABYLON {
  79456. /**
  79457. * Mesh representing the gorund
  79458. */
  79459. export class GroundMesh extends Mesh {
  79460. /** If octree should be generated */
  79461. generateOctree: boolean;
  79462. private _heightQuads;
  79463. /** @hidden */
  79464. _subdivisionsX: number;
  79465. /** @hidden */
  79466. _subdivisionsY: number;
  79467. /** @hidden */
  79468. _width: number;
  79469. /** @hidden */
  79470. _height: number;
  79471. /** @hidden */
  79472. _minX: number;
  79473. /** @hidden */
  79474. _maxX: number;
  79475. /** @hidden */
  79476. _minZ: number;
  79477. /** @hidden */
  79478. _maxZ: number;
  79479. constructor(name: string, scene: Scene);
  79480. /**
  79481. * "GroundMesh"
  79482. * @returns "GroundMesh"
  79483. */
  79484. getClassName(): string;
  79485. /**
  79486. * The minimum of x and y subdivisions
  79487. */
  79488. readonly subdivisions: number;
  79489. /**
  79490. * X subdivisions
  79491. */
  79492. readonly subdivisionsX: number;
  79493. /**
  79494. * Y subdivisions
  79495. */
  79496. readonly subdivisionsY: number;
  79497. /**
  79498. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79499. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79500. * @param chunksCount the number of subdivisions for x and y
  79501. * @param octreeBlocksSize (Default: 32)
  79502. */
  79503. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79504. /**
  79505. * Returns a height (y) value in the Worl system :
  79506. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79507. * @param x x coordinate
  79508. * @param z z coordinate
  79509. * @returns the ground y position if (x, z) are outside the ground surface.
  79510. */
  79511. getHeightAtCoordinates(x: number, z: number): number;
  79512. /**
  79513. * Returns a normalized vector (Vector3) orthogonal to the ground
  79514. * at the ground coordinates (x, z) expressed in the World system.
  79515. * @param x x coordinate
  79516. * @param z z coordinate
  79517. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79518. */
  79519. getNormalAtCoordinates(x: number, z: number): Vector3;
  79520. /**
  79521. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79522. * at the ground coordinates (x, z) expressed in the World system.
  79523. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79524. * @param x x coordinate
  79525. * @param z z coordinate
  79526. * @param ref vector to store the result
  79527. * @returns the GroundMesh.
  79528. */
  79529. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79530. /**
  79531. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79532. * if the ground has been updated.
  79533. * This can be used in the render loop.
  79534. * @returns the GroundMesh.
  79535. */
  79536. updateCoordinateHeights(): GroundMesh;
  79537. private _getFacetAt;
  79538. private _initHeightQuads;
  79539. private _computeHeightQuads;
  79540. /**
  79541. * Serializes this ground mesh
  79542. * @param serializationObject object to write serialization to
  79543. */
  79544. serialize(serializationObject: any): void;
  79545. /**
  79546. * Parses a serialized ground mesh
  79547. * @param parsedMesh the serialized mesh
  79548. * @param scene the scene to create the ground mesh in
  79549. * @returns the created ground mesh
  79550. */
  79551. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79552. }
  79553. }
  79554. declare module BABYLON {
  79555. /**
  79556. * Interface for Physics-Joint data
  79557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79558. */
  79559. export interface PhysicsJointData {
  79560. /**
  79561. * The main pivot of the joint
  79562. */
  79563. mainPivot?: Vector3;
  79564. /**
  79565. * The connected pivot of the joint
  79566. */
  79567. connectedPivot?: Vector3;
  79568. /**
  79569. * The main axis of the joint
  79570. */
  79571. mainAxis?: Vector3;
  79572. /**
  79573. * The connected axis of the joint
  79574. */
  79575. connectedAxis?: Vector3;
  79576. /**
  79577. * The collision of the joint
  79578. */
  79579. collision?: boolean;
  79580. /**
  79581. * Native Oimo/Cannon/Energy data
  79582. */
  79583. nativeParams?: any;
  79584. }
  79585. /**
  79586. * This is a holder class for the physics joint created by the physics plugin
  79587. * It holds a set of functions to control the underlying joint
  79588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79589. */
  79590. export class PhysicsJoint {
  79591. /**
  79592. * The type of the physics joint
  79593. */
  79594. type: number;
  79595. /**
  79596. * The data for the physics joint
  79597. */
  79598. jointData: PhysicsJointData;
  79599. private _physicsJoint;
  79600. protected _physicsPlugin: IPhysicsEnginePlugin;
  79601. /**
  79602. * Initializes the physics joint
  79603. * @param type The type of the physics joint
  79604. * @param jointData The data for the physics joint
  79605. */
  79606. constructor(
  79607. /**
  79608. * The type of the physics joint
  79609. */
  79610. type: number,
  79611. /**
  79612. * The data for the physics joint
  79613. */
  79614. jointData: PhysicsJointData);
  79615. /**
  79616. * Gets the physics joint
  79617. */
  79618. /**
  79619. * Sets the physics joint
  79620. */
  79621. physicsJoint: any;
  79622. /**
  79623. * Sets the physics plugin
  79624. */
  79625. physicsPlugin: IPhysicsEnginePlugin;
  79626. /**
  79627. * Execute a function that is physics-plugin specific.
  79628. * @param {Function} func the function that will be executed.
  79629. * It accepts two parameters: the physics world and the physics joint
  79630. */
  79631. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79632. /**
  79633. * Distance-Joint type
  79634. */
  79635. static DistanceJoint: number;
  79636. /**
  79637. * Hinge-Joint type
  79638. */
  79639. static HingeJoint: number;
  79640. /**
  79641. * Ball-and-Socket joint type
  79642. */
  79643. static BallAndSocketJoint: number;
  79644. /**
  79645. * Wheel-Joint type
  79646. */
  79647. static WheelJoint: number;
  79648. /**
  79649. * Slider-Joint type
  79650. */
  79651. static SliderJoint: number;
  79652. /**
  79653. * Prismatic-Joint type
  79654. */
  79655. static PrismaticJoint: number;
  79656. /**
  79657. * Universal-Joint type
  79658. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79659. */
  79660. static UniversalJoint: number;
  79661. /**
  79662. * Hinge-Joint 2 type
  79663. */
  79664. static Hinge2Joint: number;
  79665. /**
  79666. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79667. */
  79668. static PointToPointJoint: number;
  79669. /**
  79670. * Spring-Joint type
  79671. */
  79672. static SpringJoint: number;
  79673. /**
  79674. * Lock-Joint type
  79675. */
  79676. static LockJoint: number;
  79677. }
  79678. /**
  79679. * A class representing a physics distance joint
  79680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79681. */
  79682. export class DistanceJoint extends PhysicsJoint {
  79683. /**
  79684. *
  79685. * @param jointData The data for the Distance-Joint
  79686. */
  79687. constructor(jointData: DistanceJointData);
  79688. /**
  79689. * Update the predefined distance.
  79690. * @param maxDistance The maximum preferred distance
  79691. * @param minDistance The minimum preferred distance
  79692. */
  79693. updateDistance(maxDistance: number, minDistance?: number): void;
  79694. }
  79695. /**
  79696. * Represents a Motor-Enabled Joint
  79697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79698. */
  79699. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79700. /**
  79701. * Initializes the Motor-Enabled Joint
  79702. * @param type The type of the joint
  79703. * @param jointData The physica joint data for the joint
  79704. */
  79705. constructor(type: number, jointData: PhysicsJointData);
  79706. /**
  79707. * Set the motor values.
  79708. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79709. * @param force the force to apply
  79710. * @param maxForce max force for this motor.
  79711. */
  79712. setMotor(force?: number, maxForce?: number): void;
  79713. /**
  79714. * Set the motor's limits.
  79715. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79716. * @param upperLimit The upper limit of the motor
  79717. * @param lowerLimit The lower limit of the motor
  79718. */
  79719. setLimit(upperLimit: number, lowerLimit?: number): void;
  79720. }
  79721. /**
  79722. * This class represents a single physics Hinge-Joint
  79723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79724. */
  79725. export class HingeJoint extends MotorEnabledJoint {
  79726. /**
  79727. * Initializes the Hinge-Joint
  79728. * @param jointData The joint data for the Hinge-Joint
  79729. */
  79730. constructor(jointData: PhysicsJointData);
  79731. /**
  79732. * Set the motor values.
  79733. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79734. * @param {number} force the force to apply
  79735. * @param {number} maxForce max force for this motor.
  79736. */
  79737. setMotor(force?: number, maxForce?: number): void;
  79738. /**
  79739. * Set the motor's limits.
  79740. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79741. * @param upperLimit The upper limit of the motor
  79742. * @param lowerLimit The lower limit of the motor
  79743. */
  79744. setLimit(upperLimit: number, lowerLimit?: number): void;
  79745. }
  79746. /**
  79747. * This class represents a dual hinge physics joint (same as wheel joint)
  79748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79749. */
  79750. export class Hinge2Joint extends MotorEnabledJoint {
  79751. /**
  79752. * Initializes the Hinge2-Joint
  79753. * @param jointData The joint data for the Hinge2-Joint
  79754. */
  79755. constructor(jointData: PhysicsJointData);
  79756. /**
  79757. * Set the motor values.
  79758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79759. * @param {number} targetSpeed the speed the motor is to reach
  79760. * @param {number} maxForce max force for this motor.
  79761. * @param {motorIndex} the motor's index, 0 or 1.
  79762. */
  79763. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79764. /**
  79765. * Set the motor limits.
  79766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79767. * @param {number} upperLimit the upper limit
  79768. * @param {number} lowerLimit lower limit
  79769. * @param {motorIndex} the motor's index, 0 or 1.
  79770. */
  79771. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79772. }
  79773. /**
  79774. * Interface for a motor enabled joint
  79775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79776. */
  79777. export interface IMotorEnabledJoint {
  79778. /**
  79779. * Physics joint
  79780. */
  79781. physicsJoint: any;
  79782. /**
  79783. * Sets the motor of the motor-enabled joint
  79784. * @param force The force of the motor
  79785. * @param maxForce The maximum force of the motor
  79786. * @param motorIndex The index of the motor
  79787. */
  79788. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79789. /**
  79790. * Sets the limit of the motor
  79791. * @param upperLimit The upper limit of the motor
  79792. * @param lowerLimit The lower limit of the motor
  79793. * @param motorIndex The index of the motor
  79794. */
  79795. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79796. }
  79797. /**
  79798. * Joint data for a Distance-Joint
  79799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79800. */
  79801. export interface DistanceJointData extends PhysicsJointData {
  79802. /**
  79803. * Max distance the 2 joint objects can be apart
  79804. */
  79805. maxDistance: number;
  79806. }
  79807. /**
  79808. * Joint data from a spring joint
  79809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79810. */
  79811. export interface SpringJointData extends PhysicsJointData {
  79812. /**
  79813. * Length of the spring
  79814. */
  79815. length: number;
  79816. /**
  79817. * Stiffness of the spring
  79818. */
  79819. stiffness: number;
  79820. /**
  79821. * Damping of the spring
  79822. */
  79823. damping: number;
  79824. /** this callback will be called when applying the force to the impostors. */
  79825. forceApplicationCallback: () => void;
  79826. }
  79827. }
  79828. declare module BABYLON {
  79829. /**
  79830. * Holds the data for the raycast result
  79831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79832. */
  79833. export class PhysicsRaycastResult {
  79834. private _hasHit;
  79835. private _hitDistance;
  79836. private _hitNormalWorld;
  79837. private _hitPointWorld;
  79838. private _rayFromWorld;
  79839. private _rayToWorld;
  79840. /**
  79841. * Gets if there was a hit
  79842. */
  79843. readonly hasHit: boolean;
  79844. /**
  79845. * Gets the distance from the hit
  79846. */
  79847. readonly hitDistance: number;
  79848. /**
  79849. * Gets the hit normal/direction in the world
  79850. */
  79851. readonly hitNormalWorld: Vector3;
  79852. /**
  79853. * Gets the hit point in the world
  79854. */
  79855. readonly hitPointWorld: Vector3;
  79856. /**
  79857. * Gets the ray "start point" of the ray in the world
  79858. */
  79859. readonly rayFromWorld: Vector3;
  79860. /**
  79861. * Gets the ray "end point" of the ray in the world
  79862. */
  79863. readonly rayToWorld: Vector3;
  79864. /**
  79865. * Sets the hit data (normal & point in world space)
  79866. * @param hitNormalWorld defines the normal in world space
  79867. * @param hitPointWorld defines the point in world space
  79868. */
  79869. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79870. /**
  79871. * Sets the distance from the start point to the hit point
  79872. * @param distance
  79873. */
  79874. setHitDistance(distance: number): void;
  79875. /**
  79876. * Calculates the distance manually
  79877. */
  79878. calculateHitDistance(): void;
  79879. /**
  79880. * Resets all the values to default
  79881. * @param from The from point on world space
  79882. * @param to The to point on world space
  79883. */
  79884. reset(from?: Vector3, to?: Vector3): void;
  79885. }
  79886. /**
  79887. * Interface for the size containing width and height
  79888. */
  79889. interface IXYZ {
  79890. /**
  79891. * X
  79892. */
  79893. x: number;
  79894. /**
  79895. * Y
  79896. */
  79897. y: number;
  79898. /**
  79899. * Z
  79900. */
  79901. z: number;
  79902. }
  79903. }
  79904. declare module BABYLON {
  79905. /**
  79906. * Interface used to describe a physics joint
  79907. */
  79908. export interface PhysicsImpostorJoint {
  79909. /** Defines the main impostor to which the joint is linked */
  79910. mainImpostor: PhysicsImpostor;
  79911. /** Defines the impostor that is connected to the main impostor using this joint */
  79912. connectedImpostor: PhysicsImpostor;
  79913. /** Defines the joint itself */
  79914. joint: PhysicsJoint;
  79915. }
  79916. /** @hidden */
  79917. export interface IPhysicsEnginePlugin {
  79918. world: any;
  79919. name: string;
  79920. setGravity(gravity: Vector3): void;
  79921. setTimeStep(timeStep: number): void;
  79922. getTimeStep(): number;
  79923. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79924. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79925. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79926. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79927. removePhysicsBody(impostor: PhysicsImpostor): void;
  79928. generateJoint(joint: PhysicsImpostorJoint): void;
  79929. removeJoint(joint: PhysicsImpostorJoint): void;
  79930. isSupported(): boolean;
  79931. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79932. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79933. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79934. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79935. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79936. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79937. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79938. getBodyMass(impostor: PhysicsImpostor): number;
  79939. getBodyFriction(impostor: PhysicsImpostor): number;
  79940. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79941. getBodyRestitution(impostor: PhysicsImpostor): number;
  79942. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79943. getBodyPressure?(impostor: PhysicsImpostor): number;
  79944. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79945. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79946. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79947. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79948. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79949. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79950. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79951. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79952. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79953. sleepBody(impostor: PhysicsImpostor): void;
  79954. wakeUpBody(impostor: PhysicsImpostor): void;
  79955. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79956. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79957. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79958. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79959. getRadius(impostor: PhysicsImpostor): number;
  79960. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79961. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79962. dispose(): void;
  79963. }
  79964. /**
  79965. * Interface used to define a physics engine
  79966. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79967. */
  79968. export interface IPhysicsEngine {
  79969. /**
  79970. * Gets the gravity vector used by the simulation
  79971. */
  79972. gravity: Vector3;
  79973. /**
  79974. * Sets the gravity vector used by the simulation
  79975. * @param gravity defines the gravity vector to use
  79976. */
  79977. setGravity(gravity: Vector3): void;
  79978. /**
  79979. * Set the time step of the physics engine.
  79980. * Default is 1/60.
  79981. * To slow it down, enter 1/600 for example.
  79982. * To speed it up, 1/30
  79983. * @param newTimeStep the new timestep to apply to this world.
  79984. */
  79985. setTimeStep(newTimeStep: number): void;
  79986. /**
  79987. * Get the time step of the physics engine.
  79988. * @returns the current time step
  79989. */
  79990. getTimeStep(): number;
  79991. /**
  79992. * Release all resources
  79993. */
  79994. dispose(): void;
  79995. /**
  79996. * Gets the name of the current physics plugin
  79997. * @returns the name of the plugin
  79998. */
  79999. getPhysicsPluginName(): string;
  80000. /**
  80001. * Adding a new impostor for the impostor tracking.
  80002. * This will be done by the impostor itself.
  80003. * @param impostor the impostor to add
  80004. */
  80005. addImpostor(impostor: PhysicsImpostor): void;
  80006. /**
  80007. * Remove an impostor from the engine.
  80008. * This impostor and its mesh will not longer be updated by the physics engine.
  80009. * @param impostor the impostor to remove
  80010. */
  80011. removeImpostor(impostor: PhysicsImpostor): void;
  80012. /**
  80013. * Add a joint to the physics engine
  80014. * @param mainImpostor defines the main impostor to which the joint is added.
  80015. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80016. * @param joint defines the joint that will connect both impostors.
  80017. */
  80018. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80019. /**
  80020. * Removes a joint from the simulation
  80021. * @param mainImpostor defines the impostor used with the joint
  80022. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80023. * @param joint defines the joint to remove
  80024. */
  80025. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80026. /**
  80027. * Gets the current plugin used to run the simulation
  80028. * @returns current plugin
  80029. */
  80030. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80031. /**
  80032. * Gets the list of physic impostors
  80033. * @returns an array of PhysicsImpostor
  80034. */
  80035. getImpostors(): Array<PhysicsImpostor>;
  80036. /**
  80037. * Gets the impostor for a physics enabled object
  80038. * @param object defines the object impersonated by the impostor
  80039. * @returns the PhysicsImpostor or null if not found
  80040. */
  80041. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80042. /**
  80043. * Gets the impostor for a physics body object
  80044. * @param body defines physics body used by the impostor
  80045. * @returns the PhysicsImpostor or null if not found
  80046. */
  80047. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80048. /**
  80049. * Does a raycast in the physics world
  80050. * @param from when should the ray start?
  80051. * @param to when should the ray end?
  80052. * @returns PhysicsRaycastResult
  80053. */
  80054. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80055. /**
  80056. * Called by the scene. No need to call it.
  80057. * @param delta defines the timespam between frames
  80058. */
  80059. _step(delta: number): void;
  80060. }
  80061. }
  80062. declare module BABYLON {
  80063. /**
  80064. * The interface for the physics imposter parameters
  80065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80066. */
  80067. export interface PhysicsImpostorParameters {
  80068. /**
  80069. * The mass of the physics imposter
  80070. */
  80071. mass: number;
  80072. /**
  80073. * The friction of the physics imposter
  80074. */
  80075. friction?: number;
  80076. /**
  80077. * The coefficient of restitution of the physics imposter
  80078. */
  80079. restitution?: number;
  80080. /**
  80081. * The native options of the physics imposter
  80082. */
  80083. nativeOptions?: any;
  80084. /**
  80085. * Specifies if the parent should be ignored
  80086. */
  80087. ignoreParent?: boolean;
  80088. /**
  80089. * Specifies if bi-directional transformations should be disabled
  80090. */
  80091. disableBidirectionalTransformation?: boolean;
  80092. /**
  80093. * The pressure inside the physics imposter, soft object only
  80094. */
  80095. pressure?: number;
  80096. /**
  80097. * The stiffness the physics imposter, soft object only
  80098. */
  80099. stiffness?: number;
  80100. /**
  80101. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80102. */
  80103. velocityIterations?: number;
  80104. /**
  80105. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80106. */
  80107. positionIterations?: number;
  80108. /**
  80109. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80110. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80111. * Add to fix multiple points
  80112. */
  80113. fixedPoints?: number;
  80114. /**
  80115. * The collision margin around a soft object
  80116. */
  80117. margin?: number;
  80118. /**
  80119. * The collision margin around a soft object
  80120. */
  80121. damping?: number;
  80122. /**
  80123. * The path for a rope based on an extrusion
  80124. */
  80125. path?: any;
  80126. /**
  80127. * The shape of an extrusion used for a rope based on an extrusion
  80128. */
  80129. shape?: any;
  80130. }
  80131. /**
  80132. * Interface for a physics-enabled object
  80133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80134. */
  80135. export interface IPhysicsEnabledObject {
  80136. /**
  80137. * The position of the physics-enabled object
  80138. */
  80139. position: Vector3;
  80140. /**
  80141. * The rotation of the physics-enabled object
  80142. */
  80143. rotationQuaternion: Nullable<Quaternion>;
  80144. /**
  80145. * The scale of the physics-enabled object
  80146. */
  80147. scaling: Vector3;
  80148. /**
  80149. * The rotation of the physics-enabled object
  80150. */
  80151. rotation?: Vector3;
  80152. /**
  80153. * The parent of the physics-enabled object
  80154. */
  80155. parent?: any;
  80156. /**
  80157. * The bounding info of the physics-enabled object
  80158. * @returns The bounding info of the physics-enabled object
  80159. */
  80160. getBoundingInfo(): BoundingInfo;
  80161. /**
  80162. * Computes the world matrix
  80163. * @param force Specifies if the world matrix should be computed by force
  80164. * @returns A world matrix
  80165. */
  80166. computeWorldMatrix(force: boolean): Matrix;
  80167. /**
  80168. * Gets the world matrix
  80169. * @returns A world matrix
  80170. */
  80171. getWorldMatrix?(): Matrix;
  80172. /**
  80173. * Gets the child meshes
  80174. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80175. * @returns An array of abstract meshes
  80176. */
  80177. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80178. /**
  80179. * Gets the vertex data
  80180. * @param kind The type of vertex data
  80181. * @returns A nullable array of numbers, or a float32 array
  80182. */
  80183. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80184. /**
  80185. * Gets the indices from the mesh
  80186. * @returns A nullable array of index arrays
  80187. */
  80188. getIndices?(): Nullable<IndicesArray>;
  80189. /**
  80190. * Gets the scene from the mesh
  80191. * @returns the indices array or null
  80192. */
  80193. getScene?(): Scene;
  80194. /**
  80195. * Gets the absolute position from the mesh
  80196. * @returns the absolute position
  80197. */
  80198. getAbsolutePosition(): Vector3;
  80199. /**
  80200. * Gets the absolute pivot point from the mesh
  80201. * @returns the absolute pivot point
  80202. */
  80203. getAbsolutePivotPoint(): Vector3;
  80204. /**
  80205. * Rotates the mesh
  80206. * @param axis The axis of rotation
  80207. * @param amount The amount of rotation
  80208. * @param space The space of the rotation
  80209. * @returns The rotation transform node
  80210. */
  80211. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80212. /**
  80213. * Translates the mesh
  80214. * @param axis The axis of translation
  80215. * @param distance The distance of translation
  80216. * @param space The space of the translation
  80217. * @returns The transform node
  80218. */
  80219. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80220. /**
  80221. * Sets the absolute position of the mesh
  80222. * @param absolutePosition The absolute position of the mesh
  80223. * @returns The transform node
  80224. */
  80225. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80226. /**
  80227. * Gets the class name of the mesh
  80228. * @returns The class name
  80229. */
  80230. getClassName(): string;
  80231. }
  80232. /**
  80233. * Represents a physics imposter
  80234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80235. */
  80236. export class PhysicsImpostor {
  80237. /**
  80238. * The physics-enabled object used as the physics imposter
  80239. */
  80240. object: IPhysicsEnabledObject;
  80241. /**
  80242. * The type of the physics imposter
  80243. */
  80244. type: number;
  80245. private _options;
  80246. private _scene?;
  80247. /**
  80248. * The default object size of the imposter
  80249. */
  80250. static DEFAULT_OBJECT_SIZE: Vector3;
  80251. /**
  80252. * The identity quaternion of the imposter
  80253. */
  80254. static IDENTITY_QUATERNION: Quaternion;
  80255. /** @hidden */
  80256. _pluginData: any;
  80257. private _physicsEngine;
  80258. private _physicsBody;
  80259. private _bodyUpdateRequired;
  80260. private _onBeforePhysicsStepCallbacks;
  80261. private _onAfterPhysicsStepCallbacks;
  80262. /** @hidden */
  80263. _onPhysicsCollideCallbacks: Array<{
  80264. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80265. otherImpostors: Array<PhysicsImpostor>;
  80266. }>;
  80267. private _deltaPosition;
  80268. private _deltaRotation;
  80269. private _deltaRotationConjugated;
  80270. /** hidden */
  80271. _isFromLine: boolean;
  80272. private _parent;
  80273. private _isDisposed;
  80274. private static _tmpVecs;
  80275. private static _tmpQuat;
  80276. /**
  80277. * Specifies if the physics imposter is disposed
  80278. */
  80279. readonly isDisposed: boolean;
  80280. /**
  80281. * Gets the mass of the physics imposter
  80282. */
  80283. mass: number;
  80284. /**
  80285. * Gets the coefficient of friction
  80286. */
  80287. /**
  80288. * Sets the coefficient of friction
  80289. */
  80290. friction: number;
  80291. /**
  80292. * Gets the coefficient of restitution
  80293. */
  80294. /**
  80295. * Sets the coefficient of restitution
  80296. */
  80297. restitution: number;
  80298. /**
  80299. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80300. */
  80301. /**
  80302. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80303. */
  80304. pressure: number;
  80305. /**
  80306. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80307. */
  80308. /**
  80309. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80310. */
  80311. stiffness: number;
  80312. /**
  80313. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80314. */
  80315. /**
  80316. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80317. */
  80318. velocityIterations: number;
  80319. /**
  80320. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80321. */
  80322. /**
  80323. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80324. */
  80325. positionIterations: number;
  80326. /**
  80327. * The unique id of the physics imposter
  80328. * set by the physics engine when adding this impostor to the array
  80329. */
  80330. uniqueId: number;
  80331. /**
  80332. * @hidden
  80333. */
  80334. soft: boolean;
  80335. /**
  80336. * @hidden
  80337. */
  80338. segments: number;
  80339. private _joints;
  80340. /**
  80341. * Initializes the physics imposter
  80342. * @param object The physics-enabled object used as the physics imposter
  80343. * @param type The type of the physics imposter
  80344. * @param _options The options for the physics imposter
  80345. * @param _scene The Babylon scene
  80346. */
  80347. constructor(
  80348. /**
  80349. * The physics-enabled object used as the physics imposter
  80350. */
  80351. object: IPhysicsEnabledObject,
  80352. /**
  80353. * The type of the physics imposter
  80354. */
  80355. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80356. /**
  80357. * This function will completly initialize this impostor.
  80358. * It will create a new body - but only if this mesh has no parent.
  80359. * If it has, this impostor will not be used other than to define the impostor
  80360. * of the child mesh.
  80361. * @hidden
  80362. */
  80363. _init(): void;
  80364. private _getPhysicsParent;
  80365. /**
  80366. * Should a new body be generated.
  80367. * @returns boolean specifying if body initialization is required
  80368. */
  80369. isBodyInitRequired(): boolean;
  80370. /**
  80371. * Sets the updated scaling
  80372. * @param updated Specifies if the scaling is updated
  80373. */
  80374. setScalingUpdated(): void;
  80375. /**
  80376. * Force a regeneration of this or the parent's impostor's body.
  80377. * Use under cautious - This will remove all joints already implemented.
  80378. */
  80379. forceUpdate(): void;
  80380. /**
  80381. * Gets the body that holds this impostor. Either its own, or its parent.
  80382. */
  80383. /**
  80384. * Set the physics body. Used mainly by the physics engine/plugin
  80385. */
  80386. physicsBody: any;
  80387. /**
  80388. * Get the parent of the physics imposter
  80389. * @returns Physics imposter or null
  80390. */
  80391. /**
  80392. * Sets the parent of the physics imposter
  80393. */
  80394. parent: Nullable<PhysicsImpostor>;
  80395. /**
  80396. * Resets the update flags
  80397. */
  80398. resetUpdateFlags(): void;
  80399. /**
  80400. * Gets the object extend size
  80401. * @returns the object extend size
  80402. */
  80403. getObjectExtendSize(): Vector3;
  80404. /**
  80405. * Gets the object center
  80406. * @returns The object center
  80407. */
  80408. getObjectCenter(): Vector3;
  80409. /**
  80410. * Get a specific parametes from the options parameter
  80411. * @param paramName The object parameter name
  80412. * @returns The object parameter
  80413. */
  80414. getParam(paramName: string): any;
  80415. /**
  80416. * Sets a specific parameter in the options given to the physics plugin
  80417. * @param paramName The parameter name
  80418. * @param value The value of the parameter
  80419. */
  80420. setParam(paramName: string, value: number): void;
  80421. /**
  80422. * Specifically change the body's mass option. Won't recreate the physics body object
  80423. * @param mass The mass of the physics imposter
  80424. */
  80425. setMass(mass: number): void;
  80426. /**
  80427. * Gets the linear velocity
  80428. * @returns linear velocity or null
  80429. */
  80430. getLinearVelocity(): Nullable<Vector3>;
  80431. /**
  80432. * Sets the linear velocity
  80433. * @param velocity linear velocity or null
  80434. */
  80435. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80436. /**
  80437. * Gets the angular velocity
  80438. * @returns angular velocity or null
  80439. */
  80440. getAngularVelocity(): Nullable<Vector3>;
  80441. /**
  80442. * Sets the angular velocity
  80443. * @param velocity The velocity or null
  80444. */
  80445. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80446. /**
  80447. * Execute a function with the physics plugin native code
  80448. * Provide a function the will have two variables - the world object and the physics body object
  80449. * @param func The function to execute with the physics plugin native code
  80450. */
  80451. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80452. /**
  80453. * Register a function that will be executed before the physics world is stepping forward
  80454. * @param func The function to execute before the physics world is stepped forward
  80455. */
  80456. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80457. /**
  80458. * Unregister a function that will be executed before the physics world is stepping forward
  80459. * @param func The function to execute before the physics world is stepped forward
  80460. */
  80461. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80462. /**
  80463. * Register a function that will be executed after the physics step
  80464. * @param func The function to execute after physics step
  80465. */
  80466. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80467. /**
  80468. * Unregisters a function that will be executed after the physics step
  80469. * @param func The function to execute after physics step
  80470. */
  80471. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80472. /**
  80473. * register a function that will be executed when this impostor collides against a different body
  80474. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80475. * @param func Callback that is executed on collision
  80476. */
  80477. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80478. /**
  80479. * Unregisters the physics imposter on contact
  80480. * @param collideAgainst The physics object to collide against
  80481. * @param func Callback to execute on collision
  80482. */
  80483. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80484. private _tmpQuat;
  80485. private _tmpQuat2;
  80486. /**
  80487. * Get the parent rotation
  80488. * @returns The parent rotation
  80489. */
  80490. getParentsRotation(): Quaternion;
  80491. /**
  80492. * this function is executed by the physics engine.
  80493. */
  80494. beforeStep: () => void;
  80495. /**
  80496. * this function is executed by the physics engine
  80497. */
  80498. afterStep: () => void;
  80499. /**
  80500. * Legacy collision detection event support
  80501. */
  80502. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80503. /**
  80504. * event and body object due to cannon's event-based architecture.
  80505. */
  80506. onCollide: (e: {
  80507. body: any;
  80508. }) => void;
  80509. /**
  80510. * Apply a force
  80511. * @param force The force to apply
  80512. * @param contactPoint The contact point for the force
  80513. * @returns The physics imposter
  80514. */
  80515. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80516. /**
  80517. * Apply an impulse
  80518. * @param force The impulse force
  80519. * @param contactPoint The contact point for the impulse force
  80520. * @returns The physics imposter
  80521. */
  80522. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80523. /**
  80524. * A help function to create a joint
  80525. * @param otherImpostor A physics imposter used to create a joint
  80526. * @param jointType The type of joint
  80527. * @param jointData The data for the joint
  80528. * @returns The physics imposter
  80529. */
  80530. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80531. /**
  80532. * Add a joint to this impostor with a different impostor
  80533. * @param otherImpostor A physics imposter used to add a joint
  80534. * @param joint The joint to add
  80535. * @returns The physics imposter
  80536. */
  80537. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80538. /**
  80539. * Add an anchor to a cloth impostor
  80540. * @param otherImpostor rigid impostor to anchor to
  80541. * @param width ratio across width from 0 to 1
  80542. * @param height ratio up height from 0 to 1
  80543. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80544. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80545. * @returns impostor the soft imposter
  80546. */
  80547. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80548. /**
  80549. * Add a hook to a rope impostor
  80550. * @param otherImpostor rigid impostor to anchor to
  80551. * @param length ratio across rope from 0 to 1
  80552. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80553. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80554. * @returns impostor the rope imposter
  80555. */
  80556. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80557. /**
  80558. * Will keep this body still, in a sleep mode.
  80559. * @returns the physics imposter
  80560. */
  80561. sleep(): PhysicsImpostor;
  80562. /**
  80563. * Wake the body up.
  80564. * @returns The physics imposter
  80565. */
  80566. wakeUp(): PhysicsImpostor;
  80567. /**
  80568. * Clones the physics imposter
  80569. * @param newObject The physics imposter clones to this physics-enabled object
  80570. * @returns A nullable physics imposter
  80571. */
  80572. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80573. /**
  80574. * Disposes the physics imposter
  80575. */
  80576. dispose(): void;
  80577. /**
  80578. * Sets the delta position
  80579. * @param position The delta position amount
  80580. */
  80581. setDeltaPosition(position: Vector3): void;
  80582. /**
  80583. * Sets the delta rotation
  80584. * @param rotation The delta rotation amount
  80585. */
  80586. setDeltaRotation(rotation: Quaternion): void;
  80587. /**
  80588. * Gets the box size of the physics imposter and stores the result in the input parameter
  80589. * @param result Stores the box size
  80590. * @returns The physics imposter
  80591. */
  80592. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80593. /**
  80594. * Gets the radius of the physics imposter
  80595. * @returns Radius of the physics imposter
  80596. */
  80597. getRadius(): number;
  80598. /**
  80599. * Sync a bone with this impostor
  80600. * @param bone The bone to sync to the impostor.
  80601. * @param boneMesh The mesh that the bone is influencing.
  80602. * @param jointPivot The pivot of the joint / bone in local space.
  80603. * @param distToJoint Optional distance from the impostor to the joint.
  80604. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80605. */
  80606. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80607. /**
  80608. * Sync impostor to a bone
  80609. * @param bone The bone that the impostor will be synced to.
  80610. * @param boneMesh The mesh that the bone is influencing.
  80611. * @param jointPivot The pivot of the joint / bone in local space.
  80612. * @param distToJoint Optional distance from the impostor to the joint.
  80613. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80614. * @param boneAxis Optional vector3 axis the bone is aligned with
  80615. */
  80616. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80617. /**
  80618. * No-Imposter type
  80619. */
  80620. static NoImpostor: number;
  80621. /**
  80622. * Sphere-Imposter type
  80623. */
  80624. static SphereImpostor: number;
  80625. /**
  80626. * Box-Imposter type
  80627. */
  80628. static BoxImpostor: number;
  80629. /**
  80630. * Plane-Imposter type
  80631. */
  80632. static PlaneImpostor: number;
  80633. /**
  80634. * Mesh-imposter type
  80635. */
  80636. static MeshImpostor: number;
  80637. /**
  80638. * Cylinder-Imposter type
  80639. */
  80640. static CylinderImpostor: number;
  80641. /**
  80642. * Particle-Imposter type
  80643. */
  80644. static ParticleImpostor: number;
  80645. /**
  80646. * Heightmap-Imposter type
  80647. */
  80648. static HeightmapImpostor: number;
  80649. /**
  80650. * ConvexHull-Impostor type (Ammo.js plugin only)
  80651. */
  80652. static ConvexHullImpostor: number;
  80653. /**
  80654. * Rope-Imposter type
  80655. */
  80656. static RopeImpostor: number;
  80657. /**
  80658. * Cloth-Imposter type
  80659. */
  80660. static ClothImpostor: number;
  80661. /**
  80662. * Softbody-Imposter type
  80663. */
  80664. static SoftbodyImpostor: number;
  80665. }
  80666. }
  80667. declare module BABYLON {
  80668. /**
  80669. * @hidden
  80670. **/
  80671. export class _CreationDataStorage {
  80672. closePath?: boolean;
  80673. closeArray?: boolean;
  80674. idx: number[];
  80675. dashSize: number;
  80676. gapSize: number;
  80677. path3D: Path3D;
  80678. pathArray: Vector3[][];
  80679. arc: number;
  80680. radius: number;
  80681. cap: number;
  80682. tessellation: number;
  80683. }
  80684. /**
  80685. * @hidden
  80686. **/
  80687. class _InstanceDataStorage {
  80688. visibleInstances: any;
  80689. batchCache: _InstancesBatch;
  80690. instancesBufferSize: number;
  80691. instancesBuffer: Nullable<Buffer>;
  80692. instancesData: Float32Array;
  80693. overridenInstanceCount: number;
  80694. isFrozen: boolean;
  80695. previousBatch: _InstancesBatch;
  80696. hardwareInstancedRendering: boolean;
  80697. sideOrientation: number;
  80698. }
  80699. /**
  80700. * @hidden
  80701. **/
  80702. export class _InstancesBatch {
  80703. mustReturn: boolean;
  80704. visibleInstances: Nullable<InstancedMesh[]>[];
  80705. renderSelf: boolean[];
  80706. hardwareInstancedRendering: boolean[];
  80707. }
  80708. /**
  80709. * Class used to represent renderable models
  80710. */
  80711. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80712. /**
  80713. * Mesh side orientation : usually the external or front surface
  80714. */
  80715. static readonly FRONTSIDE: number;
  80716. /**
  80717. * Mesh side orientation : usually the internal or back surface
  80718. */
  80719. static readonly BACKSIDE: number;
  80720. /**
  80721. * Mesh side orientation : both internal and external or front and back surfaces
  80722. */
  80723. static readonly DOUBLESIDE: number;
  80724. /**
  80725. * Mesh side orientation : by default, `FRONTSIDE`
  80726. */
  80727. static readonly DEFAULTSIDE: number;
  80728. /**
  80729. * Mesh cap setting : no cap
  80730. */
  80731. static readonly NO_CAP: number;
  80732. /**
  80733. * Mesh cap setting : one cap at the beginning of the mesh
  80734. */
  80735. static readonly CAP_START: number;
  80736. /**
  80737. * Mesh cap setting : one cap at the end of the mesh
  80738. */
  80739. static readonly CAP_END: number;
  80740. /**
  80741. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80742. */
  80743. static readonly CAP_ALL: number;
  80744. /**
  80745. * Gets the default side orientation.
  80746. * @param orientation the orientation to value to attempt to get
  80747. * @returns the default orientation
  80748. * @hidden
  80749. */
  80750. static _GetDefaultSideOrientation(orientation?: number): number;
  80751. private _onBeforeRenderObservable;
  80752. private _onBeforeBindObservable;
  80753. private _onAfterRenderObservable;
  80754. private _onBeforeDrawObservable;
  80755. /**
  80756. * An event triggered before rendering the mesh
  80757. */
  80758. readonly onBeforeRenderObservable: Observable<Mesh>;
  80759. /**
  80760. * An event triggered before binding the mesh
  80761. */
  80762. readonly onBeforeBindObservable: Observable<Mesh>;
  80763. /**
  80764. * An event triggered after rendering the mesh
  80765. */
  80766. readonly onAfterRenderObservable: Observable<Mesh>;
  80767. /**
  80768. * An event triggered before drawing the mesh
  80769. */
  80770. readonly onBeforeDrawObservable: Observable<Mesh>;
  80771. private _onBeforeDrawObserver;
  80772. /**
  80773. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80774. */
  80775. onBeforeDraw: () => void;
  80776. /**
  80777. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80778. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80779. */
  80780. delayLoadState: number;
  80781. /**
  80782. * Gets the list of instances created from this mesh
  80783. * it is not supposed to be modified manually.
  80784. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80785. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80786. */
  80787. instances: InstancedMesh[];
  80788. /**
  80789. * Gets the file containing delay loading data for this mesh
  80790. */
  80791. delayLoadingFile: string;
  80792. /** @hidden */
  80793. _binaryInfo: any;
  80794. private _LODLevels;
  80795. /**
  80796. * User defined function used to change how LOD level selection is done
  80797. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80798. */
  80799. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80800. private _morphTargetManager;
  80801. /**
  80802. * Gets or sets the morph target manager
  80803. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80804. */
  80805. morphTargetManager: Nullable<MorphTargetManager>;
  80806. /** @hidden */
  80807. _creationDataStorage: Nullable<_CreationDataStorage>;
  80808. /** @hidden */
  80809. _geometry: Nullable<Geometry>;
  80810. /** @hidden */
  80811. _delayInfo: Array<string>;
  80812. /** @hidden */
  80813. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80814. /** @hidden */
  80815. _instanceDataStorage: _InstanceDataStorage;
  80816. private _effectiveMaterial;
  80817. /** @hidden */
  80818. _shouldGenerateFlatShading: boolean;
  80819. private _preActivateId;
  80820. /** @hidden */
  80821. _originalBuilderSideOrientation: number;
  80822. /**
  80823. * Use this property to change the original side orientation defined at construction time
  80824. */
  80825. overrideMaterialSideOrientation: Nullable<number>;
  80826. private _areNormalsFrozen;
  80827. private _sourcePositions;
  80828. private _sourceNormals;
  80829. private _source;
  80830. private meshMap;
  80831. /**
  80832. * Gets the source mesh (the one used to clone this one from)
  80833. */
  80834. readonly source: Nullable<Mesh>;
  80835. /**
  80836. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80837. */
  80838. isUnIndexed: boolean;
  80839. /**
  80840. * @constructor
  80841. * @param name The value used by scene.getMeshByName() to do a lookup.
  80842. * @param scene The scene to add this mesh to.
  80843. * @param parent The parent of this mesh, if it has one
  80844. * @param source An optional Mesh from which geometry is shared, cloned.
  80845. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80846. * When false, achieved by calling a clone(), also passing False.
  80847. * This will make creation of children, recursive.
  80848. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80849. */
  80850. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80851. /**
  80852. * Gets the class name
  80853. * @returns the string "Mesh".
  80854. */
  80855. getClassName(): string;
  80856. /** @hidden */
  80857. readonly _isMesh: boolean;
  80858. /**
  80859. * Returns a description of this mesh
  80860. * @param fullDetails define if full details about this mesh must be used
  80861. * @returns a descriptive string representing this mesh
  80862. */
  80863. toString(fullDetails?: boolean): string;
  80864. /** @hidden */
  80865. _unBindEffect(): void;
  80866. /**
  80867. * Gets a boolean indicating if this mesh has LOD
  80868. */
  80869. readonly hasLODLevels: boolean;
  80870. /**
  80871. * Gets the list of MeshLODLevel associated with the current mesh
  80872. * @returns an array of MeshLODLevel
  80873. */
  80874. getLODLevels(): MeshLODLevel[];
  80875. private _sortLODLevels;
  80876. /**
  80877. * Add a mesh as LOD level triggered at the given distance.
  80878. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80879. * @param distance The distance from the center of the object to show this level
  80880. * @param mesh The mesh to be added as LOD level (can be null)
  80881. * @return This mesh (for chaining)
  80882. */
  80883. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80884. /**
  80885. * Returns the LOD level mesh at the passed distance or null if not found.
  80886. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80887. * @param distance The distance from the center of the object to show this level
  80888. * @returns a Mesh or `null`
  80889. */
  80890. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80891. /**
  80892. * Remove a mesh from the LOD array
  80893. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80894. * @param mesh defines the mesh to be removed
  80895. * @return This mesh (for chaining)
  80896. */
  80897. removeLODLevel(mesh: Mesh): Mesh;
  80898. /**
  80899. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80900. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80901. * @param camera defines the camera to use to compute distance
  80902. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80903. * @return This mesh (for chaining)
  80904. */
  80905. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80906. /**
  80907. * Gets the mesh internal Geometry object
  80908. */
  80909. readonly geometry: Nullable<Geometry>;
  80910. /**
  80911. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80912. * @returns the total number of vertices
  80913. */
  80914. getTotalVertices(): number;
  80915. /**
  80916. * Returns the content of an associated vertex buffer
  80917. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80918. * - VertexBuffer.PositionKind
  80919. * - VertexBuffer.UVKind
  80920. * - VertexBuffer.UV2Kind
  80921. * - VertexBuffer.UV3Kind
  80922. * - VertexBuffer.UV4Kind
  80923. * - VertexBuffer.UV5Kind
  80924. * - VertexBuffer.UV6Kind
  80925. * - VertexBuffer.ColorKind
  80926. * - VertexBuffer.MatricesIndicesKind
  80927. * - VertexBuffer.MatricesIndicesExtraKind
  80928. * - VertexBuffer.MatricesWeightsKind
  80929. * - VertexBuffer.MatricesWeightsExtraKind
  80930. * @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
  80931. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80932. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80933. */
  80934. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80935. /**
  80936. * Returns the mesh VertexBuffer object from the requested `kind`
  80937. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80938. * - VertexBuffer.PositionKind
  80939. * - VertexBuffer.UVKind
  80940. * - VertexBuffer.UV2Kind
  80941. * - VertexBuffer.UV3Kind
  80942. * - VertexBuffer.UV4Kind
  80943. * - VertexBuffer.UV5Kind
  80944. * - VertexBuffer.UV6Kind
  80945. * - VertexBuffer.ColorKind
  80946. * - VertexBuffer.MatricesIndicesKind
  80947. * - VertexBuffer.MatricesIndicesExtraKind
  80948. * - VertexBuffer.MatricesWeightsKind
  80949. * - VertexBuffer.MatricesWeightsExtraKind
  80950. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80951. */
  80952. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80953. /**
  80954. * Tests if a specific vertex buffer is associated with this mesh
  80955. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80956. * - VertexBuffer.PositionKind
  80957. * - VertexBuffer.UVKind
  80958. * - VertexBuffer.UV2Kind
  80959. * - VertexBuffer.UV3Kind
  80960. * - VertexBuffer.UV4Kind
  80961. * - VertexBuffer.UV5Kind
  80962. * - VertexBuffer.UV6Kind
  80963. * - VertexBuffer.ColorKind
  80964. * - VertexBuffer.MatricesIndicesKind
  80965. * - VertexBuffer.MatricesIndicesExtraKind
  80966. * - VertexBuffer.MatricesWeightsKind
  80967. * - VertexBuffer.MatricesWeightsExtraKind
  80968. * @returns a boolean
  80969. */
  80970. isVerticesDataPresent(kind: string): boolean;
  80971. /**
  80972. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80973. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80974. * - VertexBuffer.PositionKind
  80975. * - VertexBuffer.UVKind
  80976. * - VertexBuffer.UV2Kind
  80977. * - VertexBuffer.UV3Kind
  80978. * - VertexBuffer.UV4Kind
  80979. * - VertexBuffer.UV5Kind
  80980. * - VertexBuffer.UV6Kind
  80981. * - VertexBuffer.ColorKind
  80982. * - VertexBuffer.MatricesIndicesKind
  80983. * - VertexBuffer.MatricesIndicesExtraKind
  80984. * - VertexBuffer.MatricesWeightsKind
  80985. * - VertexBuffer.MatricesWeightsExtraKind
  80986. * @returns a boolean
  80987. */
  80988. isVertexBufferUpdatable(kind: string): boolean;
  80989. /**
  80990. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80991. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80992. * - VertexBuffer.PositionKind
  80993. * - VertexBuffer.UVKind
  80994. * - VertexBuffer.UV2Kind
  80995. * - VertexBuffer.UV3Kind
  80996. * - VertexBuffer.UV4Kind
  80997. * - VertexBuffer.UV5Kind
  80998. * - VertexBuffer.UV6Kind
  80999. * - VertexBuffer.ColorKind
  81000. * - VertexBuffer.MatricesIndicesKind
  81001. * - VertexBuffer.MatricesIndicesExtraKind
  81002. * - VertexBuffer.MatricesWeightsKind
  81003. * - VertexBuffer.MatricesWeightsExtraKind
  81004. * @returns an array of strings
  81005. */
  81006. getVerticesDataKinds(): string[];
  81007. /**
  81008. * Returns a positive integer : the total number of indices in this mesh geometry.
  81009. * @returns the numner of indices or zero if the mesh has no geometry.
  81010. */
  81011. getTotalIndices(): number;
  81012. /**
  81013. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81014. * @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.
  81015. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81016. * @returns the indices array or an empty array if the mesh has no geometry
  81017. */
  81018. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81019. readonly isBlocked: boolean;
  81020. /**
  81021. * Determine if the current mesh is ready to be rendered
  81022. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81023. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81024. * @returns true if all associated assets are ready (material, textures, shaders)
  81025. */
  81026. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81027. /**
  81028. * 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.
  81029. */
  81030. readonly areNormalsFrozen: boolean;
  81031. /**
  81032. * 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.
  81033. * @returns the current mesh
  81034. */
  81035. freezeNormals(): Mesh;
  81036. /**
  81037. * 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
  81038. * @returns the current mesh
  81039. */
  81040. unfreezeNormals(): Mesh;
  81041. /**
  81042. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81043. */
  81044. overridenInstanceCount: number;
  81045. /** @hidden */
  81046. _preActivate(): Mesh;
  81047. /** @hidden */
  81048. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81049. /** @hidden */
  81050. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81051. /**
  81052. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81053. * This means the mesh underlying bounding box and sphere are recomputed.
  81054. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81055. * @returns the current mesh
  81056. */
  81057. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81058. /** @hidden */
  81059. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81060. /**
  81061. * This function will subdivide the mesh into multiple submeshes
  81062. * @param count defines the expected number of submeshes
  81063. */
  81064. subdivide(count: number): void;
  81065. /**
  81066. * Copy a FloatArray into a specific associated vertex buffer
  81067. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81068. * - VertexBuffer.PositionKind
  81069. * - VertexBuffer.UVKind
  81070. * - VertexBuffer.UV2Kind
  81071. * - VertexBuffer.UV3Kind
  81072. * - VertexBuffer.UV4Kind
  81073. * - VertexBuffer.UV5Kind
  81074. * - VertexBuffer.UV6Kind
  81075. * - VertexBuffer.ColorKind
  81076. * - VertexBuffer.MatricesIndicesKind
  81077. * - VertexBuffer.MatricesIndicesExtraKind
  81078. * - VertexBuffer.MatricesWeightsKind
  81079. * - VertexBuffer.MatricesWeightsExtraKind
  81080. * @param data defines the data source
  81081. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81082. * @param stride defines the data stride size (can be null)
  81083. * @returns the current mesh
  81084. */
  81085. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81086. /**
  81087. * Flags an associated vertex buffer as updatable
  81088. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81089. * - VertexBuffer.PositionKind
  81090. * - VertexBuffer.UVKind
  81091. * - VertexBuffer.UV2Kind
  81092. * - VertexBuffer.UV3Kind
  81093. * - VertexBuffer.UV4Kind
  81094. * - VertexBuffer.UV5Kind
  81095. * - VertexBuffer.UV6Kind
  81096. * - VertexBuffer.ColorKind
  81097. * - VertexBuffer.MatricesIndicesKind
  81098. * - VertexBuffer.MatricesIndicesExtraKind
  81099. * - VertexBuffer.MatricesWeightsKind
  81100. * - VertexBuffer.MatricesWeightsExtraKind
  81101. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81102. */
  81103. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81104. /**
  81105. * Sets the mesh global Vertex Buffer
  81106. * @param buffer defines the buffer to use
  81107. * @returns the current mesh
  81108. */
  81109. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81110. /**
  81111. * Update a specific associated vertex buffer
  81112. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81113. * - VertexBuffer.PositionKind
  81114. * - VertexBuffer.UVKind
  81115. * - VertexBuffer.UV2Kind
  81116. * - VertexBuffer.UV3Kind
  81117. * - VertexBuffer.UV4Kind
  81118. * - VertexBuffer.UV5Kind
  81119. * - VertexBuffer.UV6Kind
  81120. * - VertexBuffer.ColorKind
  81121. * - VertexBuffer.MatricesIndicesKind
  81122. * - VertexBuffer.MatricesIndicesExtraKind
  81123. * - VertexBuffer.MatricesWeightsKind
  81124. * - VertexBuffer.MatricesWeightsExtraKind
  81125. * @param data defines the data source
  81126. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81127. * @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)
  81128. * @returns the current mesh
  81129. */
  81130. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81131. /**
  81132. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81133. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81134. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81135. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81136. * @returns the current mesh
  81137. */
  81138. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81139. /**
  81140. * Creates a un-shared specific occurence of the geometry for the mesh.
  81141. * @returns the current mesh
  81142. */
  81143. makeGeometryUnique(): Mesh;
  81144. /**
  81145. * Set the index buffer of this mesh
  81146. * @param indices defines the source data
  81147. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81148. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81149. * @returns the current mesh
  81150. */
  81151. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81152. /**
  81153. * Update the current index buffer
  81154. * @param indices defines the source data
  81155. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81156. * @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)
  81157. * @returns the current mesh
  81158. */
  81159. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81160. /**
  81161. * Invert the geometry to move from a right handed system to a left handed one.
  81162. * @returns the current mesh
  81163. */
  81164. toLeftHanded(): Mesh;
  81165. /** @hidden */
  81166. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81167. /** @hidden */
  81168. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81169. /**
  81170. * Registers for this mesh a javascript function called just before the rendering process
  81171. * @param func defines the function to call before rendering this mesh
  81172. * @returns the current mesh
  81173. */
  81174. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81175. /**
  81176. * Disposes a previously registered javascript function called before the rendering
  81177. * @param func defines the function to remove
  81178. * @returns the current mesh
  81179. */
  81180. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81181. /**
  81182. * Registers for this mesh a javascript function called just after the rendering is complete
  81183. * @param func defines the function to call after rendering this mesh
  81184. * @returns the current mesh
  81185. */
  81186. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81187. /**
  81188. * Disposes a previously registered javascript function called after the rendering.
  81189. * @param func defines the function to remove
  81190. * @returns the current mesh
  81191. */
  81192. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81193. /** @hidden */
  81194. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81195. /** @hidden */
  81196. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81197. /** @hidden */
  81198. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81199. /** @hidden */
  81200. _freeze(): void;
  81201. /** @hidden */
  81202. _unFreeze(): void;
  81203. /**
  81204. * 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
  81205. * @param subMesh defines the subMesh to render
  81206. * @param enableAlphaMode defines if alpha mode can be changed
  81207. * @returns the current mesh
  81208. */
  81209. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81210. private _onBeforeDraw;
  81211. /**
  81212. * Renormalize the mesh and patch it up if there are no weights
  81213. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81214. * However in the case of zero weights then we set just a single influence to 1.
  81215. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81216. */
  81217. cleanMatrixWeights(): void;
  81218. private normalizeSkinFourWeights;
  81219. private normalizeSkinWeightsAndExtra;
  81220. /**
  81221. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81222. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81223. * the user know there was an issue with importing the mesh
  81224. * @returns a validation object with skinned, valid and report string
  81225. */
  81226. validateSkinning(): {
  81227. skinned: boolean;
  81228. valid: boolean;
  81229. report: string;
  81230. };
  81231. /** @hidden */
  81232. _checkDelayState(): Mesh;
  81233. private _queueLoad;
  81234. /**
  81235. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81236. * A mesh is in the frustum if its bounding box intersects the frustum
  81237. * @param frustumPlanes defines the frustum to test
  81238. * @returns true if the mesh is in the frustum planes
  81239. */
  81240. isInFrustum(frustumPlanes: Plane[]): boolean;
  81241. /**
  81242. * Sets the mesh material by the material or multiMaterial `id` property
  81243. * @param id is a string identifying the material or the multiMaterial
  81244. * @returns the current mesh
  81245. */
  81246. setMaterialByID(id: string): Mesh;
  81247. /**
  81248. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81249. * @returns an array of IAnimatable
  81250. */
  81251. getAnimatables(): IAnimatable[];
  81252. /**
  81253. * Modifies the mesh geometry according to the passed transformation matrix.
  81254. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81255. * The mesh normals are modified using the same transformation.
  81256. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81257. * @param transform defines the transform matrix to use
  81258. * @see http://doc.babylonjs.com/resources/baking_transformations
  81259. * @returns the current mesh
  81260. */
  81261. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81262. /**
  81263. * Modifies the mesh geometry according to its own current World Matrix.
  81264. * The mesh World Matrix is then reset.
  81265. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81266. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81267. * @see http://doc.babylonjs.com/resources/baking_transformations
  81268. * @returns the current mesh
  81269. */
  81270. bakeCurrentTransformIntoVertices(): Mesh;
  81271. /** @hidden */
  81272. readonly _positions: Nullable<Vector3[]>;
  81273. /** @hidden */
  81274. _resetPointsArrayCache(): Mesh;
  81275. /** @hidden */
  81276. _generatePointsArray(): boolean;
  81277. /**
  81278. * Returns a new Mesh object generated from the current mesh properties.
  81279. * This method must not get confused with createInstance()
  81280. * @param name is a string, the name given to the new mesh
  81281. * @param newParent can be any Node object (default `null`)
  81282. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81283. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81284. * @returns a new mesh
  81285. */
  81286. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81287. /**
  81288. * Releases resources associated with this mesh.
  81289. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81290. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81291. */
  81292. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81293. /**
  81294. * Modifies the mesh geometry according to a displacement map.
  81295. * 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.
  81296. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81297. * @param url is a string, the URL from the image file is to be downloaded.
  81298. * @param minHeight is the lower limit of the displacement.
  81299. * @param maxHeight is the upper limit of the displacement.
  81300. * @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.
  81301. * @param uvOffset is an optional vector2 used to offset UV.
  81302. * @param uvScale is an optional vector2 used to scale UV.
  81303. * @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.
  81304. * @returns the Mesh.
  81305. */
  81306. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81307. /**
  81308. * Modifies the mesh geometry according to a displacementMap buffer.
  81309. * 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.
  81310. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81311. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81312. * @param heightMapWidth is the width of the buffer image.
  81313. * @param heightMapHeight is the height of the buffer image.
  81314. * @param minHeight is the lower limit of the displacement.
  81315. * @param maxHeight is the upper limit of the displacement.
  81316. * @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.
  81317. * @param uvOffset is an optional vector2 used to offset UV.
  81318. * @param uvScale is an optional vector2 used to scale UV.
  81319. * @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.
  81320. * @returns the Mesh.
  81321. */
  81322. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81323. /**
  81324. * Modify the mesh to get a flat shading rendering.
  81325. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81326. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81327. * @returns current mesh
  81328. */
  81329. convertToFlatShadedMesh(): Mesh;
  81330. /**
  81331. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81332. * In other words, more vertices, no more indices and a single bigger VBO.
  81333. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81334. * @returns current mesh
  81335. */
  81336. convertToUnIndexedMesh(): Mesh;
  81337. /**
  81338. * Inverses facet orientations.
  81339. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81340. * @param flipNormals will also inverts the normals
  81341. * @returns current mesh
  81342. */
  81343. flipFaces(flipNormals?: boolean): Mesh;
  81344. /**
  81345. * Increase the number of facets and hence vertices in a mesh
  81346. * Vertex normals are interpolated from existing vertex normals
  81347. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81348. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81349. */
  81350. increaseVertices(numberPerEdge: number): void;
  81351. /**
  81352. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81353. * This will undo any application of covertToFlatShadedMesh
  81354. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81355. */
  81356. forceSharedVertices(): void;
  81357. /** @hidden */
  81358. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81359. /** @hidden */
  81360. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81361. /**
  81362. * Creates a new InstancedMesh object from the mesh model.
  81363. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81364. * @param name defines the name of the new instance
  81365. * @returns a new InstancedMesh
  81366. */
  81367. createInstance(name: string): InstancedMesh;
  81368. /**
  81369. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81370. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81371. * @returns the current mesh
  81372. */
  81373. synchronizeInstances(): Mesh;
  81374. /**
  81375. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81376. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81377. * This should be used together with the simplification to avoid disappearing triangles.
  81378. * @param successCallback an optional success callback to be called after the optimization finished.
  81379. * @returns the current mesh
  81380. */
  81381. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81382. /**
  81383. * Serialize current mesh
  81384. * @param serializationObject defines the object which will receive the serialization data
  81385. */
  81386. serialize(serializationObject: any): void;
  81387. /** @hidden */
  81388. _syncGeometryWithMorphTargetManager(): void;
  81389. /** @hidden */
  81390. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81391. /**
  81392. * Returns a new Mesh object parsed from the source provided.
  81393. * @param parsedMesh is the source
  81394. * @param scene defines the hosting scene
  81395. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81396. * @returns a new Mesh
  81397. */
  81398. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81399. /**
  81400. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81401. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81402. * @param name defines the name of the mesh to create
  81403. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81404. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81405. * @param closePath creates a seam between the first and the last points of each path of the path array
  81406. * @param offset is taken in account only if the `pathArray` is containing a single path
  81407. * @param scene defines the hosting scene
  81408. * @param updatable defines if the mesh must be flagged as updatable
  81409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81410. * @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)
  81411. * @returns a new Mesh
  81412. */
  81413. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81414. /**
  81415. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81416. * @param name defines the name of the mesh to create
  81417. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81418. * @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
  81419. * @param scene defines the hosting scene
  81420. * @param updatable defines if the mesh must be flagged as updatable
  81421. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81422. * @returns a new Mesh
  81423. */
  81424. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81425. /**
  81426. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81427. * @param name defines the name of the mesh to create
  81428. * @param size sets the size (float) of each box side (default 1)
  81429. * @param scene defines the hosting scene
  81430. * @param updatable defines if the mesh must be flagged as updatable
  81431. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81432. * @returns a new Mesh
  81433. */
  81434. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81435. /**
  81436. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81437. * @param name defines the name of the mesh to create
  81438. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81439. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81440. * @param scene defines the hosting scene
  81441. * @param updatable defines if the mesh must be flagged as updatable
  81442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81443. * @returns a new Mesh
  81444. */
  81445. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81446. /**
  81447. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81448. * @param name defines the name of the mesh to create
  81449. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81450. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81451. * @param scene defines the hosting scene
  81452. * @returns a new Mesh
  81453. */
  81454. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81455. /**
  81456. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81457. * @param name defines the name of the mesh to create
  81458. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81459. * @param diameterTop set the top cap diameter (floats, default 1)
  81460. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81461. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81462. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81463. * @param scene defines the hosting scene
  81464. * @param updatable defines if the mesh must be flagged as updatable
  81465. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81466. * @returns a new Mesh
  81467. */
  81468. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81469. /**
  81470. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81471. * @param name defines the name of the mesh to create
  81472. * @param diameter sets the diameter size (float) of the torus (default 1)
  81473. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81474. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81475. * @param scene defines the hosting scene
  81476. * @param updatable defines if the mesh must be flagged as updatable
  81477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81478. * @returns a new Mesh
  81479. */
  81480. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81481. /**
  81482. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81483. * @param name defines the name of the mesh to create
  81484. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81485. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81486. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81487. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81488. * @param p the number of windings on X axis (positive integers, default 2)
  81489. * @param q the number of windings on Y axis (positive integers, default 3)
  81490. * @param scene defines the hosting scene
  81491. * @param updatable defines if the mesh must be flagged as updatable
  81492. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81493. * @returns a new Mesh
  81494. */
  81495. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81496. /**
  81497. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81498. * @param name defines the name of the mesh to create
  81499. * @param points is an array successive Vector3
  81500. * @param scene defines the hosting scene
  81501. * @param updatable defines if the mesh must be flagged as updatable
  81502. * @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).
  81503. * @returns a new Mesh
  81504. */
  81505. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81506. /**
  81507. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81508. * @param name defines the name of the mesh to create
  81509. * @param points is an array successive Vector3
  81510. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81511. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81512. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81513. * @param scene defines the hosting scene
  81514. * @param updatable defines if the mesh must be flagged as updatable
  81515. * @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)
  81516. * @returns a new Mesh
  81517. */
  81518. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81519. /**
  81520. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81521. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81522. * 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.
  81523. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81524. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81525. * Remember you can only change the shape positions, not their number when updating a polygon.
  81526. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81527. * @param name defines the name of the mesh to create
  81528. * @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
  81529. * @param scene defines the hosting scene
  81530. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  81534. * @returns a new Mesh
  81535. */
  81536. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81537. /**
  81538. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81539. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81540. * @param name defines the name of the mesh to create
  81541. * @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
  81542. * @param depth defines the height of extrusion
  81543. * @param scene defines the hosting scene
  81544. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81545. * @param updatable defines if the mesh must be flagged as updatable
  81546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81547. * @param earcutInjection can be used to inject your own earcut reference
  81548. * @returns a new Mesh
  81549. */
  81550. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81551. /**
  81552. * Creates an extruded shape mesh.
  81553. * 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
  81554. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81555. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81556. * @param name defines the name of the mesh to create
  81557. * @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
  81558. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81559. * @param scale is the value to scale the shape
  81560. * @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
  81561. * @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
  81562. * @param scene defines the hosting scene
  81563. * @param updatable defines if the mesh must be flagged as updatable
  81564. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81565. * @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)
  81566. * @returns a new Mesh
  81567. */
  81568. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81569. /**
  81570. * Creates an custom extruded shape mesh.
  81571. * The custom extrusion is a parametric shape.
  81572. * It has no predefined shape. Its final shape will depend on the input parameters.
  81573. * Please consider using the same method from the MeshBuilder class instead
  81574. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81575. * @param name defines the name of the mesh to create
  81576. * @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
  81577. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81578. * @param scaleFunction is a custom Javascript function called on each path point
  81579. * @param rotationFunction is a custom Javascript function called on each path point
  81580. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81581. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81582. * @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
  81583. * @param scene defines the hosting scene
  81584. * @param updatable defines if the mesh must be flagged as updatable
  81585. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81586. * @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)
  81587. * @returns a new Mesh
  81588. */
  81589. 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;
  81590. /**
  81591. * Creates lathe mesh.
  81592. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81593. * Please consider using the same method from the MeshBuilder class instead
  81594. * @param name defines the name of the mesh to create
  81595. * @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
  81596. * @param radius is the radius value of the lathe
  81597. * @param tessellation is the side number of the lathe.
  81598. * @param scene defines the hosting scene
  81599. * @param updatable defines if the mesh must be flagged as updatable
  81600. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81601. * @returns a new Mesh
  81602. */
  81603. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81604. /**
  81605. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81606. * @param name defines the name of the mesh to create
  81607. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81608. * @param scene defines the hosting scene
  81609. * @param updatable defines if the mesh must be flagged as updatable
  81610. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81611. * @returns a new Mesh
  81612. */
  81613. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81614. /**
  81615. * Creates a ground mesh.
  81616. * Please consider using the same method from the MeshBuilder class instead
  81617. * @param name defines the name of the mesh to create
  81618. * @param width set the width of the ground
  81619. * @param height set the height of the ground
  81620. * @param subdivisions sets the number of subdivisions per side
  81621. * @param scene defines the hosting scene
  81622. * @param updatable defines if the mesh must be flagged as updatable
  81623. * @returns a new Mesh
  81624. */
  81625. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81626. /**
  81627. * Creates a tiled ground mesh.
  81628. * Please consider using the same method from the MeshBuilder class instead
  81629. * @param name defines the name of the mesh to create
  81630. * @param xmin set the ground minimum X coordinate
  81631. * @param zmin set the ground minimum Y coordinate
  81632. * @param xmax set the ground maximum X coordinate
  81633. * @param zmax set the ground maximum Z coordinate
  81634. * @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
  81635. * @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
  81636. * @param scene defines the hosting scene
  81637. * @param updatable defines if the mesh must be flagged as updatable
  81638. * @returns a new Mesh
  81639. */
  81640. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81641. w: number;
  81642. h: number;
  81643. }, precision: {
  81644. w: number;
  81645. h: number;
  81646. }, scene: Scene, updatable?: boolean): Mesh;
  81647. /**
  81648. * Creates a ground mesh from a height map.
  81649. * Please consider using the same method from the MeshBuilder class instead
  81650. * @see http://doc.babylonjs.com/babylon101/height_map
  81651. * @param name defines the name of the mesh to create
  81652. * @param url sets the URL of the height map image resource
  81653. * @param width set the ground width size
  81654. * @param height set the ground height size
  81655. * @param subdivisions sets the number of subdivision per side
  81656. * @param minHeight is the minimum altitude on the ground
  81657. * @param maxHeight is the maximum altitude on the ground
  81658. * @param scene defines the hosting scene
  81659. * @param updatable defines if the mesh must be flagged as updatable
  81660. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81661. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81662. * @returns a new Mesh
  81663. */
  81664. 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;
  81665. /**
  81666. * Creates a tube mesh.
  81667. * The tube is a parametric shape.
  81668. * It has no predefined shape. Its final shape will depend on the input parameters.
  81669. * Please consider using the same method from the MeshBuilder class instead
  81670. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81671. * @param name defines the name of the mesh to create
  81672. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81673. * @param radius sets the tube radius size
  81674. * @param tessellation is the number of sides on the tubular surface
  81675. * @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
  81676. * @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
  81677. * @param scene defines the hosting scene
  81678. * @param updatable defines if the mesh must be flagged as updatable
  81679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81680. * @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)
  81681. * @returns a new Mesh
  81682. */
  81683. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81684. (i: number, distance: number): number;
  81685. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81686. /**
  81687. * Creates a polyhedron mesh.
  81688. * Please consider using the same method from the MeshBuilder class instead.
  81689. * * 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
  81690. * * The parameter `size` (positive float, default 1) sets the polygon size
  81691. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81692. * * 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`
  81693. * * 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
  81694. * * 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)`)
  81695. * * 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
  81696. * * 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
  81697. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81698. * * If you create a double-sided mesh, you can choose what parts of 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
  81699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81700. * @param name defines the name of the mesh to create
  81701. * @param options defines the options used to create the mesh
  81702. * @param scene defines the hosting scene
  81703. * @returns a new Mesh
  81704. */
  81705. static CreatePolyhedron(name: string, options: {
  81706. type?: number;
  81707. size?: number;
  81708. sizeX?: number;
  81709. sizeY?: number;
  81710. sizeZ?: number;
  81711. custom?: any;
  81712. faceUV?: Vector4[];
  81713. faceColors?: Color4[];
  81714. updatable?: boolean;
  81715. sideOrientation?: number;
  81716. }, scene: Scene): Mesh;
  81717. /**
  81718. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81719. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81720. * * 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`)
  81721. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81722. * * 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
  81723. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81724. * * If you create a double-sided mesh, you can choose what parts of 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
  81725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81726. * @param name defines the name of the mesh
  81727. * @param options defines the options used to create the mesh
  81728. * @param scene defines the hosting scene
  81729. * @returns a new Mesh
  81730. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81731. */
  81732. static CreateIcoSphere(name: string, options: {
  81733. radius?: number;
  81734. flat?: boolean;
  81735. subdivisions?: number;
  81736. sideOrientation?: number;
  81737. updatable?: boolean;
  81738. }, scene: Scene): Mesh;
  81739. /**
  81740. * Creates a decal mesh.
  81741. * Please consider using the same method from the MeshBuilder class instead.
  81742. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81743. * @param name defines the name of the mesh
  81744. * @param sourceMesh defines the mesh receiving the decal
  81745. * @param position sets the position of the decal in world coordinates
  81746. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81747. * @param size sets the decal scaling
  81748. * @param angle sets the angle to rotate the decal
  81749. * @returns a new Mesh
  81750. */
  81751. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81752. /**
  81753. * Prepare internal position array for software CPU skinning
  81754. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81755. */
  81756. setPositionsForCPUSkinning(): Float32Array;
  81757. /**
  81758. * Prepare internal normal array for software CPU skinning
  81759. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81760. */
  81761. setNormalsForCPUSkinning(): Float32Array;
  81762. /**
  81763. * Updates the vertex buffer by applying transformation from the bones
  81764. * @param skeleton defines the skeleton to apply to current mesh
  81765. * @returns the current mesh
  81766. */
  81767. applySkeleton(skeleton: Skeleton): Mesh;
  81768. /**
  81769. * 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
  81770. * @param meshes defines the list of meshes to scan
  81771. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81772. */
  81773. static MinMax(meshes: AbstractMesh[]): {
  81774. min: Vector3;
  81775. max: Vector3;
  81776. };
  81777. /**
  81778. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81779. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81780. * @returns a vector3
  81781. */
  81782. static Center(meshesOrMinMaxVector: {
  81783. min: Vector3;
  81784. max: Vector3;
  81785. } | AbstractMesh[]): Vector3;
  81786. /**
  81787. * Merge the array of meshes into a single mesh for performance reasons.
  81788. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81789. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81790. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81791. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81792. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81793. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81794. * @returns a new mesh
  81795. */
  81796. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81797. /** @hidden */
  81798. addInstance(instance: InstancedMesh): void;
  81799. /** @hidden */
  81800. removeInstance(instance: InstancedMesh): void;
  81801. }
  81802. }
  81803. declare module BABYLON {
  81804. /**
  81805. * Base class for the main features of a material in Babylon.js
  81806. */
  81807. export class Material implements IAnimatable {
  81808. /**
  81809. * Returns the triangle fill mode
  81810. */
  81811. static readonly TriangleFillMode: number;
  81812. /**
  81813. * Returns the wireframe mode
  81814. */
  81815. static readonly WireFrameFillMode: number;
  81816. /**
  81817. * Returns the point fill mode
  81818. */
  81819. static readonly PointFillMode: number;
  81820. /**
  81821. * Returns the point list draw mode
  81822. */
  81823. static readonly PointListDrawMode: number;
  81824. /**
  81825. * Returns the line list draw mode
  81826. */
  81827. static readonly LineListDrawMode: number;
  81828. /**
  81829. * Returns the line loop draw mode
  81830. */
  81831. static readonly LineLoopDrawMode: number;
  81832. /**
  81833. * Returns the line strip draw mode
  81834. */
  81835. static readonly LineStripDrawMode: number;
  81836. /**
  81837. * Returns the triangle strip draw mode
  81838. */
  81839. static readonly TriangleStripDrawMode: number;
  81840. /**
  81841. * Returns the triangle fan draw mode
  81842. */
  81843. static readonly TriangleFanDrawMode: number;
  81844. /**
  81845. * Stores the clock-wise side orientation
  81846. */
  81847. static readonly ClockWiseSideOrientation: number;
  81848. /**
  81849. * Stores the counter clock-wise side orientation
  81850. */
  81851. static readonly CounterClockWiseSideOrientation: number;
  81852. /**
  81853. * The dirty texture flag value
  81854. */
  81855. static readonly TextureDirtyFlag: number;
  81856. /**
  81857. * The dirty light flag value
  81858. */
  81859. static readonly LightDirtyFlag: number;
  81860. /**
  81861. * The dirty fresnel flag value
  81862. */
  81863. static readonly FresnelDirtyFlag: number;
  81864. /**
  81865. * The dirty attribute flag value
  81866. */
  81867. static readonly AttributesDirtyFlag: number;
  81868. /**
  81869. * The dirty misc flag value
  81870. */
  81871. static readonly MiscDirtyFlag: number;
  81872. /**
  81873. * The all dirty flag value
  81874. */
  81875. static readonly AllDirtyFlag: number;
  81876. /**
  81877. * The ID of the material
  81878. */
  81879. id: string;
  81880. /**
  81881. * Gets or sets the unique id of the material
  81882. */
  81883. uniqueId: number;
  81884. /**
  81885. * The name of the material
  81886. */
  81887. name: string;
  81888. /**
  81889. * Gets or sets user defined metadata
  81890. */
  81891. metadata: any;
  81892. /**
  81893. * For internal use only. Please do not use.
  81894. */
  81895. reservedDataStore: any;
  81896. /**
  81897. * Specifies if the ready state should be checked on each call
  81898. */
  81899. checkReadyOnEveryCall: boolean;
  81900. /**
  81901. * Specifies if the ready state should be checked once
  81902. */
  81903. checkReadyOnlyOnce: boolean;
  81904. /**
  81905. * The state of the material
  81906. */
  81907. state: string;
  81908. /**
  81909. * The alpha value of the material
  81910. */
  81911. protected _alpha: number;
  81912. /**
  81913. * List of inspectable custom properties (used by the Inspector)
  81914. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81915. */
  81916. inspectableCustomProperties: IInspectable[];
  81917. /**
  81918. * Sets the alpha value of the material
  81919. */
  81920. /**
  81921. * Gets the alpha value of the material
  81922. */
  81923. alpha: number;
  81924. /**
  81925. * Specifies if back face culling is enabled
  81926. */
  81927. protected _backFaceCulling: boolean;
  81928. /**
  81929. * Sets the back-face culling state
  81930. */
  81931. /**
  81932. * Gets the back-face culling state
  81933. */
  81934. backFaceCulling: boolean;
  81935. /**
  81936. * Stores the value for side orientation
  81937. */
  81938. sideOrientation: number;
  81939. /**
  81940. * Callback triggered when the material is compiled
  81941. */
  81942. onCompiled: Nullable<(effect: Effect) => void>;
  81943. /**
  81944. * Callback triggered when an error occurs
  81945. */
  81946. onError: Nullable<(effect: Effect, errors: string) => void>;
  81947. /**
  81948. * Callback triggered to get the render target textures
  81949. */
  81950. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  81951. /**
  81952. * Gets a boolean indicating that current material needs to register RTT
  81953. */
  81954. readonly hasRenderTargetTextures: boolean;
  81955. /**
  81956. * Specifies if the material should be serialized
  81957. */
  81958. doNotSerialize: boolean;
  81959. /**
  81960. * @hidden
  81961. */
  81962. _storeEffectOnSubMeshes: boolean;
  81963. /**
  81964. * Stores the animations for the material
  81965. */
  81966. animations: Nullable<Array<Animation>>;
  81967. /**
  81968. * An event triggered when the material is disposed
  81969. */
  81970. onDisposeObservable: Observable<Material>;
  81971. /**
  81972. * An observer which watches for dispose events
  81973. */
  81974. private _onDisposeObserver;
  81975. private _onUnBindObservable;
  81976. /**
  81977. * Called during a dispose event
  81978. */
  81979. onDispose: () => void;
  81980. private _onBindObservable;
  81981. /**
  81982. * An event triggered when the material is bound
  81983. */
  81984. readonly onBindObservable: Observable<AbstractMesh>;
  81985. /**
  81986. * An observer which watches for bind events
  81987. */
  81988. private _onBindObserver;
  81989. /**
  81990. * Called during a bind event
  81991. */
  81992. onBind: (Mesh: AbstractMesh) => void;
  81993. /**
  81994. * An event triggered when the material is unbound
  81995. */
  81996. readonly onUnBindObservable: Observable<Material>;
  81997. /**
  81998. * Stores the value of the alpha mode
  81999. */
  82000. private _alphaMode;
  82001. /**
  82002. * Sets the value of the alpha mode.
  82003. *
  82004. * | Value | Type | Description |
  82005. * | --- | --- | --- |
  82006. * | 0 | ALPHA_DISABLE | |
  82007. * | 1 | ALPHA_ADD | |
  82008. * | 2 | ALPHA_COMBINE | |
  82009. * | 3 | ALPHA_SUBTRACT | |
  82010. * | 4 | ALPHA_MULTIPLY | |
  82011. * | 5 | ALPHA_MAXIMIZED | |
  82012. * | 6 | ALPHA_ONEONE | |
  82013. * | 7 | ALPHA_PREMULTIPLIED | |
  82014. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82015. * | 9 | ALPHA_INTERPOLATE | |
  82016. * | 10 | ALPHA_SCREENMODE | |
  82017. *
  82018. */
  82019. /**
  82020. * Gets the value of the alpha mode
  82021. */
  82022. alphaMode: number;
  82023. /**
  82024. * Stores the state of the need depth pre-pass value
  82025. */
  82026. private _needDepthPrePass;
  82027. /**
  82028. * Sets the need depth pre-pass value
  82029. */
  82030. /**
  82031. * Gets the depth pre-pass value
  82032. */
  82033. needDepthPrePass: boolean;
  82034. /**
  82035. * Specifies if depth writing should be disabled
  82036. */
  82037. disableDepthWrite: boolean;
  82038. /**
  82039. * Specifies if depth writing should be forced
  82040. */
  82041. forceDepthWrite: boolean;
  82042. /**
  82043. * Specifies if there should be a separate pass for culling
  82044. */
  82045. separateCullingPass: boolean;
  82046. /**
  82047. * Stores the state specifing if fog should be enabled
  82048. */
  82049. private _fogEnabled;
  82050. /**
  82051. * Sets the state for enabling fog
  82052. */
  82053. /**
  82054. * Gets the value of the fog enabled state
  82055. */
  82056. fogEnabled: boolean;
  82057. /**
  82058. * Stores the size of points
  82059. */
  82060. pointSize: number;
  82061. /**
  82062. * Stores the z offset value
  82063. */
  82064. zOffset: number;
  82065. /**
  82066. * Gets a value specifying if wireframe mode is enabled
  82067. */
  82068. /**
  82069. * Sets the state of wireframe mode
  82070. */
  82071. wireframe: boolean;
  82072. /**
  82073. * Gets the value specifying if point clouds are enabled
  82074. */
  82075. /**
  82076. * Sets the state of point cloud mode
  82077. */
  82078. pointsCloud: boolean;
  82079. /**
  82080. * Gets the material fill mode
  82081. */
  82082. /**
  82083. * Sets the material fill mode
  82084. */
  82085. fillMode: number;
  82086. /**
  82087. * @hidden
  82088. * Stores the effects for the material
  82089. */
  82090. _effect: Nullable<Effect>;
  82091. /**
  82092. * @hidden
  82093. * Specifies if the material was previously ready
  82094. */
  82095. _wasPreviouslyReady: boolean;
  82096. /**
  82097. * Specifies if uniform buffers should be used
  82098. */
  82099. private _useUBO;
  82100. /**
  82101. * Stores a reference to the scene
  82102. */
  82103. private _scene;
  82104. /**
  82105. * Stores the fill mode state
  82106. */
  82107. private _fillMode;
  82108. /**
  82109. * Specifies if the depth write state should be cached
  82110. */
  82111. private _cachedDepthWriteState;
  82112. /**
  82113. * Stores the uniform buffer
  82114. */
  82115. protected _uniformBuffer: UniformBuffer;
  82116. /** @hidden */
  82117. _indexInSceneMaterialArray: number;
  82118. /** @hidden */
  82119. meshMap: Nullable<{
  82120. [id: string]: AbstractMesh | undefined;
  82121. }>;
  82122. /**
  82123. * Creates a material instance
  82124. * @param name defines the name of the material
  82125. * @param scene defines the scene to reference
  82126. * @param doNotAdd specifies if the material should be added to the scene
  82127. */
  82128. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82129. /**
  82130. * Returns a string representation of the current material
  82131. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82132. * @returns a string with material information
  82133. */
  82134. toString(fullDetails?: boolean): string;
  82135. /**
  82136. * Gets the class name of the material
  82137. * @returns a string with the class name of the material
  82138. */
  82139. getClassName(): string;
  82140. /**
  82141. * Specifies if updates for the material been locked
  82142. */
  82143. readonly isFrozen: boolean;
  82144. /**
  82145. * Locks updates for the material
  82146. */
  82147. freeze(): void;
  82148. /**
  82149. * Unlocks updates for the material
  82150. */
  82151. unfreeze(): void;
  82152. /**
  82153. * Specifies if the material is ready to be used
  82154. * @param mesh defines the mesh to check
  82155. * @param useInstances specifies if instances should be used
  82156. * @returns a boolean indicating if the material is ready to be used
  82157. */
  82158. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82159. /**
  82160. * Specifies that the submesh is ready to be used
  82161. * @param mesh defines the mesh to check
  82162. * @param subMesh defines which submesh to check
  82163. * @param useInstances specifies that instances should be used
  82164. * @returns a boolean indicating that the submesh is ready or not
  82165. */
  82166. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82167. /**
  82168. * Returns the material effect
  82169. * @returns the effect associated with the material
  82170. */
  82171. getEffect(): Nullable<Effect>;
  82172. /**
  82173. * Returns the current scene
  82174. * @returns a Scene
  82175. */
  82176. getScene(): Scene;
  82177. /**
  82178. * Specifies if the material will require alpha blending
  82179. * @returns a boolean specifying if alpha blending is needed
  82180. */
  82181. needAlphaBlending(): boolean;
  82182. /**
  82183. * Specifies if the mesh will require alpha blending
  82184. * @param mesh defines the mesh to check
  82185. * @returns a boolean specifying if alpha blending is needed for the mesh
  82186. */
  82187. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82188. /**
  82189. * Specifies if this material should be rendered in alpha test mode
  82190. * @returns a boolean specifying if an alpha test is needed.
  82191. */
  82192. needAlphaTesting(): boolean;
  82193. /**
  82194. * Gets the texture used for the alpha test
  82195. * @returns the texture to use for alpha testing
  82196. */
  82197. getAlphaTestTexture(): Nullable<BaseTexture>;
  82198. /**
  82199. * Marks the material to indicate that it needs to be re-calculated
  82200. */
  82201. markDirty(): void;
  82202. /** @hidden */
  82203. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82204. /**
  82205. * Binds the material to the mesh
  82206. * @param world defines the world transformation matrix
  82207. * @param mesh defines the mesh to bind the material to
  82208. */
  82209. bind(world: Matrix, mesh?: Mesh): void;
  82210. /**
  82211. * Binds the submesh to the material
  82212. * @param world defines the world transformation matrix
  82213. * @param mesh defines the mesh containing the submesh
  82214. * @param subMesh defines the submesh to bind the material to
  82215. */
  82216. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82217. /**
  82218. * Binds the world matrix to the material
  82219. * @param world defines the world transformation matrix
  82220. */
  82221. bindOnlyWorldMatrix(world: Matrix): void;
  82222. /**
  82223. * Binds the scene's uniform buffer to the effect.
  82224. * @param effect defines the effect to bind to the scene uniform buffer
  82225. * @param sceneUbo defines the uniform buffer storing scene data
  82226. */
  82227. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82228. /**
  82229. * Binds the view matrix to the effect
  82230. * @param effect defines the effect to bind the view matrix to
  82231. */
  82232. bindView(effect: Effect): void;
  82233. /**
  82234. * Binds the view projection matrix to the effect
  82235. * @param effect defines the effect to bind the view projection matrix to
  82236. */
  82237. bindViewProjection(effect: Effect): void;
  82238. /**
  82239. * Specifies if material alpha testing should be turned on for the mesh
  82240. * @param mesh defines the mesh to check
  82241. */
  82242. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82243. /**
  82244. * Processes to execute after binding the material to a mesh
  82245. * @param mesh defines the rendered mesh
  82246. */
  82247. protected _afterBind(mesh?: Mesh): void;
  82248. /**
  82249. * Unbinds the material from the mesh
  82250. */
  82251. unbind(): void;
  82252. /**
  82253. * Gets the active textures from the material
  82254. * @returns an array of textures
  82255. */
  82256. getActiveTextures(): BaseTexture[];
  82257. /**
  82258. * Specifies if the material uses a texture
  82259. * @param texture defines the texture to check against the material
  82260. * @returns a boolean specifying if the material uses the texture
  82261. */
  82262. hasTexture(texture: BaseTexture): boolean;
  82263. /**
  82264. * Makes a duplicate of the material, and gives it a new name
  82265. * @param name defines the new name for the duplicated material
  82266. * @returns the cloned material
  82267. */
  82268. clone(name: string): Nullable<Material>;
  82269. /**
  82270. * Gets the meshes bound to the material
  82271. * @returns an array of meshes bound to the material
  82272. */
  82273. getBindedMeshes(): AbstractMesh[];
  82274. /**
  82275. * Force shader compilation
  82276. * @param mesh defines the mesh associated with this material
  82277. * @param onCompiled defines a function to execute once the material is compiled
  82278. * @param options defines the options to configure the compilation
  82279. */
  82280. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82281. clipPlane: boolean;
  82282. }>): void;
  82283. /**
  82284. * Force shader compilation
  82285. * @param mesh defines the mesh that will use this material
  82286. * @param options defines additional options for compiling the shaders
  82287. * @returns a promise that resolves when the compilation completes
  82288. */
  82289. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82290. clipPlane: boolean;
  82291. }>): Promise<void>;
  82292. private static readonly _ImageProcessingDirtyCallBack;
  82293. private static readonly _TextureDirtyCallBack;
  82294. private static readonly _FresnelDirtyCallBack;
  82295. private static readonly _MiscDirtyCallBack;
  82296. private static readonly _LightsDirtyCallBack;
  82297. private static readonly _AttributeDirtyCallBack;
  82298. private static _FresnelAndMiscDirtyCallBack;
  82299. private static _TextureAndMiscDirtyCallBack;
  82300. private static readonly _DirtyCallbackArray;
  82301. private static readonly _RunDirtyCallBacks;
  82302. /**
  82303. * Marks a define in the material to indicate that it needs to be re-computed
  82304. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82305. */
  82306. markAsDirty(flag: number): void;
  82307. /**
  82308. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82309. * @param func defines a function which checks material defines against the submeshes
  82310. */
  82311. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82312. /**
  82313. * Indicates that image processing needs to be re-calculated for all submeshes
  82314. */
  82315. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82316. /**
  82317. * Indicates that textures need to be re-calculated for all submeshes
  82318. */
  82319. protected _markAllSubMeshesAsTexturesDirty(): void;
  82320. /**
  82321. * Indicates that fresnel needs to be re-calculated for all submeshes
  82322. */
  82323. protected _markAllSubMeshesAsFresnelDirty(): void;
  82324. /**
  82325. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82326. */
  82327. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82328. /**
  82329. * Indicates that lights need to be re-calculated for all submeshes
  82330. */
  82331. protected _markAllSubMeshesAsLightsDirty(): void;
  82332. /**
  82333. * Indicates that attributes need to be re-calculated for all submeshes
  82334. */
  82335. protected _markAllSubMeshesAsAttributesDirty(): void;
  82336. /**
  82337. * Indicates that misc needs to be re-calculated for all submeshes
  82338. */
  82339. protected _markAllSubMeshesAsMiscDirty(): void;
  82340. /**
  82341. * Indicates that textures and misc need to be re-calculated for all submeshes
  82342. */
  82343. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82344. /**
  82345. * Disposes the material
  82346. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82347. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82348. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82349. */
  82350. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82351. /** @hidden */
  82352. private releaseVertexArrayObject;
  82353. /**
  82354. * Serializes this material
  82355. * @returns the serialized material object
  82356. */
  82357. serialize(): any;
  82358. /**
  82359. * Creates a material from parsed material data
  82360. * @param parsedMaterial defines parsed material data
  82361. * @param scene defines the hosting scene
  82362. * @param rootUrl defines the root URL to use to load textures
  82363. * @returns a new material
  82364. */
  82365. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82366. }
  82367. }
  82368. declare module BABYLON {
  82369. /**
  82370. * Base class for submeshes
  82371. */
  82372. export class BaseSubMesh {
  82373. /** @hidden */
  82374. _materialDefines: Nullable<MaterialDefines>;
  82375. /** @hidden */
  82376. _materialEffect: Nullable<Effect>;
  82377. /**
  82378. * Gets associated effect
  82379. */
  82380. readonly effect: Nullable<Effect>;
  82381. /**
  82382. * Sets associated effect (effect used to render this submesh)
  82383. * @param effect defines the effect to associate with
  82384. * @param defines defines the set of defines used to compile this effect
  82385. */
  82386. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82387. }
  82388. /**
  82389. * Defines a subdivision inside a mesh
  82390. */
  82391. export class SubMesh extends BaseSubMesh implements ICullable {
  82392. /** the material index to use */
  82393. materialIndex: number;
  82394. /** vertex index start */
  82395. verticesStart: number;
  82396. /** vertices count */
  82397. verticesCount: number;
  82398. /** index start */
  82399. indexStart: number;
  82400. /** indices count */
  82401. indexCount: number;
  82402. /** @hidden */
  82403. _linesIndexCount: number;
  82404. private _mesh;
  82405. private _renderingMesh;
  82406. private _boundingInfo;
  82407. private _linesIndexBuffer;
  82408. /** @hidden */
  82409. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82410. /** @hidden */
  82411. _trianglePlanes: Plane[];
  82412. /** @hidden */
  82413. _lastColliderTransformMatrix: Nullable<Matrix>;
  82414. /** @hidden */
  82415. _renderId: number;
  82416. /** @hidden */
  82417. _alphaIndex: number;
  82418. /** @hidden */
  82419. _distanceToCamera: number;
  82420. /** @hidden */
  82421. _id: number;
  82422. private _currentMaterial;
  82423. /**
  82424. * Add a new submesh to a mesh
  82425. * @param materialIndex defines the material index to use
  82426. * @param verticesStart defines vertex index start
  82427. * @param verticesCount defines vertices count
  82428. * @param indexStart defines index start
  82429. * @param indexCount defines indices count
  82430. * @param mesh defines the parent mesh
  82431. * @param renderingMesh defines an optional rendering mesh
  82432. * @param createBoundingBox defines if bounding box should be created for this submesh
  82433. * @returns the new submesh
  82434. */
  82435. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82436. /**
  82437. * Creates a new submesh
  82438. * @param materialIndex defines the material index to use
  82439. * @param verticesStart defines vertex index start
  82440. * @param verticesCount defines vertices count
  82441. * @param indexStart defines index start
  82442. * @param indexCount defines indices count
  82443. * @param mesh defines the parent mesh
  82444. * @param renderingMesh defines an optional rendering mesh
  82445. * @param createBoundingBox defines if bounding box should be created for this submesh
  82446. */
  82447. constructor(
  82448. /** the material index to use */
  82449. materialIndex: number,
  82450. /** vertex index start */
  82451. verticesStart: number,
  82452. /** vertices count */
  82453. verticesCount: number,
  82454. /** index start */
  82455. indexStart: number,
  82456. /** indices count */
  82457. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82458. /**
  82459. * Returns true if this submesh covers the entire parent mesh
  82460. * @ignorenaming
  82461. */
  82462. readonly IsGlobal: boolean;
  82463. /**
  82464. * Returns the submesh BoudingInfo object
  82465. * @returns current bounding info (or mesh's one if the submesh is global)
  82466. */
  82467. getBoundingInfo(): BoundingInfo;
  82468. /**
  82469. * Sets the submesh BoundingInfo
  82470. * @param boundingInfo defines the new bounding info to use
  82471. * @returns the SubMesh
  82472. */
  82473. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82474. /**
  82475. * Returns the mesh of the current submesh
  82476. * @return the parent mesh
  82477. */
  82478. getMesh(): AbstractMesh;
  82479. /**
  82480. * Returns the rendering mesh of the submesh
  82481. * @returns the rendering mesh (could be different from parent mesh)
  82482. */
  82483. getRenderingMesh(): Mesh;
  82484. /**
  82485. * Returns the submesh material
  82486. * @returns null or the current material
  82487. */
  82488. getMaterial(): Nullable<Material>;
  82489. /**
  82490. * Sets a new updated BoundingInfo object to the submesh
  82491. * @param data defines an optional position array to use to determine the bounding info
  82492. * @returns the SubMesh
  82493. */
  82494. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82495. /** @hidden */
  82496. _checkCollision(collider: Collider): boolean;
  82497. /**
  82498. * Updates the submesh BoundingInfo
  82499. * @param world defines the world matrix to use to update the bounding info
  82500. * @returns the submesh
  82501. */
  82502. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82503. /**
  82504. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82505. * @param frustumPlanes defines the frustum planes
  82506. * @returns true if the submesh is intersecting with the frustum
  82507. */
  82508. isInFrustum(frustumPlanes: Plane[]): boolean;
  82509. /**
  82510. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82511. * @param frustumPlanes defines the frustum planes
  82512. * @returns true if the submesh is inside the frustum
  82513. */
  82514. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82515. /**
  82516. * Renders the submesh
  82517. * @param enableAlphaMode defines if alpha needs to be used
  82518. * @returns the submesh
  82519. */
  82520. render(enableAlphaMode: boolean): SubMesh;
  82521. /**
  82522. * @hidden
  82523. */
  82524. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82525. /**
  82526. * Checks if the submesh intersects with a ray
  82527. * @param ray defines the ray to test
  82528. * @returns true is the passed ray intersects the submesh bounding box
  82529. */
  82530. canIntersects(ray: Ray): boolean;
  82531. /**
  82532. * Intersects current submesh with a ray
  82533. * @param ray defines the ray to test
  82534. * @param positions defines mesh's positions array
  82535. * @param indices defines mesh's indices array
  82536. * @param fastCheck defines if only bounding info should be used
  82537. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82538. * @returns intersection info or null if no intersection
  82539. */
  82540. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82541. /** @hidden */
  82542. private _intersectLines;
  82543. /** @hidden */
  82544. private _intersectTriangles;
  82545. /** @hidden */
  82546. _rebuild(): void;
  82547. /**
  82548. * Creates a new submesh from the passed mesh
  82549. * @param newMesh defines the new hosting mesh
  82550. * @param newRenderingMesh defines an optional rendering mesh
  82551. * @returns the new submesh
  82552. */
  82553. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82554. /**
  82555. * Release associated resources
  82556. */
  82557. dispose(): void;
  82558. /**
  82559. * Gets the class name
  82560. * @returns the string "SubMesh".
  82561. */
  82562. getClassName(): string;
  82563. /**
  82564. * Creates a new submesh from indices data
  82565. * @param materialIndex the index of the main mesh material
  82566. * @param startIndex the index where to start the copy in the mesh indices array
  82567. * @param indexCount the number of indices to copy then from the startIndex
  82568. * @param mesh the main mesh to create the submesh from
  82569. * @param renderingMesh the optional rendering mesh
  82570. * @returns a new submesh
  82571. */
  82572. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82573. }
  82574. }
  82575. declare module BABYLON {
  82576. /**
  82577. * Class used to store geometry data (vertex buffers + index buffer)
  82578. */
  82579. export class Geometry implements IGetSetVerticesData {
  82580. /**
  82581. * Gets or sets the ID of the geometry
  82582. */
  82583. id: string;
  82584. /**
  82585. * Gets or sets the unique ID of the geometry
  82586. */
  82587. uniqueId: number;
  82588. /**
  82589. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82590. */
  82591. delayLoadState: number;
  82592. /**
  82593. * Gets the file containing the data to load when running in delay load state
  82594. */
  82595. delayLoadingFile: Nullable<string>;
  82596. /**
  82597. * Callback called when the geometry is updated
  82598. */
  82599. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82600. private _scene;
  82601. private _engine;
  82602. private _meshes;
  82603. private _totalVertices;
  82604. /** @hidden */
  82605. _indices: IndicesArray;
  82606. /** @hidden */
  82607. _vertexBuffers: {
  82608. [key: string]: VertexBuffer;
  82609. };
  82610. private _isDisposed;
  82611. private _extend;
  82612. private _boundingBias;
  82613. /** @hidden */
  82614. _delayInfo: Array<string>;
  82615. private _indexBuffer;
  82616. private _indexBufferIsUpdatable;
  82617. /** @hidden */
  82618. _boundingInfo: Nullable<BoundingInfo>;
  82619. /** @hidden */
  82620. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82621. /** @hidden */
  82622. _softwareSkinningFrameId: number;
  82623. private _vertexArrayObjects;
  82624. private _updatable;
  82625. /** @hidden */
  82626. _positions: Nullable<Vector3[]>;
  82627. /**
  82628. * 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
  82629. */
  82630. /**
  82631. * 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
  82632. */
  82633. boundingBias: Vector2;
  82634. /**
  82635. * Static function used to attach a new empty geometry to a mesh
  82636. * @param mesh defines the mesh to attach the geometry to
  82637. * @returns the new Geometry
  82638. */
  82639. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82640. /**
  82641. * Creates a new geometry
  82642. * @param id defines the unique ID
  82643. * @param scene defines the hosting scene
  82644. * @param vertexData defines the VertexData used to get geometry data
  82645. * @param updatable defines if geometry must be updatable (false by default)
  82646. * @param mesh defines the mesh that will be associated with the geometry
  82647. */
  82648. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82649. /**
  82650. * Gets the current extend of the geometry
  82651. */
  82652. readonly extend: {
  82653. minimum: Vector3;
  82654. maximum: Vector3;
  82655. };
  82656. /**
  82657. * Gets the hosting scene
  82658. * @returns the hosting Scene
  82659. */
  82660. getScene(): Scene;
  82661. /**
  82662. * Gets the hosting engine
  82663. * @returns the hosting Engine
  82664. */
  82665. getEngine(): Engine;
  82666. /**
  82667. * Defines if the geometry is ready to use
  82668. * @returns true if the geometry is ready to be used
  82669. */
  82670. isReady(): boolean;
  82671. /**
  82672. * Gets a value indicating that the geometry should not be serialized
  82673. */
  82674. readonly doNotSerialize: boolean;
  82675. /** @hidden */
  82676. _rebuild(): void;
  82677. /**
  82678. * Affects all geometry data in one call
  82679. * @param vertexData defines the geometry data
  82680. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82681. */
  82682. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82683. /**
  82684. * Set specific vertex data
  82685. * @param kind defines the data kind (Position, normal, etc...)
  82686. * @param data defines the vertex data to use
  82687. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82688. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82689. */
  82690. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82691. /**
  82692. * Removes a specific vertex data
  82693. * @param kind defines the data kind (Position, normal, etc...)
  82694. */
  82695. removeVerticesData(kind: string): void;
  82696. /**
  82697. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82698. * @param buffer defines the vertex buffer to use
  82699. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82700. */
  82701. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82702. /**
  82703. * Update a specific vertex buffer
  82704. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82705. * It will do nothing if the buffer is not updatable
  82706. * @param kind defines the data kind (Position, normal, etc...)
  82707. * @param data defines the data to use
  82708. * @param offset defines the offset in the target buffer where to store the data
  82709. * @param useBytes set to true if the offset is in bytes
  82710. */
  82711. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82712. /**
  82713. * Update a specific vertex buffer
  82714. * This function will create a new buffer if the current one is not updatable
  82715. * @param kind defines the data kind (Position, normal, etc...)
  82716. * @param data defines the data to use
  82717. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82718. */
  82719. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82720. private _updateBoundingInfo;
  82721. /** @hidden */
  82722. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82723. /**
  82724. * Gets total number of vertices
  82725. * @returns the total number of vertices
  82726. */
  82727. getTotalVertices(): number;
  82728. /**
  82729. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82730. * @param kind defines the data kind (Position, normal, etc...)
  82731. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82732. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82733. * @returns a float array containing vertex data
  82734. */
  82735. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82736. /**
  82737. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82738. * @param kind defines the data kind (Position, normal, etc...)
  82739. * @returns true if the vertex buffer with the specified kind is updatable
  82740. */
  82741. isVertexBufferUpdatable(kind: string): boolean;
  82742. /**
  82743. * Gets a specific vertex buffer
  82744. * @param kind defines the data kind (Position, normal, etc...)
  82745. * @returns a VertexBuffer
  82746. */
  82747. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82748. /**
  82749. * Returns all vertex buffers
  82750. * @return an object holding all vertex buffers indexed by kind
  82751. */
  82752. getVertexBuffers(): Nullable<{
  82753. [key: string]: VertexBuffer;
  82754. }>;
  82755. /**
  82756. * Gets a boolean indicating if specific vertex buffer is present
  82757. * @param kind defines the data kind (Position, normal, etc...)
  82758. * @returns true if data is present
  82759. */
  82760. isVerticesDataPresent(kind: string): boolean;
  82761. /**
  82762. * Gets a list of all attached data kinds (Position, normal, etc...)
  82763. * @returns a list of string containing all kinds
  82764. */
  82765. getVerticesDataKinds(): string[];
  82766. /**
  82767. * Update index buffer
  82768. * @param indices defines the indices to store in the index buffer
  82769. * @param offset defines the offset in the target buffer where to store the data
  82770. * @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)
  82771. */
  82772. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82773. /**
  82774. * Creates a new index buffer
  82775. * @param indices defines the indices to store in the index buffer
  82776. * @param totalVertices defines the total number of vertices (could be null)
  82777. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82778. */
  82779. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82780. /**
  82781. * Return the total number of indices
  82782. * @returns the total number of indices
  82783. */
  82784. getTotalIndices(): number;
  82785. /**
  82786. * Gets the index buffer array
  82787. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82788. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82789. * @returns the index buffer array
  82790. */
  82791. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82792. /**
  82793. * Gets the index buffer
  82794. * @return the index buffer
  82795. */
  82796. getIndexBuffer(): Nullable<DataBuffer>;
  82797. /** @hidden */
  82798. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82799. /**
  82800. * Release the associated resources for a specific mesh
  82801. * @param mesh defines the source mesh
  82802. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82803. */
  82804. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82805. /**
  82806. * Apply current geometry to a given mesh
  82807. * @param mesh defines the mesh to apply geometry to
  82808. */
  82809. applyToMesh(mesh: Mesh): void;
  82810. private _updateExtend;
  82811. private _applyToMesh;
  82812. private notifyUpdate;
  82813. /**
  82814. * Load the geometry if it was flagged as delay loaded
  82815. * @param scene defines the hosting scene
  82816. * @param onLoaded defines a callback called when the geometry is loaded
  82817. */
  82818. load(scene: Scene, onLoaded?: () => void): void;
  82819. private _queueLoad;
  82820. /**
  82821. * Invert the geometry to move from a right handed system to a left handed one.
  82822. */
  82823. toLeftHanded(): void;
  82824. /** @hidden */
  82825. _resetPointsArrayCache(): void;
  82826. /** @hidden */
  82827. _generatePointsArray(): boolean;
  82828. /**
  82829. * Gets a value indicating if the geometry is disposed
  82830. * @returns true if the geometry was disposed
  82831. */
  82832. isDisposed(): boolean;
  82833. private _disposeVertexArrayObjects;
  82834. /**
  82835. * Free all associated resources
  82836. */
  82837. dispose(): void;
  82838. /**
  82839. * Clone the current geometry into a new geometry
  82840. * @param id defines the unique ID of the new geometry
  82841. * @returns a new geometry object
  82842. */
  82843. copy(id: string): Geometry;
  82844. /**
  82845. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82846. * @return a JSON representation of the current geometry data (without the vertices data)
  82847. */
  82848. serialize(): any;
  82849. private toNumberArray;
  82850. /**
  82851. * Serialize all vertices data into a JSON oject
  82852. * @returns a JSON representation of the current geometry data
  82853. */
  82854. serializeVerticeData(): any;
  82855. /**
  82856. * Extracts a clone of a mesh geometry
  82857. * @param mesh defines the source mesh
  82858. * @param id defines the unique ID of the new geometry object
  82859. * @returns the new geometry object
  82860. */
  82861. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82862. /**
  82863. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82864. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82865. * Be aware Math.random() could cause collisions, but:
  82866. * "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"
  82867. * @returns a string containing a new GUID
  82868. */
  82869. static RandomId(): string;
  82870. /** @hidden */
  82871. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82872. private static _CleanMatricesWeights;
  82873. /**
  82874. * Create a new geometry from persisted data (Using .babylon file format)
  82875. * @param parsedVertexData defines the persisted data
  82876. * @param scene defines the hosting scene
  82877. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82878. * @returns the new geometry object
  82879. */
  82880. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82881. }
  82882. }
  82883. declare module BABYLON {
  82884. /**
  82885. * Define an interface for all classes that will get and set the data on vertices
  82886. */
  82887. export interface IGetSetVerticesData {
  82888. /**
  82889. * Gets a boolean indicating if specific vertex data is present
  82890. * @param kind defines the vertex data kind to use
  82891. * @returns true is data kind is present
  82892. */
  82893. isVerticesDataPresent(kind: string): boolean;
  82894. /**
  82895. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82896. * @param kind defines the data kind (Position, normal, etc...)
  82897. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82898. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82899. * @returns a float array containing vertex data
  82900. */
  82901. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82902. /**
  82903. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82904. * @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.
  82905. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82906. * @returns the indices array or an empty array if the mesh has no geometry
  82907. */
  82908. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82909. /**
  82910. * Set specific vertex data
  82911. * @param kind defines the data kind (Position, normal, etc...)
  82912. * @param data defines the vertex data to use
  82913. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82914. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82915. */
  82916. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82917. /**
  82918. * Update a specific associated vertex buffer
  82919. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82920. * - VertexBuffer.PositionKind
  82921. * - VertexBuffer.UVKind
  82922. * - VertexBuffer.UV2Kind
  82923. * - VertexBuffer.UV3Kind
  82924. * - VertexBuffer.UV4Kind
  82925. * - VertexBuffer.UV5Kind
  82926. * - VertexBuffer.UV6Kind
  82927. * - VertexBuffer.ColorKind
  82928. * - VertexBuffer.MatricesIndicesKind
  82929. * - VertexBuffer.MatricesIndicesExtraKind
  82930. * - VertexBuffer.MatricesWeightsKind
  82931. * - VertexBuffer.MatricesWeightsExtraKind
  82932. * @param data defines the data source
  82933. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82934. * @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)
  82935. */
  82936. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82937. /**
  82938. * Creates a new index buffer
  82939. * @param indices defines the indices to store in the index buffer
  82940. * @param totalVertices defines the total number of vertices (could be null)
  82941. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82942. */
  82943. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82944. }
  82945. /**
  82946. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82947. */
  82948. export class VertexData {
  82949. /**
  82950. * Mesh side orientation : usually the external or front surface
  82951. */
  82952. static readonly FRONTSIDE: number;
  82953. /**
  82954. * Mesh side orientation : usually the internal or back surface
  82955. */
  82956. static readonly BACKSIDE: number;
  82957. /**
  82958. * Mesh side orientation : both internal and external or front and back surfaces
  82959. */
  82960. static readonly DOUBLESIDE: number;
  82961. /**
  82962. * Mesh side orientation : by default, `FRONTSIDE`
  82963. */
  82964. static readonly DEFAULTSIDE: number;
  82965. /**
  82966. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82967. */
  82968. positions: Nullable<FloatArray>;
  82969. /**
  82970. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82971. */
  82972. normals: Nullable<FloatArray>;
  82973. /**
  82974. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82975. */
  82976. tangents: Nullable<FloatArray>;
  82977. /**
  82978. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82979. */
  82980. uvs: Nullable<FloatArray>;
  82981. /**
  82982. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82983. */
  82984. uvs2: Nullable<FloatArray>;
  82985. /**
  82986. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82987. */
  82988. uvs3: Nullable<FloatArray>;
  82989. /**
  82990. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82991. */
  82992. uvs4: Nullable<FloatArray>;
  82993. /**
  82994. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82995. */
  82996. uvs5: Nullable<FloatArray>;
  82997. /**
  82998. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82999. */
  83000. uvs6: Nullable<FloatArray>;
  83001. /**
  83002. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83003. */
  83004. colors: Nullable<FloatArray>;
  83005. /**
  83006. * 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).
  83007. */
  83008. matricesIndices: Nullable<FloatArray>;
  83009. /**
  83010. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83011. */
  83012. matricesWeights: Nullable<FloatArray>;
  83013. /**
  83014. * An array extending the number of possible indices
  83015. */
  83016. matricesIndicesExtra: Nullable<FloatArray>;
  83017. /**
  83018. * An array extending the number of possible weights when the number of indices is extended
  83019. */
  83020. matricesWeightsExtra: Nullable<FloatArray>;
  83021. /**
  83022. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83023. */
  83024. indices: Nullable<IndicesArray>;
  83025. /**
  83026. * Uses the passed data array to set the set the values for the specified kind of data
  83027. * @param data a linear array of floating numbers
  83028. * @param kind the type of data that is being set, eg positions, colors etc
  83029. */
  83030. set(data: FloatArray, kind: string): void;
  83031. /**
  83032. * Associates the vertexData to the passed Mesh.
  83033. * Sets it as updatable or not (default `false`)
  83034. * @param mesh the mesh the vertexData is applied to
  83035. * @param updatable when used and having the value true allows new data to update the vertexData
  83036. * @returns the VertexData
  83037. */
  83038. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83039. /**
  83040. * Associates the vertexData to the passed Geometry.
  83041. * Sets it as updatable or not (default `false`)
  83042. * @param geometry the geometry the vertexData is applied to
  83043. * @param updatable when used and having the value true allows new data to update the vertexData
  83044. * @returns VertexData
  83045. */
  83046. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83047. /**
  83048. * Updates the associated mesh
  83049. * @param mesh the mesh to be updated
  83050. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83051. * @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
  83052. * @returns VertexData
  83053. */
  83054. updateMesh(mesh: Mesh): VertexData;
  83055. /**
  83056. * Updates the associated geometry
  83057. * @param geometry the geometry to be updated
  83058. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83059. * @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
  83060. * @returns VertexData.
  83061. */
  83062. updateGeometry(geometry: Geometry): VertexData;
  83063. private _applyTo;
  83064. private _update;
  83065. /**
  83066. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83067. * @param matrix the transforming matrix
  83068. * @returns the VertexData
  83069. */
  83070. transform(matrix: Matrix): VertexData;
  83071. /**
  83072. * Merges the passed VertexData into the current one
  83073. * @param other the VertexData to be merged into the current one
  83074. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83075. * @returns the modified VertexData
  83076. */
  83077. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83078. private _mergeElement;
  83079. private _validate;
  83080. /**
  83081. * Serializes the VertexData
  83082. * @returns a serialized object
  83083. */
  83084. serialize(): any;
  83085. /**
  83086. * Extracts the vertexData from a mesh
  83087. * @param mesh the mesh from which to extract the VertexData
  83088. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83089. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83090. * @returns the object VertexData associated to the passed mesh
  83091. */
  83092. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83093. /**
  83094. * Extracts the vertexData from the geometry
  83095. * @param geometry the geometry from which to extract the VertexData
  83096. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83097. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83098. * @returns the object VertexData associated to the passed mesh
  83099. */
  83100. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83101. private static _ExtractFrom;
  83102. /**
  83103. * Creates the VertexData for a Ribbon
  83104. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83105. * * pathArray array of paths, each of which an array of successive Vector3
  83106. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83107. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83108. * * 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
  83109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83110. * * 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)
  83111. * * 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)
  83112. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83113. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83114. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83115. * @returns the VertexData of the ribbon
  83116. */
  83117. static CreateRibbon(options: {
  83118. pathArray: Vector3[][];
  83119. closeArray?: boolean;
  83120. closePath?: boolean;
  83121. offset?: number;
  83122. sideOrientation?: number;
  83123. frontUVs?: Vector4;
  83124. backUVs?: Vector4;
  83125. invertUV?: boolean;
  83126. uvs?: Vector2[];
  83127. colors?: Color4[];
  83128. }): VertexData;
  83129. /**
  83130. * Creates the VertexData for a box
  83131. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83132. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83133. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83134. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83135. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83136. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83137. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83139. * * 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)
  83140. * * 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)
  83141. * @returns the VertexData of the box
  83142. */
  83143. static CreateBox(options: {
  83144. size?: number;
  83145. width?: number;
  83146. height?: number;
  83147. depth?: number;
  83148. faceUV?: Vector4[];
  83149. faceColors?: Color4[];
  83150. sideOrientation?: number;
  83151. frontUVs?: Vector4;
  83152. backUVs?: Vector4;
  83153. }): VertexData;
  83154. /**
  83155. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83156. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83157. * * segments sets the number of horizontal strips optional, default 32
  83158. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83159. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83160. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83161. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83162. * * 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
  83163. * * 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
  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. * @returns the VertexData of the ellipsoid
  83168. */
  83169. static CreateSphere(options: {
  83170. segments?: number;
  83171. diameter?: number;
  83172. diameterX?: number;
  83173. diameterY?: number;
  83174. diameterZ?: number;
  83175. arc?: number;
  83176. slice?: number;
  83177. sideOrientation?: number;
  83178. frontUVs?: Vector4;
  83179. backUVs?: Vector4;
  83180. }): VertexData;
  83181. /**
  83182. * Creates the VertexData for a cylinder, cone or prism
  83183. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83184. * * height sets the height (y direction) of the cylinder, optional, default 2
  83185. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83186. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83187. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83188. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83189. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83190. * * 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
  83191. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83192. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83193. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83194. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83196. * * 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)
  83197. * * 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)
  83198. * @returns the VertexData of the cylinder, cone or prism
  83199. */
  83200. static CreateCylinder(options: {
  83201. height?: number;
  83202. diameterTop?: number;
  83203. diameterBottom?: number;
  83204. diameter?: number;
  83205. tessellation?: number;
  83206. subdivisions?: number;
  83207. arc?: number;
  83208. faceColors?: Color4[];
  83209. faceUV?: Vector4[];
  83210. hasRings?: boolean;
  83211. enclose?: boolean;
  83212. sideOrientation?: number;
  83213. frontUVs?: Vector4;
  83214. backUVs?: Vector4;
  83215. }): VertexData;
  83216. /**
  83217. * Creates the VertexData for a torus
  83218. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83219. * * diameter the diameter of the torus, optional default 1
  83220. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83221. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83223. * * 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)
  83224. * * 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)
  83225. * @returns the VertexData of the torus
  83226. */
  83227. static CreateTorus(options: {
  83228. diameter?: number;
  83229. thickness?: number;
  83230. tessellation?: number;
  83231. sideOrientation?: number;
  83232. frontUVs?: Vector4;
  83233. backUVs?: Vector4;
  83234. }): VertexData;
  83235. /**
  83236. * Creates the VertexData of the LineSystem
  83237. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83238. * - lines an array of lines, each line being an array of successive Vector3
  83239. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83240. * @returns the VertexData of the LineSystem
  83241. */
  83242. static CreateLineSystem(options: {
  83243. lines: Vector3[][];
  83244. colors?: Nullable<Color4[][]>;
  83245. }): VertexData;
  83246. /**
  83247. * Create the VertexData for a DashedLines
  83248. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83249. * - points an array successive Vector3
  83250. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83251. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83252. * - dashNb the intended total number of dashes, optional, default 200
  83253. * @returns the VertexData for the DashedLines
  83254. */
  83255. static CreateDashedLines(options: {
  83256. points: Vector3[];
  83257. dashSize?: number;
  83258. gapSize?: number;
  83259. dashNb?: number;
  83260. }): VertexData;
  83261. /**
  83262. * Creates the VertexData for a Ground
  83263. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83264. * - width the width (x direction) of the ground, optional, default 1
  83265. * - height the height (z direction) of the ground, optional, default 1
  83266. * - subdivisions the number of subdivisions per side, optional, default 1
  83267. * @returns the VertexData of the Ground
  83268. */
  83269. static CreateGround(options: {
  83270. width?: number;
  83271. height?: number;
  83272. subdivisions?: number;
  83273. subdivisionsX?: number;
  83274. subdivisionsY?: number;
  83275. }): VertexData;
  83276. /**
  83277. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83278. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83279. * * xmin the ground minimum X coordinate, optional, default -1
  83280. * * zmin the ground minimum Z coordinate, optional, default -1
  83281. * * xmax the ground maximum X coordinate, optional, default 1
  83282. * * zmax the ground maximum Z coordinate, optional, default 1
  83283. * * 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}
  83284. * * 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}
  83285. * @returns the VertexData of the TiledGround
  83286. */
  83287. static CreateTiledGround(options: {
  83288. xmin: number;
  83289. zmin: number;
  83290. xmax: number;
  83291. zmax: number;
  83292. subdivisions?: {
  83293. w: number;
  83294. h: number;
  83295. };
  83296. precision?: {
  83297. w: number;
  83298. h: number;
  83299. };
  83300. }): VertexData;
  83301. /**
  83302. * Creates the VertexData of the Ground designed from a heightmap
  83303. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83304. * * width the width (x direction) of the ground
  83305. * * height the height (z direction) of the ground
  83306. * * subdivisions the number of subdivisions per side
  83307. * * minHeight the minimum altitude on the ground, optional, default 0
  83308. * * maxHeight the maximum altitude on the ground, optional default 1
  83309. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83310. * * buffer the array holding the image color data
  83311. * * bufferWidth the width of image
  83312. * * bufferHeight the height of image
  83313. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83314. * @returns the VertexData of the Ground designed from a heightmap
  83315. */
  83316. static CreateGroundFromHeightMap(options: {
  83317. width: number;
  83318. height: number;
  83319. subdivisions: number;
  83320. minHeight: number;
  83321. maxHeight: number;
  83322. colorFilter: Color3;
  83323. buffer: Uint8Array;
  83324. bufferWidth: number;
  83325. bufferHeight: number;
  83326. alphaFilter: number;
  83327. }): VertexData;
  83328. /**
  83329. * Creates the VertexData for a Plane
  83330. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83331. * * size sets the width and height of the plane to the value of size, optional default 1
  83332. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83333. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83335. * * 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)
  83336. * * 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)
  83337. * @returns the VertexData of the box
  83338. */
  83339. static CreatePlane(options: {
  83340. size?: number;
  83341. width?: number;
  83342. height?: number;
  83343. sideOrientation?: number;
  83344. frontUVs?: Vector4;
  83345. backUVs?: Vector4;
  83346. }): VertexData;
  83347. /**
  83348. * Creates the VertexData of the Disc or regular Polygon
  83349. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83350. * * radius the radius of the disc, optional default 0.5
  83351. * * tessellation the number of polygon sides, optional, default 64
  83352. * * 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
  83353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83354. * * 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)
  83355. * * 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)
  83356. * @returns the VertexData of the box
  83357. */
  83358. static CreateDisc(options: {
  83359. radius?: number;
  83360. tessellation?: number;
  83361. arc?: number;
  83362. sideOrientation?: number;
  83363. frontUVs?: Vector4;
  83364. backUVs?: Vector4;
  83365. }): VertexData;
  83366. /**
  83367. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83368. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83369. * @param polygon a mesh built from polygonTriangulation.build()
  83370. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83371. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83372. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83373. * @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)
  83374. * @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)
  83375. * @returns the VertexData of the Polygon
  83376. */
  83377. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83378. /**
  83379. * Creates the VertexData of the IcoSphere
  83380. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83381. * * radius the radius of the IcoSphere, optional default 1
  83382. * * radiusX allows stretching in the x direction, optional, default radius
  83383. * * radiusY allows stretching in the y direction, optional, default radius
  83384. * * radiusZ allows stretching in the z direction, optional, default radius
  83385. * * flat when true creates a flat shaded mesh, optional, default true
  83386. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83388. * * 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)
  83389. * * 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)
  83390. * @returns the VertexData of the IcoSphere
  83391. */
  83392. static CreateIcoSphere(options: {
  83393. radius?: number;
  83394. radiusX?: number;
  83395. radiusY?: number;
  83396. radiusZ?: number;
  83397. flat?: boolean;
  83398. subdivisions?: number;
  83399. sideOrientation?: number;
  83400. frontUVs?: Vector4;
  83401. backUVs?: Vector4;
  83402. }): VertexData;
  83403. /**
  83404. * Creates the VertexData for a Polyhedron
  83405. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83406. * * type provided types are:
  83407. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83408. * * 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)
  83409. * * size the size of the IcoSphere, optional default 1
  83410. * * sizeX allows stretching in the x direction, optional, default size
  83411. * * sizeY allows stretching in the y direction, optional, default size
  83412. * * sizeZ allows stretching in the z direction, optional, default size
  83413. * * 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
  83414. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83415. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83416. * * flat when true creates a flat shaded mesh, optional, default true
  83417. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83419. * * 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)
  83420. * * 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)
  83421. * @returns the VertexData of the Polyhedron
  83422. */
  83423. static CreatePolyhedron(options: {
  83424. type?: number;
  83425. size?: number;
  83426. sizeX?: number;
  83427. sizeY?: number;
  83428. sizeZ?: number;
  83429. custom?: any;
  83430. faceUV?: Vector4[];
  83431. faceColors?: Color4[];
  83432. flat?: boolean;
  83433. sideOrientation?: number;
  83434. frontUVs?: Vector4;
  83435. backUVs?: Vector4;
  83436. }): VertexData;
  83437. /**
  83438. * Creates the VertexData for a TorusKnot
  83439. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83440. * * radius the radius of the torus knot, optional, default 2
  83441. * * tube the thickness of the tube, optional, default 0.5
  83442. * * radialSegments the number of sides on each tube segments, optional, default 32
  83443. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83444. * * p the number of windings around the z axis, optional, default 2
  83445. * * q the number of windings around the x axis, optional, default 3
  83446. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83447. * * 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)
  83448. * * 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)
  83449. * @returns the VertexData of the Torus Knot
  83450. */
  83451. static CreateTorusKnot(options: {
  83452. radius?: number;
  83453. tube?: number;
  83454. radialSegments?: number;
  83455. tubularSegments?: number;
  83456. p?: number;
  83457. q?: number;
  83458. sideOrientation?: number;
  83459. frontUVs?: Vector4;
  83460. backUVs?: Vector4;
  83461. }): VertexData;
  83462. /**
  83463. * Compute normals for given positions and indices
  83464. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83465. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83466. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83467. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83468. * * facetNormals : optional array of facet normals (vector3)
  83469. * * facetPositions : optional array of facet positions (vector3)
  83470. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83471. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83472. * * bInfo : optional bounding info, required for facetPartitioning computation
  83473. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83474. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83475. * * useRightHandedSystem: optional boolean to for right handed system computation
  83476. * * depthSort : optional boolean to enable the facet depth sort computation
  83477. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83478. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83479. */
  83480. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83481. facetNormals?: any;
  83482. facetPositions?: any;
  83483. facetPartitioning?: any;
  83484. ratio?: number;
  83485. bInfo?: any;
  83486. bbSize?: Vector3;
  83487. subDiv?: any;
  83488. useRightHandedSystem?: boolean;
  83489. depthSort?: boolean;
  83490. distanceTo?: Vector3;
  83491. depthSortedFacets?: any;
  83492. }): void;
  83493. /** @hidden */
  83494. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83495. /**
  83496. * Applies VertexData created from the imported parameters to the geometry
  83497. * @param parsedVertexData the parsed data from an imported file
  83498. * @param geometry the geometry to apply the VertexData to
  83499. */
  83500. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83501. }
  83502. }
  83503. declare module BABYLON {
  83504. /**
  83505. * Class containing static functions to help procedurally build meshes
  83506. */
  83507. export class DiscBuilder {
  83508. /**
  83509. * Creates a plane polygonal mesh. By default, this is a disc
  83510. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83511. * * 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
  83512. * * 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
  83513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83516. * @param name defines the name of the mesh
  83517. * @param options defines the options used to create the mesh
  83518. * @param scene defines the hosting scene
  83519. * @returns the plane polygonal mesh
  83520. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83521. */
  83522. static CreateDisc(name: string, options: {
  83523. radius?: number;
  83524. tessellation?: number;
  83525. arc?: number;
  83526. updatable?: boolean;
  83527. sideOrientation?: number;
  83528. frontUVs?: Vector4;
  83529. backUVs?: Vector4;
  83530. }, scene?: Nullable<Scene>): Mesh;
  83531. }
  83532. }
  83533. declare module BABYLON {
  83534. /**
  83535. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83536. *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.
  83537. * The SPS is also a particle system. It provides some methods to manage the particles.
  83538. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83539. *
  83540. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83541. */
  83542. export class SolidParticleSystem implements IDisposable {
  83543. /**
  83544. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83545. * Example : var p = SPS.particles[i];
  83546. */
  83547. particles: SolidParticle[];
  83548. /**
  83549. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83550. */
  83551. nbParticles: number;
  83552. /**
  83553. * If the particles must ever face the camera (default false). Useful for planar particles.
  83554. */
  83555. billboard: boolean;
  83556. /**
  83557. * Recompute normals when adding a shape
  83558. */
  83559. recomputeNormals: boolean;
  83560. /**
  83561. * This a counter ofr your own usage. It's not set by any SPS functions.
  83562. */
  83563. counter: number;
  83564. /**
  83565. * The SPS name. This name is also given to the underlying mesh.
  83566. */
  83567. name: string;
  83568. /**
  83569. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83570. */
  83571. mesh: Mesh;
  83572. /**
  83573. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83574. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83575. */
  83576. vars: any;
  83577. /**
  83578. * This array is populated when the SPS is set as 'pickable'.
  83579. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83580. * Each element of this array is an object `{idx: int, faceId: int}`.
  83581. * `idx` is the picked particle index in the `SPS.particles` array
  83582. * `faceId` is the picked face index counted within this particle.
  83583. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83584. */
  83585. pickedParticles: {
  83586. idx: number;
  83587. faceId: number;
  83588. }[];
  83589. /**
  83590. * This array is populated when `enableDepthSort` is set to true.
  83591. * Each element of this array is an instance of the class DepthSortedParticle.
  83592. */
  83593. depthSortedParticles: DepthSortedParticle[];
  83594. /**
  83595. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83596. * @hidden
  83597. */
  83598. _bSphereOnly: boolean;
  83599. /**
  83600. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83601. * @hidden
  83602. */
  83603. _bSphereRadiusFactor: number;
  83604. private _scene;
  83605. private _positions;
  83606. private _indices;
  83607. private _normals;
  83608. private _colors;
  83609. private _uvs;
  83610. private _indices32;
  83611. private _positions32;
  83612. private _normals32;
  83613. private _fixedNormal32;
  83614. private _colors32;
  83615. private _uvs32;
  83616. private _index;
  83617. private _updatable;
  83618. private _pickable;
  83619. private _isVisibilityBoxLocked;
  83620. private _alwaysVisible;
  83621. private _depthSort;
  83622. private _shapeCounter;
  83623. private _copy;
  83624. private _color;
  83625. private _computeParticleColor;
  83626. private _computeParticleTexture;
  83627. private _computeParticleRotation;
  83628. private _computeParticleVertex;
  83629. private _computeBoundingBox;
  83630. private _depthSortParticles;
  83631. private _camera;
  83632. private _mustUnrotateFixedNormals;
  83633. private _particlesIntersect;
  83634. private _needs32Bits;
  83635. /**
  83636. * Creates a SPS (Solid Particle System) object.
  83637. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83638. * @param scene (Scene) is the scene in which the SPS is added.
  83639. * @param options defines the options of the sps e.g.
  83640. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83641. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83642. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83643. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83644. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83645. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83646. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83647. */
  83648. constructor(name: string, scene: Scene, options?: {
  83649. updatable?: boolean;
  83650. isPickable?: boolean;
  83651. enableDepthSort?: boolean;
  83652. particleIntersection?: boolean;
  83653. boundingSphereOnly?: boolean;
  83654. bSphereRadiusFactor?: number;
  83655. });
  83656. /**
  83657. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83658. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83659. * @returns the created mesh
  83660. */
  83661. buildMesh(): Mesh;
  83662. /**
  83663. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83664. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83665. * Thus the particles generated from `digest()` have their property `position` set yet.
  83666. * @param mesh ( Mesh ) is the mesh to be digested
  83667. * @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
  83668. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83669. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83670. * @returns the current SPS
  83671. */
  83672. digest(mesh: Mesh, options?: {
  83673. facetNb?: number;
  83674. number?: number;
  83675. delta?: number;
  83676. }): SolidParticleSystem;
  83677. private _unrotateFixedNormals;
  83678. private _resetCopy;
  83679. private _meshBuilder;
  83680. private _posToShape;
  83681. private _uvsToShapeUV;
  83682. private _addParticle;
  83683. /**
  83684. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83685. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83686. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83687. * @param nb (positive integer) the number of particles to be created from this model
  83688. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83689. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83690. * @returns the number of shapes in the system
  83691. */
  83692. addShape(mesh: Mesh, nb: number, options?: {
  83693. positionFunction?: any;
  83694. vertexFunction?: any;
  83695. }): number;
  83696. private _rebuildParticle;
  83697. /**
  83698. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83699. * @returns the SPS.
  83700. */
  83701. rebuildMesh(): SolidParticleSystem;
  83702. /**
  83703. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83704. * This method calls `updateParticle()` for each particle of the SPS.
  83705. * For an animated SPS, it is usually called within the render loop.
  83706. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83707. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83708. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83709. * @returns the SPS.
  83710. */
  83711. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83712. /**
  83713. * Disposes the SPS.
  83714. */
  83715. dispose(): void;
  83716. /**
  83717. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83718. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83719. * @returns the SPS.
  83720. */
  83721. refreshVisibleSize(): SolidParticleSystem;
  83722. /**
  83723. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83724. * @param size the size (float) of the visibility box
  83725. * note : this doesn't lock the SPS mesh bounding box.
  83726. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83727. */
  83728. setVisibilityBox(size: number): void;
  83729. /**
  83730. * Gets whether the SPS as always visible or not
  83731. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83732. */
  83733. /**
  83734. * Sets the SPS as always visible or not
  83735. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83736. */
  83737. isAlwaysVisible: boolean;
  83738. /**
  83739. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83740. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83741. */
  83742. /**
  83743. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83744. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83745. */
  83746. isVisibilityBoxLocked: boolean;
  83747. /**
  83748. * Tells to `setParticles()` to compute the particle rotations or not.
  83749. * Default value : true. The SPS is faster when it's set to false.
  83750. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83751. */
  83752. /**
  83753. * Gets if `setParticles()` computes the particle rotations or not.
  83754. * Default value : true. The SPS is faster when it's set to false.
  83755. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83756. */
  83757. computeParticleRotation: boolean;
  83758. /**
  83759. * Tells to `setParticles()` to compute the particle colors or not.
  83760. * Default value : true. The SPS is faster when it's set to false.
  83761. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83762. */
  83763. /**
  83764. * Gets if `setParticles()` computes the particle colors or not.
  83765. * Default value : true. The SPS is faster when it's set to false.
  83766. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83767. */
  83768. computeParticleColor: boolean;
  83769. /**
  83770. * Gets if `setParticles()` computes the particle textures or not.
  83771. * Default value : true. The SPS is faster when it's set to false.
  83772. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83773. */
  83774. computeParticleTexture: boolean;
  83775. /**
  83776. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83777. * Default value : false. The SPS is faster when it's set to false.
  83778. * Note : the particle custom vertex positions aren't stored values.
  83779. */
  83780. /**
  83781. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83782. * Default value : false. The SPS is faster when it's set to false.
  83783. * Note : the particle custom vertex positions aren't stored values.
  83784. */
  83785. computeParticleVertex: boolean;
  83786. /**
  83787. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83788. */
  83789. /**
  83790. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83791. */
  83792. computeBoundingBox: boolean;
  83793. /**
  83794. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83795. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83796. * Default : `true`
  83797. */
  83798. /**
  83799. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83800. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83801. * Default : `true`
  83802. */
  83803. depthSortParticles: boolean;
  83804. /**
  83805. * This function does nothing. It may be overwritten to set all the particle first values.
  83806. * The SPS doesn't call this function, you may have to call it by your own.
  83807. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83808. */
  83809. initParticles(): void;
  83810. /**
  83811. * This function does nothing. It may be overwritten to recycle a particle.
  83812. * The SPS doesn't call this function, you may have to call it by your own.
  83813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83814. * @param particle The particle to recycle
  83815. * @returns the recycled particle
  83816. */
  83817. recycleParticle(particle: SolidParticle): SolidParticle;
  83818. /**
  83819. * Updates a particle : this function should be overwritten by the user.
  83820. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83821. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83822. * @example : just set a particle position or velocity and recycle conditions
  83823. * @param particle The particle to update
  83824. * @returns the updated particle
  83825. */
  83826. updateParticle(particle: SolidParticle): SolidParticle;
  83827. /**
  83828. * Updates a vertex of a particle : it can be overwritten by the user.
  83829. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83830. * @param particle the current particle
  83831. * @param vertex the current index of the current particle
  83832. * @param pt the index of the current vertex in the particle shape
  83833. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83834. * @example : just set a vertex particle position
  83835. * @returns the updated vertex
  83836. */
  83837. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83838. /**
  83839. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83840. * This does nothing and may be overwritten by the user.
  83841. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83842. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83843. * @param update the boolean update value actually passed to setParticles()
  83844. */
  83845. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83846. /**
  83847. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83848. * This will be passed three parameters.
  83849. * This does nothing and may be overwritten by the user.
  83850. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83851. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83852. * @param update the boolean update value actually passed to setParticles()
  83853. */
  83854. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83855. }
  83856. }
  83857. declare module BABYLON {
  83858. /**
  83859. * Represents one particle of a solid particle system.
  83860. */
  83861. export class SolidParticle {
  83862. /**
  83863. * particle global index
  83864. */
  83865. idx: number;
  83866. /**
  83867. * The color of the particle
  83868. */
  83869. color: Nullable<Color4>;
  83870. /**
  83871. * The world space position of the particle.
  83872. */
  83873. position: Vector3;
  83874. /**
  83875. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83876. */
  83877. rotation: Vector3;
  83878. /**
  83879. * The world space rotation quaternion of the particle.
  83880. */
  83881. rotationQuaternion: Nullable<Quaternion>;
  83882. /**
  83883. * The scaling of the particle.
  83884. */
  83885. scaling: Vector3;
  83886. /**
  83887. * The uvs of the particle.
  83888. */
  83889. uvs: Vector4;
  83890. /**
  83891. * The current speed of the particle.
  83892. */
  83893. velocity: Vector3;
  83894. /**
  83895. * The pivot point in the particle local space.
  83896. */
  83897. pivot: Vector3;
  83898. /**
  83899. * Must the particle be translated from its pivot point in its local space ?
  83900. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83901. * Default : false
  83902. */
  83903. translateFromPivot: boolean;
  83904. /**
  83905. * Is the particle active or not ?
  83906. */
  83907. alive: boolean;
  83908. /**
  83909. * Is the particle visible or not ?
  83910. */
  83911. isVisible: boolean;
  83912. /**
  83913. * Index of this particle in the global "positions" array (Internal use)
  83914. * @hidden
  83915. */
  83916. _pos: number;
  83917. /**
  83918. * @hidden Index of this particle in the global "indices" array (Internal use)
  83919. */
  83920. _ind: number;
  83921. /**
  83922. * @hidden ModelShape of this particle (Internal use)
  83923. */
  83924. _model: ModelShape;
  83925. /**
  83926. * ModelShape id of this particle
  83927. */
  83928. shapeId: number;
  83929. /**
  83930. * Index of the particle in its shape id (Internal use)
  83931. */
  83932. idxInShape: number;
  83933. /**
  83934. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83935. */
  83936. _modelBoundingInfo: BoundingInfo;
  83937. /**
  83938. * @hidden Particle BoundingInfo object (Internal use)
  83939. */
  83940. _boundingInfo: BoundingInfo;
  83941. /**
  83942. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83943. */
  83944. _sps: SolidParticleSystem;
  83945. /**
  83946. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83947. */
  83948. _stillInvisible: boolean;
  83949. /**
  83950. * @hidden Last computed particle rotation matrix
  83951. */
  83952. _rotationMatrix: number[];
  83953. /**
  83954. * Parent particle Id, if any.
  83955. * Default null.
  83956. */
  83957. parentId: Nullable<number>;
  83958. /**
  83959. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83960. * The possible values are :
  83961. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83962. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83963. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83964. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83965. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83966. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83967. * */
  83968. cullingStrategy: number;
  83969. /**
  83970. * @hidden Internal global position in the SPS.
  83971. */
  83972. _globalPosition: Vector3;
  83973. /**
  83974. * Creates a Solid Particle object.
  83975. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83976. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83977. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83978. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83979. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83980. * @param shapeId (integer) is the model shape identifier in the SPS.
  83981. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83982. * @param sps defines the sps it is associated to
  83983. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83984. */
  83985. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83986. /**
  83987. * Legacy support, changed scale to scaling
  83988. */
  83989. /**
  83990. * Legacy support, changed scale to scaling
  83991. */
  83992. scale: Vector3;
  83993. /**
  83994. * Legacy support, changed quaternion to rotationQuaternion
  83995. */
  83996. /**
  83997. * Legacy support, changed quaternion to rotationQuaternion
  83998. */
  83999. quaternion: Nullable<Quaternion>;
  84000. /**
  84001. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84002. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84003. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84004. * @returns true if it intersects
  84005. */
  84006. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84007. /**
  84008. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84009. * A particle is in the frustum if its bounding box intersects the frustum
  84010. * @param frustumPlanes defines the frustum to test
  84011. * @returns true if the particle is in the frustum planes
  84012. */
  84013. isInFrustum(frustumPlanes: Plane[]): boolean;
  84014. /**
  84015. * get the rotation matrix of the particle
  84016. * @hidden
  84017. */
  84018. getRotationMatrix(m: Matrix): void;
  84019. }
  84020. /**
  84021. * Represents the shape of the model used by one particle of a solid particle system.
  84022. * SPS internal tool, don't use it manually.
  84023. */
  84024. export class ModelShape {
  84025. /**
  84026. * The shape id
  84027. * @hidden
  84028. */
  84029. shapeID: number;
  84030. /**
  84031. * flat array of model positions (internal use)
  84032. * @hidden
  84033. */
  84034. _shape: Vector3[];
  84035. /**
  84036. * flat array of model UVs (internal use)
  84037. * @hidden
  84038. */
  84039. _shapeUV: number[];
  84040. /**
  84041. * length of the shape in the model indices array (internal use)
  84042. * @hidden
  84043. */
  84044. _indicesLength: number;
  84045. /**
  84046. * Custom position function (internal use)
  84047. * @hidden
  84048. */
  84049. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84050. /**
  84051. * Custom vertex function (internal use)
  84052. * @hidden
  84053. */
  84054. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84055. /**
  84056. * 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.
  84057. * SPS internal tool, don't use it manually.
  84058. * @hidden
  84059. */
  84060. 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>);
  84061. }
  84062. /**
  84063. * Represents a Depth Sorted Particle in the solid particle system.
  84064. */
  84065. export class DepthSortedParticle {
  84066. /**
  84067. * Index of the particle in the "indices" array
  84068. */
  84069. ind: number;
  84070. /**
  84071. * Length of the particle shape in the "indices" array
  84072. */
  84073. indicesLength: number;
  84074. /**
  84075. * Squared distance from the particle to the camera
  84076. */
  84077. sqDistance: number;
  84078. }
  84079. }
  84080. declare module BABYLON {
  84081. /**
  84082. * Class used to store all common mesh properties
  84083. */
  84084. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84085. /** No occlusion */
  84086. static OCCLUSION_TYPE_NONE: number;
  84087. /** Occlusion set to optimisitic */
  84088. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84089. /** Occlusion set to strict */
  84090. static OCCLUSION_TYPE_STRICT: number;
  84091. /** Use an accurante occlusion algorithm */
  84092. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84093. /** Use a conservative occlusion algorithm */
  84094. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84095. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84096. * Test order :
  84097. * Is the bounding sphere outside the frustum ?
  84098. * If not, are the bounding box vertices outside the frustum ?
  84099. * It not, then the cullable object is in the frustum.
  84100. */
  84101. static readonly CULLINGSTRATEGY_STANDARD: number;
  84102. /** Culling strategy : Bounding Sphere Only.
  84103. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84104. * It's also less accurate than the standard because some not visible objects can still be selected.
  84105. * Test : is the bounding sphere outside the frustum ?
  84106. * If not, then the cullable object is in the frustum.
  84107. */
  84108. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84109. /** Culling strategy : Optimistic Inclusion.
  84110. * This in an inclusion test first, then the standard exclusion test.
  84111. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84112. * 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.
  84113. * Anyway, it's as accurate as the standard strategy.
  84114. * Test :
  84115. * Is the cullable object bounding sphere center in the frustum ?
  84116. * If not, apply the default culling strategy.
  84117. */
  84118. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84119. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84120. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84121. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84122. * 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.
  84123. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84124. * Test :
  84125. * Is the cullable object bounding sphere center in the frustum ?
  84126. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84127. */
  84128. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84129. /**
  84130. * No billboard
  84131. */
  84132. static readonly BILLBOARDMODE_NONE: number;
  84133. /** Billboard on X axis */
  84134. static readonly BILLBOARDMODE_X: number;
  84135. /** Billboard on Y axis */
  84136. static readonly BILLBOARDMODE_Y: number;
  84137. /** Billboard on Z axis */
  84138. static readonly BILLBOARDMODE_Z: number;
  84139. /** Billboard on all axes */
  84140. static readonly BILLBOARDMODE_ALL: number;
  84141. private _facetData;
  84142. /**
  84143. * The culling strategy to use to check whether the mesh must be rendered or not.
  84144. * This value can be changed at any time and will be used on the next render mesh selection.
  84145. * The possible values are :
  84146. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84147. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84148. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84149. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84150. * Please read each static variable documentation to get details about the culling process.
  84151. * */
  84152. cullingStrategy: number;
  84153. /**
  84154. * Gets the number of facets in the mesh
  84155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84156. */
  84157. readonly facetNb: number;
  84158. /**
  84159. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84161. */
  84162. partitioningSubdivisions: number;
  84163. /**
  84164. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84165. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84167. */
  84168. partitioningBBoxRatio: number;
  84169. /**
  84170. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84171. * Works only for updatable meshes.
  84172. * Doesn't work with multi-materials
  84173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84174. */
  84175. mustDepthSortFacets: boolean;
  84176. /**
  84177. * The location (Vector3) where the facet depth sort must be computed from.
  84178. * By default, the active camera position.
  84179. * Used only when facet depth sort is enabled
  84180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84181. */
  84182. facetDepthSortFrom: Vector3;
  84183. /**
  84184. * gets a boolean indicating if facetData is enabled
  84185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84186. */
  84187. readonly isFacetDataEnabled: boolean;
  84188. /** @hidden */
  84189. _updateNonUniformScalingState(value: boolean): boolean;
  84190. /**
  84191. * An event triggered when this mesh collides with another one
  84192. */
  84193. onCollideObservable: Observable<AbstractMesh>;
  84194. private _onCollideObserver;
  84195. /** Set a function to call when this mesh collides with another one */
  84196. onCollide: () => void;
  84197. /**
  84198. * An event triggered when the collision's position changes
  84199. */
  84200. onCollisionPositionChangeObservable: Observable<Vector3>;
  84201. private _onCollisionPositionChangeObserver;
  84202. /** Set a function to call when the collision's position changes */
  84203. onCollisionPositionChange: () => void;
  84204. /**
  84205. * An event triggered when material is changed
  84206. */
  84207. onMaterialChangedObservable: Observable<AbstractMesh>;
  84208. /**
  84209. * Gets or sets the orientation for POV movement & rotation
  84210. */
  84211. definedFacingForward: boolean;
  84212. /** @hidden */
  84213. _occlusionQuery: Nullable<WebGLQuery>;
  84214. private _visibility;
  84215. /** @hidden */
  84216. _isActive: boolean;
  84217. /** @hidden */
  84218. _onlyForInstances: boolean;
  84219. /** @hidden */
  84220. _renderingGroup: Nullable<RenderingGroup>;
  84221. /**
  84222. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84223. */
  84224. /**
  84225. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84226. */
  84227. visibility: number;
  84228. /** Gets or sets the alpha index used to sort transparent meshes
  84229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84230. */
  84231. alphaIndex: number;
  84232. /**
  84233. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84234. */
  84235. isVisible: boolean;
  84236. /**
  84237. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84238. */
  84239. isPickable: boolean;
  84240. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84241. showSubMeshesBoundingBox: boolean;
  84242. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84244. */
  84245. isBlocker: boolean;
  84246. /**
  84247. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84248. */
  84249. enablePointerMoveEvents: boolean;
  84250. /**
  84251. * Specifies the rendering group id for this mesh (0 by default)
  84252. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84253. */
  84254. renderingGroupId: number;
  84255. private _material;
  84256. /** Gets or sets current material */
  84257. material: Nullable<Material>;
  84258. private _receiveShadows;
  84259. /**
  84260. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84261. * @see http://doc.babylonjs.com/babylon101/shadows
  84262. */
  84263. receiveShadows: boolean;
  84264. /** Defines color to use when rendering outline */
  84265. outlineColor: Color3;
  84266. /** Define width to use when rendering outline */
  84267. outlineWidth: number;
  84268. /** Defines color to use when rendering overlay */
  84269. overlayColor: Color3;
  84270. /** Defines alpha to use when rendering overlay */
  84271. overlayAlpha: number;
  84272. private _hasVertexAlpha;
  84273. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84274. hasVertexAlpha: boolean;
  84275. private _useVertexColors;
  84276. /** 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) */
  84277. useVertexColors: boolean;
  84278. private _computeBonesUsingShaders;
  84279. /**
  84280. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84281. */
  84282. computeBonesUsingShaders: boolean;
  84283. private _numBoneInfluencers;
  84284. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84285. numBoneInfluencers: number;
  84286. private _applyFog;
  84287. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84288. applyFog: boolean;
  84289. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84290. useOctreeForRenderingSelection: boolean;
  84291. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84292. useOctreeForPicking: boolean;
  84293. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84294. useOctreeForCollisions: boolean;
  84295. private _layerMask;
  84296. /**
  84297. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84298. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84299. */
  84300. layerMask: number;
  84301. /**
  84302. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84303. */
  84304. alwaysSelectAsActiveMesh: boolean;
  84305. /**
  84306. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84307. */
  84308. doNotSyncBoundingInfo: boolean;
  84309. /**
  84310. * Gets or sets the current action manager
  84311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84312. */
  84313. actionManager: Nullable<AbstractActionManager>;
  84314. private _checkCollisions;
  84315. private _collisionMask;
  84316. private _collisionGroup;
  84317. /**
  84318. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84320. */
  84321. ellipsoid: Vector3;
  84322. /**
  84323. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84325. */
  84326. ellipsoidOffset: Vector3;
  84327. private _collider;
  84328. private _oldPositionForCollisions;
  84329. private _diffPositionForCollisions;
  84330. /**
  84331. * Gets or sets a collision mask used to mask collisions (default is -1).
  84332. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84333. */
  84334. collisionMask: number;
  84335. /**
  84336. * Gets or sets the current collision group mask (-1 by default).
  84337. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84338. */
  84339. collisionGroup: number;
  84340. /**
  84341. * Defines edge width used when edgesRenderer is enabled
  84342. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84343. */
  84344. edgesWidth: number;
  84345. /**
  84346. * Defines edge color used when edgesRenderer is enabled
  84347. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84348. */
  84349. edgesColor: Color4;
  84350. /** @hidden */
  84351. _edgesRenderer: Nullable<IEdgesRenderer>;
  84352. /** @hidden */
  84353. _masterMesh: Nullable<AbstractMesh>;
  84354. /** @hidden */
  84355. _boundingInfo: Nullable<BoundingInfo>;
  84356. /** @hidden */
  84357. _renderId: number;
  84358. /**
  84359. * Gets or sets the list of subMeshes
  84360. * @see http://doc.babylonjs.com/how_to/multi_materials
  84361. */
  84362. subMeshes: SubMesh[];
  84363. /** @hidden */
  84364. _intersectionsInProgress: AbstractMesh[];
  84365. /** @hidden */
  84366. _unIndexed: boolean;
  84367. /** @hidden */
  84368. _lightSources: Light[];
  84369. /** Gets the list of lights affecting that mesh */
  84370. readonly lightSources: Light[];
  84371. /** @hidden */
  84372. readonly _positions: Nullable<Vector3[]>;
  84373. /** @hidden */
  84374. _waitingActions: Nullable<any>;
  84375. /** @hidden */
  84376. _waitingFreezeWorldMatrix: Nullable<boolean>;
  84377. private _skeleton;
  84378. /** @hidden */
  84379. _bonesTransformMatrices: Nullable<Float32Array>;
  84380. /**
  84381. * Gets or sets a skeleton to apply skining transformations
  84382. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84383. */
  84384. skeleton: Nullable<Skeleton>;
  84385. /**
  84386. * An event triggered when the mesh is rebuilt.
  84387. */
  84388. onRebuildObservable: Observable<AbstractMesh>;
  84389. /**
  84390. * Creates a new AbstractMesh
  84391. * @param name defines the name of the mesh
  84392. * @param scene defines the hosting scene
  84393. */
  84394. constructor(name: string, scene?: Nullable<Scene>);
  84395. /**
  84396. * Returns the string "AbstractMesh"
  84397. * @returns "AbstractMesh"
  84398. */
  84399. getClassName(): string;
  84400. /**
  84401. * Gets a string representation of the current mesh
  84402. * @param fullDetails defines a boolean indicating if full details must be included
  84403. * @returns a string representation of the current mesh
  84404. */
  84405. toString(fullDetails?: boolean): string;
  84406. /**
  84407. * @hidden
  84408. */
  84409. protected _getEffectiveParent(): Nullable<Node>;
  84410. /** @hidden */
  84411. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84412. /** @hidden */
  84413. _rebuild(): void;
  84414. /** @hidden */
  84415. _resyncLightSources(): void;
  84416. /** @hidden */
  84417. _resyncLighSource(light: Light): void;
  84418. /** @hidden */
  84419. _unBindEffect(): void;
  84420. /** @hidden */
  84421. _removeLightSource(light: Light): void;
  84422. private _markSubMeshesAsDirty;
  84423. /** @hidden */
  84424. _markSubMeshesAsLightDirty(): void;
  84425. /** @hidden */
  84426. _markSubMeshesAsAttributesDirty(): void;
  84427. /** @hidden */
  84428. _markSubMeshesAsMiscDirty(): void;
  84429. /**
  84430. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84431. */
  84432. scaling: Vector3;
  84433. /**
  84434. * Returns true if the mesh is blocked. Implemented by child classes
  84435. */
  84436. readonly isBlocked: boolean;
  84437. /**
  84438. * Returns the mesh itself by default. Implemented by child classes
  84439. * @param camera defines the camera to use to pick the right LOD level
  84440. * @returns the currentAbstractMesh
  84441. */
  84442. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84443. /**
  84444. * Returns 0 by default. Implemented by child classes
  84445. * @returns an integer
  84446. */
  84447. getTotalVertices(): number;
  84448. /**
  84449. * Returns a positive integer : the total number of indices in this mesh geometry.
  84450. * @returns the numner of indices or zero if the mesh has no geometry.
  84451. */
  84452. getTotalIndices(): number;
  84453. /**
  84454. * Returns null by default. Implemented by child classes
  84455. * @returns null
  84456. */
  84457. getIndices(): Nullable<IndicesArray>;
  84458. /**
  84459. * Returns the array of the requested vertex data kind. Implemented by child classes
  84460. * @param kind defines the vertex data kind to use
  84461. * @returns null
  84462. */
  84463. getVerticesData(kind: string): Nullable<FloatArray>;
  84464. /**
  84465. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84466. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84467. * Note that a new underlying VertexBuffer object is created each call.
  84468. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84469. * @param kind defines vertex data kind:
  84470. * * VertexBuffer.PositionKind
  84471. * * VertexBuffer.UVKind
  84472. * * VertexBuffer.UV2Kind
  84473. * * VertexBuffer.UV3Kind
  84474. * * VertexBuffer.UV4Kind
  84475. * * VertexBuffer.UV5Kind
  84476. * * VertexBuffer.UV6Kind
  84477. * * VertexBuffer.ColorKind
  84478. * * VertexBuffer.MatricesIndicesKind
  84479. * * VertexBuffer.MatricesIndicesExtraKind
  84480. * * VertexBuffer.MatricesWeightsKind
  84481. * * VertexBuffer.MatricesWeightsExtraKind
  84482. * @param data defines the data source
  84483. * @param updatable defines if the data must be flagged as updatable (or static)
  84484. * @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
  84485. * @returns the current mesh
  84486. */
  84487. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84488. /**
  84489. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84490. * If the mesh has no geometry, it is simply returned as it is.
  84491. * @param kind defines vertex data kind:
  84492. * * VertexBuffer.PositionKind
  84493. * * VertexBuffer.UVKind
  84494. * * VertexBuffer.UV2Kind
  84495. * * VertexBuffer.UV3Kind
  84496. * * VertexBuffer.UV4Kind
  84497. * * VertexBuffer.UV5Kind
  84498. * * VertexBuffer.UV6Kind
  84499. * * VertexBuffer.ColorKind
  84500. * * VertexBuffer.MatricesIndicesKind
  84501. * * VertexBuffer.MatricesIndicesExtraKind
  84502. * * VertexBuffer.MatricesWeightsKind
  84503. * * VertexBuffer.MatricesWeightsExtraKind
  84504. * @param data defines the data source
  84505. * @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
  84506. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84507. * @returns the current mesh
  84508. */
  84509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84510. /**
  84511. * Sets the mesh indices,
  84512. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84513. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84514. * @param totalVertices Defines the total number of vertices
  84515. * @returns the current mesh
  84516. */
  84517. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84518. /**
  84519. * Gets a boolean indicating if specific vertex data is present
  84520. * @param kind defines the vertex data kind to use
  84521. * @returns true is data kind is present
  84522. */
  84523. isVerticesDataPresent(kind: string): boolean;
  84524. /**
  84525. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84526. * @returns a BoundingInfo
  84527. */
  84528. getBoundingInfo(): BoundingInfo;
  84529. /**
  84530. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84531. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84532. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84533. * @returns the current mesh
  84534. */
  84535. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84536. /**
  84537. * Overwrite the current bounding info
  84538. * @param boundingInfo defines the new bounding info
  84539. * @returns the current mesh
  84540. */
  84541. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84542. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84543. readonly useBones: boolean;
  84544. /** @hidden */
  84545. _preActivate(): void;
  84546. /** @hidden */
  84547. _preActivateForIntermediateRendering(renderId: number): void;
  84548. /** @hidden */
  84549. _activate(renderId: number): boolean;
  84550. /** @hidden */
  84551. _freeze(): void;
  84552. /** @hidden */
  84553. _unFreeze(): void;
  84554. /**
  84555. * Gets the current world matrix
  84556. * @returns a Matrix
  84557. */
  84558. getWorldMatrix(): Matrix;
  84559. /** @hidden */
  84560. _getWorldMatrixDeterminant(): number;
  84561. /**
  84562. * Perform relative position change from the point of view of behind the front of the mesh.
  84563. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84564. * Supports definition of mesh facing forward or backward
  84565. * @param amountRight defines the distance on the right axis
  84566. * @param amountUp defines the distance on the up axis
  84567. * @param amountForward defines the distance on the forward axis
  84568. * @returns the current mesh
  84569. */
  84570. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84571. /**
  84572. * Calculate relative position change from the point of view of behind the front of the mesh.
  84573. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84574. * Supports definition of mesh facing forward or backward
  84575. * @param amountRight defines the distance on the right axis
  84576. * @param amountUp defines the distance on the up axis
  84577. * @param amountForward defines the distance on the forward axis
  84578. * @returns the new displacement vector
  84579. */
  84580. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84581. /**
  84582. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84583. * Supports definition of mesh facing forward or backward
  84584. * @param flipBack defines the flip
  84585. * @param twirlClockwise defines the twirl
  84586. * @param tiltRight defines the tilt
  84587. * @returns the current mesh
  84588. */
  84589. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84590. /**
  84591. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84592. * Supports definition of mesh facing forward or backward.
  84593. * @param flipBack defines the flip
  84594. * @param twirlClockwise defines the twirl
  84595. * @param tiltRight defines the tilt
  84596. * @returns the new rotation vector
  84597. */
  84598. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84599. /**
  84600. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84601. * This means the mesh underlying bounding box and sphere are recomputed.
  84602. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84603. * @returns the current mesh
  84604. */
  84605. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84606. /** @hidden */
  84607. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84608. /** @hidden */
  84609. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84610. /** @hidden */
  84611. _updateBoundingInfo(): AbstractMesh;
  84612. /** @hidden */
  84613. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84614. /** @hidden */
  84615. protected _afterComputeWorldMatrix(): void;
  84616. /** @hidden */
  84617. readonly _effectiveMesh: AbstractMesh;
  84618. /**
  84619. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84620. * A mesh is in the frustum if its bounding box intersects the frustum
  84621. * @param frustumPlanes defines the frustum to test
  84622. * @returns true if the mesh is in the frustum planes
  84623. */
  84624. isInFrustum(frustumPlanes: Plane[]): boolean;
  84625. /**
  84626. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84627. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84628. * @param frustumPlanes defines the frustum to test
  84629. * @returns true if the mesh is completely in the frustum planes
  84630. */
  84631. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84632. /**
  84633. * True if the mesh intersects another mesh or a SolidParticle object
  84634. * @param mesh defines a target mesh or SolidParticle to test
  84635. * @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)
  84636. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84637. * @returns true if there is an intersection
  84638. */
  84639. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84640. /**
  84641. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84642. * @param point defines the point to test
  84643. * @returns true if there is an intersection
  84644. */
  84645. intersectsPoint(point: Vector3): boolean;
  84646. /**
  84647. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84649. */
  84650. checkCollisions: boolean;
  84651. /**
  84652. * Gets Collider object used to compute collisions (not physics)
  84653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84654. */
  84655. readonly collider: Nullable<Collider>;
  84656. /**
  84657. * Move the mesh using collision engine
  84658. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84659. * @param displacement defines the requested displacement vector
  84660. * @returns the current mesh
  84661. */
  84662. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84663. private _onCollisionPositionChange;
  84664. /** @hidden */
  84665. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84666. /** @hidden */
  84667. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84668. /** @hidden */
  84669. _checkCollision(collider: Collider): AbstractMesh;
  84670. /** @hidden */
  84671. _generatePointsArray(): boolean;
  84672. /**
  84673. * Checks if the passed Ray intersects with the mesh
  84674. * @param ray defines the ray to use
  84675. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84677. * @returns the picking info
  84678. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84679. */
  84680. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84681. /**
  84682. * Clones the current mesh
  84683. * @param name defines the mesh name
  84684. * @param newParent defines the new mesh parent
  84685. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84686. * @returns the new mesh
  84687. */
  84688. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84689. /**
  84690. * Disposes all the submeshes of the current meshnp
  84691. * @returns the current mesh
  84692. */
  84693. releaseSubMeshes(): AbstractMesh;
  84694. /**
  84695. * Releases resources associated with this abstract mesh.
  84696. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84697. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84698. */
  84699. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84700. /**
  84701. * Adds the passed mesh as a child to the current mesh
  84702. * @param mesh defines the child mesh
  84703. * @returns the current mesh
  84704. */
  84705. addChild(mesh: AbstractMesh): AbstractMesh;
  84706. /**
  84707. * Removes the passed mesh from the current mesh children list
  84708. * @param mesh defines the child mesh
  84709. * @returns the current mesh
  84710. */
  84711. removeChild(mesh: AbstractMesh): AbstractMesh;
  84712. /** @hidden */
  84713. private _initFacetData;
  84714. /**
  84715. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84716. * This method can be called within the render loop.
  84717. * 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
  84718. * @returns the current mesh
  84719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84720. */
  84721. updateFacetData(): AbstractMesh;
  84722. /**
  84723. * Returns the facetLocalNormals array.
  84724. * The normals are expressed in the mesh local spac
  84725. * @returns an array of Vector3
  84726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84727. */
  84728. getFacetLocalNormals(): Vector3[];
  84729. /**
  84730. * Returns the facetLocalPositions array.
  84731. * The facet positions are expressed in the mesh local space
  84732. * @returns an array of Vector3
  84733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84734. */
  84735. getFacetLocalPositions(): Vector3[];
  84736. /**
  84737. * Returns the facetLocalPartioning array
  84738. * @returns an array of array of numbers
  84739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84740. */
  84741. getFacetLocalPartitioning(): number[][];
  84742. /**
  84743. * Returns the i-th facet position in the world system.
  84744. * This method allocates a new Vector3 per call
  84745. * @param i defines the facet index
  84746. * @returns a new Vector3
  84747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84748. */
  84749. getFacetPosition(i: number): Vector3;
  84750. /**
  84751. * Sets the reference Vector3 with the i-th facet position in the world system
  84752. * @param i defines the facet index
  84753. * @param ref defines the target vector
  84754. * @returns the current mesh
  84755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84756. */
  84757. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84758. /**
  84759. * Returns the i-th facet normal in the world system.
  84760. * This method allocates a new Vector3 per call
  84761. * @param i defines the facet index
  84762. * @returns a new Vector3
  84763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84764. */
  84765. getFacetNormal(i: number): Vector3;
  84766. /**
  84767. * Sets the reference Vector3 with the i-th facet normal in the world system
  84768. * @param i defines the facet index
  84769. * @param ref defines the target vector
  84770. * @returns the current mesh
  84771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84772. */
  84773. getFacetNormalToRef(i: number, ref: Vector3): this;
  84774. /**
  84775. * 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)
  84776. * @param x defines x coordinate
  84777. * @param y defines y coordinate
  84778. * @param z defines z coordinate
  84779. * @returns the array of facet indexes
  84780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84781. */
  84782. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84783. /**
  84784. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84785. * @param projected sets as the (x,y,z) world projection on the facet
  84786. * @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
  84787. * @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
  84788. * @param x defines x coordinate
  84789. * @param y defines y coordinate
  84790. * @param z defines z coordinate
  84791. * @returns the face index if found (or null instead)
  84792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84793. */
  84794. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84795. /**
  84796. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84797. * @param projected sets as the (x,y,z) local projection on the facet
  84798. * @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
  84799. * @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
  84800. * @param x defines x coordinate
  84801. * @param y defines y coordinate
  84802. * @param z defines z coordinate
  84803. * @returns the face index if found (or null instead)
  84804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84805. */
  84806. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84807. /**
  84808. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84809. * @returns the parameters
  84810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84811. */
  84812. getFacetDataParameters(): any;
  84813. /**
  84814. * Disables the feature FacetData and frees the related memory
  84815. * @returns the current mesh
  84816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84817. */
  84818. disableFacetData(): AbstractMesh;
  84819. /**
  84820. * Updates the AbstractMesh indices array
  84821. * @param indices defines the data source
  84822. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84823. * @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)
  84824. * @returns the current mesh
  84825. */
  84826. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84827. /**
  84828. * Creates new normals data for the mesh
  84829. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84830. * @returns the current mesh
  84831. */
  84832. createNormals(updatable: boolean): AbstractMesh;
  84833. /**
  84834. * Align the mesh with a normal
  84835. * @param normal defines the normal to use
  84836. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84837. * @returns the current mesh
  84838. */
  84839. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84840. /** @hidden */
  84841. _checkOcclusionQuery(): boolean;
  84842. }
  84843. }
  84844. declare module BABYLON {
  84845. /**
  84846. * Interface used to define ActionEvent
  84847. */
  84848. export interface IActionEvent {
  84849. /** The mesh or sprite that triggered the action */
  84850. source: any;
  84851. /** The X mouse cursor position at the time of the event */
  84852. pointerX: number;
  84853. /** The Y mouse cursor position at the time of the event */
  84854. pointerY: number;
  84855. /** The mesh that is currently pointed at (can be null) */
  84856. meshUnderPointer: Nullable<AbstractMesh>;
  84857. /** the original (browser) event that triggered the ActionEvent */
  84858. sourceEvent?: any;
  84859. /** additional data for the event */
  84860. additionalData?: any;
  84861. }
  84862. /**
  84863. * ActionEvent is the event being sent when an action is triggered.
  84864. */
  84865. export class ActionEvent implements IActionEvent {
  84866. /** The mesh or sprite that triggered the action */
  84867. source: any;
  84868. /** The X mouse cursor position at the time of the event */
  84869. pointerX: number;
  84870. /** The Y mouse cursor position at the time of the event */
  84871. pointerY: number;
  84872. /** The mesh that is currently pointed at (can be null) */
  84873. meshUnderPointer: Nullable<AbstractMesh>;
  84874. /** the original (browser) event that triggered the ActionEvent */
  84875. sourceEvent?: any;
  84876. /** additional data for the event */
  84877. additionalData?: any;
  84878. /**
  84879. * Creates a new ActionEvent
  84880. * @param source The mesh or sprite that triggered the action
  84881. * @param pointerX The X mouse cursor position at the time of the event
  84882. * @param pointerY The Y mouse cursor position at the time of the event
  84883. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84884. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84885. * @param additionalData additional data for the event
  84886. */
  84887. constructor(
  84888. /** The mesh or sprite that triggered the action */
  84889. source: any,
  84890. /** The X mouse cursor position at the time of the event */
  84891. pointerX: number,
  84892. /** The Y mouse cursor position at the time of the event */
  84893. pointerY: number,
  84894. /** The mesh that is currently pointed at (can be null) */
  84895. meshUnderPointer: Nullable<AbstractMesh>,
  84896. /** the original (browser) event that triggered the ActionEvent */
  84897. sourceEvent?: any,
  84898. /** additional data for the event */
  84899. additionalData?: any);
  84900. /**
  84901. * Helper function to auto-create an ActionEvent from a source mesh.
  84902. * @param source The source mesh that triggered the event
  84903. * @param evt The original (browser) event
  84904. * @param additionalData additional data for the event
  84905. * @returns the new ActionEvent
  84906. */
  84907. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84908. /**
  84909. * Helper function to auto-create an ActionEvent from a source sprite
  84910. * @param source The source sprite that triggered the event
  84911. * @param scene Scene associated with the sprite
  84912. * @param evt The original (browser) event
  84913. * @param additionalData additional data for the event
  84914. * @returns the new ActionEvent
  84915. */
  84916. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84917. /**
  84918. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84919. * @param scene the scene where the event occurred
  84920. * @param evt The original (browser) event
  84921. * @returns the new ActionEvent
  84922. */
  84923. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84924. /**
  84925. * Helper function to auto-create an ActionEvent from a primitive
  84926. * @param prim defines the target primitive
  84927. * @param pointerPos defines the pointer position
  84928. * @param evt The original (browser) event
  84929. * @param additionalData additional data for the event
  84930. * @returns the new ActionEvent
  84931. */
  84932. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84933. }
  84934. }
  84935. declare module BABYLON {
  84936. /**
  84937. * Abstract class used to decouple action Manager from scene and meshes.
  84938. * Do not instantiate.
  84939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84940. */
  84941. export abstract class AbstractActionManager implements IDisposable {
  84942. /** Gets the list of active triggers */
  84943. static Triggers: {
  84944. [key: string]: number;
  84945. };
  84946. /** Gets the cursor to use when hovering items */
  84947. hoverCursor: string;
  84948. /** Gets the list of actions */
  84949. actions: IAction[];
  84950. /**
  84951. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84952. */
  84953. isRecursive: boolean;
  84954. /**
  84955. * Releases all associated resources
  84956. */
  84957. abstract dispose(): void;
  84958. /**
  84959. * Does this action manager has pointer triggers
  84960. */
  84961. abstract readonly hasPointerTriggers: boolean;
  84962. /**
  84963. * Does this action manager has pick triggers
  84964. */
  84965. abstract readonly hasPickTriggers: boolean;
  84966. /**
  84967. * Process a specific trigger
  84968. * @param trigger defines the trigger to process
  84969. * @param evt defines the event details to be processed
  84970. */
  84971. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84972. /**
  84973. * Does this action manager handles actions of any of the given triggers
  84974. * @param triggers defines the triggers to be tested
  84975. * @return a boolean indicating whether one (or more) of the triggers is handled
  84976. */
  84977. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84978. /**
  84979. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84980. * speed.
  84981. * @param triggerA defines the trigger to be tested
  84982. * @param triggerB defines the trigger to be tested
  84983. * @return a boolean indicating whether one (or more) of the triggers is handled
  84984. */
  84985. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84986. /**
  84987. * Does this action manager handles actions of a given trigger
  84988. * @param trigger defines the trigger to be tested
  84989. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84990. * @return whether the trigger is handled
  84991. */
  84992. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84993. /**
  84994. * Serialize this manager to a JSON object
  84995. * @param name defines the property name to store this manager
  84996. * @returns a JSON representation of this manager
  84997. */
  84998. abstract serialize(name: string): any;
  84999. /**
  85000. * Registers an action to this action manager
  85001. * @param action defines the action to be registered
  85002. * @return the action amended (prepared) after registration
  85003. */
  85004. abstract registerAction(action: IAction): Nullable<IAction>;
  85005. /**
  85006. * Unregisters an action to this action manager
  85007. * @param action defines the action to be unregistered
  85008. * @return a boolean indicating whether the action has been unregistered
  85009. */
  85010. abstract unregisterAction(action: IAction): Boolean;
  85011. /**
  85012. * Does exist one action manager with at least one trigger
  85013. **/
  85014. static readonly HasTriggers: boolean;
  85015. /**
  85016. * Does exist one action manager with at least one pick trigger
  85017. **/
  85018. static readonly HasPickTriggers: boolean;
  85019. /**
  85020. * Does exist one action manager that handles actions of a given trigger
  85021. * @param trigger defines the trigger to be tested
  85022. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85023. **/
  85024. static HasSpecificTrigger(trigger: number): boolean;
  85025. }
  85026. }
  85027. declare module BABYLON {
  85028. /**
  85029. * Defines how a node can be built from a string name.
  85030. */
  85031. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85032. /**
  85033. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85034. */
  85035. export class Node implements IBehaviorAware<Node> {
  85036. /** @hidden */
  85037. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85038. private static _NodeConstructors;
  85039. /**
  85040. * Add a new node constructor
  85041. * @param type defines the type name of the node to construct
  85042. * @param constructorFunc defines the constructor function
  85043. */
  85044. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85045. /**
  85046. * Returns a node constructor based on type name
  85047. * @param type defines the type name
  85048. * @param name defines the new node name
  85049. * @param scene defines the hosting scene
  85050. * @param options defines optional options to transmit to constructors
  85051. * @returns the new constructor or null
  85052. */
  85053. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85054. /**
  85055. * Gets or sets the name of the node
  85056. */
  85057. name: string;
  85058. /**
  85059. * Gets or sets the id of the node
  85060. */
  85061. id: string;
  85062. /**
  85063. * Gets or sets the unique id of the node
  85064. */
  85065. uniqueId: number;
  85066. /**
  85067. * Gets or sets a string used to store user defined state for the node
  85068. */
  85069. state: string;
  85070. /**
  85071. * Gets or sets an object used to store user defined information for the node
  85072. */
  85073. metadata: any;
  85074. /**
  85075. * For internal use only. Please do not use.
  85076. */
  85077. reservedDataStore: any;
  85078. /**
  85079. * List of inspectable custom properties (used by the Inspector)
  85080. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85081. */
  85082. inspectableCustomProperties: IInspectable[];
  85083. /**
  85084. * Gets or sets a boolean used to define if the node must be serialized
  85085. */
  85086. doNotSerialize: boolean;
  85087. /** @hidden */
  85088. _isDisposed: boolean;
  85089. /**
  85090. * Gets a list of Animations associated with the node
  85091. */
  85092. animations: Animation[];
  85093. protected _ranges: {
  85094. [name: string]: Nullable<AnimationRange>;
  85095. };
  85096. /**
  85097. * Callback raised when the node is ready to be used
  85098. */
  85099. onReady: Nullable<(node: Node) => void>;
  85100. private _isEnabled;
  85101. private _isParentEnabled;
  85102. private _isReady;
  85103. /** @hidden */
  85104. _currentRenderId: number;
  85105. private _parentUpdateId;
  85106. /** @hidden */
  85107. _childUpdateId: number;
  85108. /** @hidden */
  85109. _waitingParentId: Nullable<string>;
  85110. /** @hidden */
  85111. _scene: Scene;
  85112. /** @hidden */
  85113. _cache: any;
  85114. private _parentNode;
  85115. private _children;
  85116. /** @hidden */
  85117. _worldMatrix: Matrix;
  85118. /** @hidden */
  85119. _worldMatrixDeterminant: number;
  85120. /** @hidden */
  85121. _worldMatrixDeterminantIsDirty: boolean;
  85122. /** @hidden */
  85123. private _sceneRootNodesIndex;
  85124. /**
  85125. * Gets a boolean indicating if the node has been disposed
  85126. * @returns true if the node was disposed
  85127. */
  85128. isDisposed(): boolean;
  85129. /**
  85130. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85131. * @see https://doc.babylonjs.com/how_to/parenting
  85132. */
  85133. parent: Nullable<Node>;
  85134. private addToSceneRootNodes;
  85135. private removeFromSceneRootNodes;
  85136. private _animationPropertiesOverride;
  85137. /**
  85138. * Gets or sets the animation properties override
  85139. */
  85140. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85141. /**
  85142. * Gets a string idenfifying the name of the class
  85143. * @returns "Node" string
  85144. */
  85145. getClassName(): string;
  85146. /** @hidden */
  85147. readonly _isNode: boolean;
  85148. /**
  85149. * An event triggered when the mesh is disposed
  85150. */
  85151. onDisposeObservable: Observable<Node>;
  85152. private _onDisposeObserver;
  85153. /**
  85154. * Sets a callback that will be raised when the node will be disposed
  85155. */
  85156. onDispose: () => void;
  85157. /**
  85158. * Creates a new Node
  85159. * @param name the name and id to be given to this node
  85160. * @param scene the scene this node will be added to
  85161. * @param addToRootNodes the node will be added to scene.rootNodes
  85162. */
  85163. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85164. /**
  85165. * Gets the scene of the node
  85166. * @returns a scene
  85167. */
  85168. getScene(): Scene;
  85169. /**
  85170. * Gets the engine of the node
  85171. * @returns a Engine
  85172. */
  85173. getEngine(): Engine;
  85174. private _behaviors;
  85175. /**
  85176. * Attach a behavior to the node
  85177. * @see http://doc.babylonjs.com/features/behaviour
  85178. * @param behavior defines the behavior to attach
  85179. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85180. * @returns the current Node
  85181. */
  85182. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85183. /**
  85184. * Remove an attached behavior
  85185. * @see http://doc.babylonjs.com/features/behaviour
  85186. * @param behavior defines the behavior to attach
  85187. * @returns the current Node
  85188. */
  85189. removeBehavior(behavior: Behavior<Node>): Node;
  85190. /**
  85191. * Gets the list of attached behaviors
  85192. * @see http://doc.babylonjs.com/features/behaviour
  85193. */
  85194. readonly behaviors: Behavior<Node>[];
  85195. /**
  85196. * Gets an attached behavior by name
  85197. * @param name defines the name of the behavior to look for
  85198. * @see http://doc.babylonjs.com/features/behaviour
  85199. * @returns null if behavior was not found else the requested behavior
  85200. */
  85201. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85202. /**
  85203. * Returns the latest update of the World matrix
  85204. * @returns a Matrix
  85205. */
  85206. getWorldMatrix(): Matrix;
  85207. /** @hidden */
  85208. _getWorldMatrixDeterminant(): number;
  85209. /**
  85210. * Returns directly the latest state of the mesh World matrix.
  85211. * A Matrix is returned.
  85212. */
  85213. readonly worldMatrixFromCache: Matrix;
  85214. /** @hidden */
  85215. _initCache(): void;
  85216. /** @hidden */
  85217. updateCache(force?: boolean): void;
  85218. /** @hidden */
  85219. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85220. /** @hidden */
  85221. _updateCache(ignoreParentClass?: boolean): void;
  85222. /** @hidden */
  85223. _isSynchronized(): boolean;
  85224. /** @hidden */
  85225. _markSyncedWithParent(): void;
  85226. /** @hidden */
  85227. isSynchronizedWithParent(): boolean;
  85228. /** @hidden */
  85229. isSynchronized(): boolean;
  85230. /**
  85231. * Is this node ready to be used/rendered
  85232. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85233. * @return true if the node is ready
  85234. */
  85235. isReady(completeCheck?: boolean): boolean;
  85236. /**
  85237. * Is this node enabled?
  85238. * 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
  85239. * @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
  85240. * @return whether this node (and its parent) is enabled
  85241. */
  85242. isEnabled(checkAncestors?: boolean): boolean;
  85243. /** @hidden */
  85244. protected _syncParentEnabledState(): void;
  85245. /**
  85246. * Set the enabled state of this node
  85247. * @param value defines the new enabled state
  85248. */
  85249. setEnabled(value: boolean): void;
  85250. /**
  85251. * Is this node a descendant of the given node?
  85252. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85253. * @param ancestor defines the parent node to inspect
  85254. * @returns a boolean indicating if this node is a descendant of the given node
  85255. */
  85256. isDescendantOf(ancestor: Node): boolean;
  85257. /** @hidden */
  85258. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85259. /**
  85260. * Will return all nodes that have this node as ascendant
  85261. * @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
  85262. * @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
  85263. * @return all children nodes of all types
  85264. */
  85265. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85266. /**
  85267. * Get all child-meshes of this node
  85268. * @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)
  85269. * @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
  85270. * @returns an array of AbstractMesh
  85271. */
  85272. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85273. /**
  85274. * Get all direct children of this node
  85275. * @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
  85276. * @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)
  85277. * @returns an array of Node
  85278. */
  85279. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85280. /** @hidden */
  85281. _setReady(state: boolean): void;
  85282. /**
  85283. * Get an animation by name
  85284. * @param name defines the name of the animation to look for
  85285. * @returns null if not found else the requested animation
  85286. */
  85287. getAnimationByName(name: string): Nullable<Animation>;
  85288. /**
  85289. * Creates an animation range for this node
  85290. * @param name defines the name of the range
  85291. * @param from defines the starting key
  85292. * @param to defines the end key
  85293. */
  85294. createAnimationRange(name: string, from: number, to: number): void;
  85295. /**
  85296. * Delete a specific animation range
  85297. * @param name defines the name of the range to delete
  85298. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85299. */
  85300. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85301. /**
  85302. * Get an animation range by name
  85303. * @param name defines the name of the animation range to look for
  85304. * @returns null if not found else the requested animation range
  85305. */
  85306. getAnimationRange(name: string): Nullable<AnimationRange>;
  85307. /**
  85308. * Gets the list of all animation ranges defined on this node
  85309. * @returns an array
  85310. */
  85311. getAnimationRanges(): Nullable<AnimationRange>[];
  85312. /**
  85313. * Will start the animation sequence
  85314. * @param name defines the range frames for animation sequence
  85315. * @param loop defines if the animation should loop (false by default)
  85316. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85317. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85318. * @returns the object created for this animation. If range does not exist, it will return null
  85319. */
  85320. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85321. /**
  85322. * Serialize animation ranges into a JSON compatible object
  85323. * @returns serialization object
  85324. */
  85325. serializeAnimationRanges(): any;
  85326. /**
  85327. * Computes the world matrix of the node
  85328. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85329. * @returns the world matrix
  85330. */
  85331. computeWorldMatrix(force?: boolean): Matrix;
  85332. /**
  85333. * Releases resources associated with this node.
  85334. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85335. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85336. */
  85337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85338. /**
  85339. * Parse animation range data from a serialization object and store them into a given node
  85340. * @param node defines where to store the animation ranges
  85341. * @param parsedNode defines the serialization object to read data from
  85342. * @param scene defines the hosting scene
  85343. */
  85344. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85345. /**
  85346. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85347. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85348. * @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
  85349. * @returns the new bounding vectors
  85350. */
  85351. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85352. min: Vector3;
  85353. max: Vector3;
  85354. };
  85355. }
  85356. }
  85357. declare module BABYLON {
  85358. /**
  85359. * @hidden
  85360. */
  85361. export class _IAnimationState {
  85362. key: number;
  85363. repeatCount: number;
  85364. workValue?: any;
  85365. loopMode?: number;
  85366. offsetValue?: any;
  85367. highLimitValue?: any;
  85368. }
  85369. /**
  85370. * Class used to store any kind of animation
  85371. */
  85372. export class Animation {
  85373. /**Name of the animation */
  85374. name: string;
  85375. /**Property to animate */
  85376. targetProperty: string;
  85377. /**The frames per second of the animation */
  85378. framePerSecond: number;
  85379. /**The data type of the animation */
  85380. dataType: number;
  85381. /**The loop mode of the animation */
  85382. loopMode?: number | undefined;
  85383. /**Specifies if blending should be enabled */
  85384. enableBlending?: boolean | undefined;
  85385. /**
  85386. * Use matrix interpolation instead of using direct key value when animating matrices
  85387. */
  85388. static AllowMatricesInterpolation: boolean;
  85389. /**
  85390. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85391. */
  85392. static AllowMatrixDecomposeForInterpolation: boolean;
  85393. /**
  85394. * Stores the key frames of the animation
  85395. */
  85396. private _keys;
  85397. /**
  85398. * Stores the easing function of the animation
  85399. */
  85400. private _easingFunction;
  85401. /**
  85402. * @hidden Internal use only
  85403. */
  85404. _runtimeAnimations: RuntimeAnimation[];
  85405. /**
  85406. * The set of event that will be linked to this animation
  85407. */
  85408. private _events;
  85409. /**
  85410. * Stores an array of target property paths
  85411. */
  85412. targetPropertyPath: string[];
  85413. /**
  85414. * Stores the blending speed of the animation
  85415. */
  85416. blendingSpeed: number;
  85417. /**
  85418. * Stores the animation ranges for the animation
  85419. */
  85420. private _ranges;
  85421. /**
  85422. * @hidden Internal use
  85423. */
  85424. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85425. /**
  85426. * Sets up an animation
  85427. * @param property The property to animate
  85428. * @param animationType The animation type to apply
  85429. * @param framePerSecond The frames per second of the animation
  85430. * @param easingFunction The easing function used in the animation
  85431. * @returns The created animation
  85432. */
  85433. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85434. /**
  85435. * Create and start an animation on a node
  85436. * @param name defines the name of the global animation that will be run on all nodes
  85437. * @param node defines the root node where the animation will take place
  85438. * @param targetProperty defines property to animate
  85439. * @param framePerSecond defines the number of frame per second yo use
  85440. * @param totalFrame defines the number of frames in total
  85441. * @param from defines the initial value
  85442. * @param to defines the final value
  85443. * @param loopMode defines which loop mode you want to use (off by default)
  85444. * @param easingFunction defines the easing function to use (linear by default)
  85445. * @param onAnimationEnd defines the callback to call when animation end
  85446. * @returns the animatable created for this animation
  85447. */
  85448. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85449. /**
  85450. * Create and start an animation on a node and its descendants
  85451. * @param name defines the name of the global animation that will be run on all nodes
  85452. * @param node defines the root node where the animation will take place
  85453. * @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
  85454. * @param targetProperty defines property to animate
  85455. * @param framePerSecond defines the number of frame per second to use
  85456. * @param totalFrame defines the number of frames in total
  85457. * @param from defines the initial value
  85458. * @param to defines the final value
  85459. * @param loopMode defines which loop mode you want to use (off by default)
  85460. * @param easingFunction defines the easing function to use (linear by default)
  85461. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85462. * @returns the list of animatables created for all nodes
  85463. * @example https://www.babylonjs-playground.com/#MH0VLI
  85464. */
  85465. 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[]>;
  85466. /**
  85467. * Creates a new animation, merges it with the existing animations and starts it
  85468. * @param name Name of the animation
  85469. * @param node Node which contains the scene that begins the animations
  85470. * @param targetProperty Specifies which property to animate
  85471. * @param framePerSecond The frames per second of the animation
  85472. * @param totalFrame The total number of frames
  85473. * @param from The frame at the beginning of the animation
  85474. * @param to The frame at the end of the animation
  85475. * @param loopMode Specifies the loop mode of the animation
  85476. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85477. * @param onAnimationEnd Callback to run once the animation is complete
  85478. * @returns Nullable animation
  85479. */
  85480. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85481. /**
  85482. * Transition property of an host to the target Value
  85483. * @param property The property to transition
  85484. * @param targetValue The target Value of the property
  85485. * @param host The object where the property to animate belongs
  85486. * @param scene Scene used to run the animation
  85487. * @param frameRate Framerate (in frame/s) to use
  85488. * @param transition The transition type we want to use
  85489. * @param duration The duration of the animation, in milliseconds
  85490. * @param onAnimationEnd Callback trigger at the end of the animation
  85491. * @returns Nullable animation
  85492. */
  85493. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85494. /**
  85495. * Return the array of runtime animations currently using this animation
  85496. */
  85497. readonly runtimeAnimations: RuntimeAnimation[];
  85498. /**
  85499. * Specifies if any of the runtime animations are currently running
  85500. */
  85501. readonly hasRunningRuntimeAnimations: boolean;
  85502. /**
  85503. * Initializes the animation
  85504. * @param name Name of the animation
  85505. * @param targetProperty Property to animate
  85506. * @param framePerSecond The frames per second of the animation
  85507. * @param dataType The data type of the animation
  85508. * @param loopMode The loop mode of the animation
  85509. * @param enableBlending Specifies if blending should be enabled
  85510. */
  85511. constructor(
  85512. /**Name of the animation */
  85513. name: string,
  85514. /**Property to animate */
  85515. targetProperty: string,
  85516. /**The frames per second of the animation */
  85517. framePerSecond: number,
  85518. /**The data type of the animation */
  85519. dataType: number,
  85520. /**The loop mode of the animation */
  85521. loopMode?: number | undefined,
  85522. /**Specifies if blending should be enabled */
  85523. enableBlending?: boolean | undefined);
  85524. /**
  85525. * Converts the animation to a string
  85526. * @param fullDetails support for multiple levels of logging within scene loading
  85527. * @returns String form of the animation
  85528. */
  85529. toString(fullDetails?: boolean): string;
  85530. /**
  85531. * Add an event to this animation
  85532. * @param event Event to add
  85533. */
  85534. addEvent(event: AnimationEvent): void;
  85535. /**
  85536. * Remove all events found at the given frame
  85537. * @param frame The frame to remove events from
  85538. */
  85539. removeEvents(frame: number): void;
  85540. /**
  85541. * Retrieves all the events from the animation
  85542. * @returns Events from the animation
  85543. */
  85544. getEvents(): AnimationEvent[];
  85545. /**
  85546. * Creates an animation range
  85547. * @param name Name of the animation range
  85548. * @param from Starting frame of the animation range
  85549. * @param to Ending frame of the animation
  85550. */
  85551. createRange(name: string, from: number, to: number): void;
  85552. /**
  85553. * Deletes an animation range by name
  85554. * @param name Name of the animation range to delete
  85555. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85556. */
  85557. deleteRange(name: string, deleteFrames?: boolean): void;
  85558. /**
  85559. * Gets the animation range by name, or null if not defined
  85560. * @param name Name of the animation range
  85561. * @returns Nullable animation range
  85562. */
  85563. getRange(name: string): Nullable<AnimationRange>;
  85564. /**
  85565. * Gets the key frames from the animation
  85566. * @returns The key frames of the animation
  85567. */
  85568. getKeys(): Array<IAnimationKey>;
  85569. /**
  85570. * Gets the highest frame rate of the animation
  85571. * @returns Highest frame rate of the animation
  85572. */
  85573. getHighestFrame(): number;
  85574. /**
  85575. * Gets the easing function of the animation
  85576. * @returns Easing function of the animation
  85577. */
  85578. getEasingFunction(): IEasingFunction;
  85579. /**
  85580. * Sets the easing function of the animation
  85581. * @param easingFunction A custom mathematical formula for animation
  85582. */
  85583. setEasingFunction(easingFunction: EasingFunction): void;
  85584. /**
  85585. * Interpolates a scalar linearly
  85586. * @param startValue Start value of the animation curve
  85587. * @param endValue End value of the animation curve
  85588. * @param gradient Scalar amount to interpolate
  85589. * @returns Interpolated scalar value
  85590. */
  85591. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85592. /**
  85593. * Interpolates a scalar cubically
  85594. * @param startValue Start value of the animation curve
  85595. * @param outTangent End tangent of the animation
  85596. * @param endValue End value of the animation curve
  85597. * @param inTangent Start tangent of the animation curve
  85598. * @param gradient Scalar amount to interpolate
  85599. * @returns Interpolated scalar value
  85600. */
  85601. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85602. /**
  85603. * Interpolates a quaternion using a spherical linear interpolation
  85604. * @param startValue Start value of the animation curve
  85605. * @param endValue End value of the animation curve
  85606. * @param gradient Scalar amount to interpolate
  85607. * @returns Interpolated quaternion value
  85608. */
  85609. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85610. /**
  85611. * Interpolates a quaternion cubically
  85612. * @param startValue Start value of the animation curve
  85613. * @param outTangent End tangent of the animation curve
  85614. * @param endValue End value of the animation curve
  85615. * @param inTangent Start tangent of the animation curve
  85616. * @param gradient Scalar amount to interpolate
  85617. * @returns Interpolated quaternion value
  85618. */
  85619. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85620. /**
  85621. * Interpolates a Vector3 linearl
  85622. * @param startValue Start value of the animation curve
  85623. * @param endValue End value of the animation curve
  85624. * @param gradient Scalar amount to interpolate
  85625. * @returns Interpolated scalar value
  85626. */
  85627. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85628. /**
  85629. * Interpolates a Vector3 cubically
  85630. * @param startValue Start value of the animation curve
  85631. * @param outTangent End tangent of the animation
  85632. * @param endValue End value of the animation curve
  85633. * @param inTangent Start tangent of the animation curve
  85634. * @param gradient Scalar amount to interpolate
  85635. * @returns InterpolatedVector3 value
  85636. */
  85637. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85638. /**
  85639. * Interpolates a Vector2 linearly
  85640. * @param startValue Start value of the animation curve
  85641. * @param endValue End value of the animation curve
  85642. * @param gradient Scalar amount to interpolate
  85643. * @returns Interpolated Vector2 value
  85644. */
  85645. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85646. /**
  85647. * Interpolates a Vector2 cubically
  85648. * @param startValue Start value of the animation curve
  85649. * @param outTangent End tangent of the animation
  85650. * @param endValue End value of the animation curve
  85651. * @param inTangent Start tangent of the animation curve
  85652. * @param gradient Scalar amount to interpolate
  85653. * @returns Interpolated Vector2 value
  85654. */
  85655. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85656. /**
  85657. * Interpolates a size linearly
  85658. * @param startValue Start value of the animation curve
  85659. * @param endValue End value of the animation curve
  85660. * @param gradient Scalar amount to interpolate
  85661. * @returns Interpolated Size value
  85662. */
  85663. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85664. /**
  85665. * Interpolates a Color3 linearly
  85666. * @param startValue Start value of the animation curve
  85667. * @param endValue End value of the animation curve
  85668. * @param gradient Scalar amount to interpolate
  85669. * @returns Interpolated Color3 value
  85670. */
  85671. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85672. /**
  85673. * @hidden Internal use only
  85674. */
  85675. _getKeyValue(value: any): any;
  85676. /**
  85677. * @hidden Internal use only
  85678. */
  85679. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85680. /**
  85681. * Defines the function to use to interpolate matrices
  85682. * @param startValue defines the start matrix
  85683. * @param endValue defines the end matrix
  85684. * @param gradient defines the gradient between both matrices
  85685. * @param result defines an optional target matrix where to store the interpolation
  85686. * @returns the interpolated matrix
  85687. */
  85688. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85689. /**
  85690. * Makes a copy of the animation
  85691. * @returns Cloned animation
  85692. */
  85693. clone(): Animation;
  85694. /**
  85695. * Sets the key frames of the animation
  85696. * @param values The animation key frames to set
  85697. */
  85698. setKeys(values: Array<IAnimationKey>): void;
  85699. /**
  85700. * Serializes the animation to an object
  85701. * @returns Serialized object
  85702. */
  85703. serialize(): any;
  85704. /**
  85705. * Float animation type
  85706. */
  85707. private static _ANIMATIONTYPE_FLOAT;
  85708. /**
  85709. * Vector3 animation type
  85710. */
  85711. private static _ANIMATIONTYPE_VECTOR3;
  85712. /**
  85713. * Quaternion animation type
  85714. */
  85715. private static _ANIMATIONTYPE_QUATERNION;
  85716. /**
  85717. * Matrix animation type
  85718. */
  85719. private static _ANIMATIONTYPE_MATRIX;
  85720. /**
  85721. * Color3 animation type
  85722. */
  85723. private static _ANIMATIONTYPE_COLOR3;
  85724. /**
  85725. * Vector2 animation type
  85726. */
  85727. private static _ANIMATIONTYPE_VECTOR2;
  85728. /**
  85729. * Size animation type
  85730. */
  85731. private static _ANIMATIONTYPE_SIZE;
  85732. /**
  85733. * Relative Loop Mode
  85734. */
  85735. private static _ANIMATIONLOOPMODE_RELATIVE;
  85736. /**
  85737. * Cycle Loop Mode
  85738. */
  85739. private static _ANIMATIONLOOPMODE_CYCLE;
  85740. /**
  85741. * Constant Loop Mode
  85742. */
  85743. private static _ANIMATIONLOOPMODE_CONSTANT;
  85744. /**
  85745. * Get the float animation type
  85746. */
  85747. static readonly ANIMATIONTYPE_FLOAT: number;
  85748. /**
  85749. * Get the Vector3 animation type
  85750. */
  85751. static readonly ANIMATIONTYPE_VECTOR3: number;
  85752. /**
  85753. * Get the Vector2 animation type
  85754. */
  85755. static readonly ANIMATIONTYPE_VECTOR2: number;
  85756. /**
  85757. * Get the Size animation type
  85758. */
  85759. static readonly ANIMATIONTYPE_SIZE: number;
  85760. /**
  85761. * Get the Quaternion animation type
  85762. */
  85763. static readonly ANIMATIONTYPE_QUATERNION: number;
  85764. /**
  85765. * Get the Matrix animation type
  85766. */
  85767. static readonly ANIMATIONTYPE_MATRIX: number;
  85768. /**
  85769. * Get the Color3 animation type
  85770. */
  85771. static readonly ANIMATIONTYPE_COLOR3: number;
  85772. /**
  85773. * Get the Relative Loop Mode
  85774. */
  85775. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85776. /**
  85777. * Get the Cycle Loop Mode
  85778. */
  85779. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85780. /**
  85781. * Get the Constant Loop Mode
  85782. */
  85783. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85784. /** @hidden */
  85785. static _UniversalLerp(left: any, right: any, amount: number): any;
  85786. /**
  85787. * Parses an animation object and creates an animation
  85788. * @param parsedAnimation Parsed animation object
  85789. * @returns Animation object
  85790. */
  85791. static Parse(parsedAnimation: any): Animation;
  85792. /**
  85793. * Appends the serialized animations from the source animations
  85794. * @param source Source containing the animations
  85795. * @param destination Target to store the animations
  85796. */
  85797. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85798. }
  85799. }
  85800. declare module BABYLON {
  85801. /**
  85802. * Base class of all the textures in babylon.
  85803. * It groups all the common properties the materials, post process, lights... might need
  85804. * in order to make a correct use of the texture.
  85805. */
  85806. export class BaseTexture implements IAnimatable {
  85807. /**
  85808. * Default anisotropic filtering level for the application.
  85809. * It is set to 4 as a good tradeoff between perf and quality.
  85810. */
  85811. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85812. /**
  85813. * Gets or sets the unique id of the texture
  85814. */
  85815. uniqueId: number;
  85816. /**
  85817. * Define the name of the texture.
  85818. */
  85819. name: string;
  85820. /**
  85821. * Gets or sets an object used to store user defined information.
  85822. */
  85823. metadata: any;
  85824. /**
  85825. * For internal use only. Please do not use.
  85826. */
  85827. reservedDataStore: any;
  85828. private _hasAlpha;
  85829. /**
  85830. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85831. */
  85832. hasAlpha: boolean;
  85833. /**
  85834. * Defines if the alpha value should be determined via the rgb values.
  85835. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85836. */
  85837. getAlphaFromRGB: boolean;
  85838. /**
  85839. * Intensity or strength of the texture.
  85840. * It is commonly used by materials to fine tune the intensity of the texture
  85841. */
  85842. level: number;
  85843. /**
  85844. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85845. * This is part of the texture as textures usually maps to one uv set.
  85846. */
  85847. coordinatesIndex: number;
  85848. private _coordinatesMode;
  85849. /**
  85850. * How a texture is mapped.
  85851. *
  85852. * | Value | Type | Description |
  85853. * | ----- | ----------------------------------- | ----------- |
  85854. * | 0 | EXPLICIT_MODE | |
  85855. * | 1 | SPHERICAL_MODE | |
  85856. * | 2 | PLANAR_MODE | |
  85857. * | 3 | CUBIC_MODE | |
  85858. * | 4 | PROJECTION_MODE | |
  85859. * | 5 | SKYBOX_MODE | |
  85860. * | 6 | INVCUBIC_MODE | |
  85861. * | 7 | EQUIRECTANGULAR_MODE | |
  85862. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85863. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85864. */
  85865. coordinatesMode: number;
  85866. /**
  85867. * | Value | Type | Description |
  85868. * | ----- | ------------------ | ----------- |
  85869. * | 0 | CLAMP_ADDRESSMODE | |
  85870. * | 1 | WRAP_ADDRESSMODE | |
  85871. * | 2 | MIRROR_ADDRESSMODE | |
  85872. */
  85873. wrapU: number;
  85874. /**
  85875. * | Value | Type | Description |
  85876. * | ----- | ------------------ | ----------- |
  85877. * | 0 | CLAMP_ADDRESSMODE | |
  85878. * | 1 | WRAP_ADDRESSMODE | |
  85879. * | 2 | MIRROR_ADDRESSMODE | |
  85880. */
  85881. wrapV: number;
  85882. /**
  85883. * | Value | Type | Description |
  85884. * | ----- | ------------------ | ----------- |
  85885. * | 0 | CLAMP_ADDRESSMODE | |
  85886. * | 1 | WRAP_ADDRESSMODE | |
  85887. * | 2 | MIRROR_ADDRESSMODE | |
  85888. */
  85889. wrapR: number;
  85890. /**
  85891. * With compliant hardware and browser (supporting anisotropic filtering)
  85892. * this defines the level of anisotropic filtering in the texture.
  85893. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85894. */
  85895. anisotropicFilteringLevel: number;
  85896. /**
  85897. * Define if the texture is a cube texture or if false a 2d texture.
  85898. */
  85899. isCube: boolean;
  85900. /**
  85901. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85902. */
  85903. is3D: boolean;
  85904. /**
  85905. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85906. * HDR texture are usually stored in linear space.
  85907. * This only impacts the PBR and Background materials
  85908. */
  85909. gammaSpace: boolean;
  85910. /**
  85911. * Gets whether or not the texture contains RGBD data.
  85912. */
  85913. readonly isRGBD: boolean;
  85914. /**
  85915. * Is Z inverted in the texture (useful in a cube texture).
  85916. */
  85917. invertZ: boolean;
  85918. /**
  85919. * Are mip maps generated for this texture or not.
  85920. */
  85921. readonly noMipmap: boolean;
  85922. /**
  85923. * @hidden
  85924. */
  85925. lodLevelInAlpha: boolean;
  85926. /**
  85927. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85928. */
  85929. lodGenerationOffset: number;
  85930. /**
  85931. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85932. */
  85933. lodGenerationScale: number;
  85934. /**
  85935. * Define if the texture is a render target.
  85936. */
  85937. isRenderTarget: boolean;
  85938. /**
  85939. * Define the unique id of the texture in the scene.
  85940. */
  85941. readonly uid: string;
  85942. /**
  85943. * Return a string representation of the texture.
  85944. * @returns the texture as a string
  85945. */
  85946. toString(): string;
  85947. /**
  85948. * Get the class name of the texture.
  85949. * @returns "BaseTexture"
  85950. */
  85951. getClassName(): string;
  85952. /**
  85953. * Define the list of animation attached to the texture.
  85954. */
  85955. animations: Animation[];
  85956. /**
  85957. * An event triggered when the texture is disposed.
  85958. */
  85959. onDisposeObservable: Observable<BaseTexture>;
  85960. private _onDisposeObserver;
  85961. /**
  85962. * Callback triggered when the texture has been disposed.
  85963. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85964. */
  85965. onDispose: () => void;
  85966. /**
  85967. * Define the current state of the loading sequence when in delayed load mode.
  85968. */
  85969. delayLoadState: number;
  85970. private _scene;
  85971. /** @hidden */
  85972. _texture: Nullable<InternalTexture>;
  85973. private _uid;
  85974. /**
  85975. * Define if the texture is preventinga material to render or not.
  85976. * If not and the texture is not ready, the engine will use a default black texture instead.
  85977. */
  85978. readonly isBlocking: boolean;
  85979. /**
  85980. * Instantiates a new BaseTexture.
  85981. * Base class of all the textures in babylon.
  85982. * It groups all the common properties the materials, post process, lights... might need
  85983. * in order to make a correct use of the texture.
  85984. * @param scene Define the scene the texture blongs to
  85985. */
  85986. constructor(scene: Nullable<Scene>);
  85987. /**
  85988. * Get the scene the texture belongs to.
  85989. * @returns the scene or null if undefined
  85990. */
  85991. getScene(): Nullable<Scene>;
  85992. /**
  85993. * Get the texture transform matrix used to offset tile the texture for istance.
  85994. * @returns the transformation matrix
  85995. */
  85996. getTextureMatrix(): Matrix;
  85997. /**
  85998. * Get the texture reflection matrix used to rotate/transform the reflection.
  85999. * @returns the reflection matrix
  86000. */
  86001. getReflectionTextureMatrix(): Matrix;
  86002. /**
  86003. * Get the underlying lower level texture from Babylon.
  86004. * @returns the insternal texture
  86005. */
  86006. getInternalTexture(): Nullable<InternalTexture>;
  86007. /**
  86008. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86009. * @returns true if ready or not blocking
  86010. */
  86011. isReadyOrNotBlocking(): boolean;
  86012. /**
  86013. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86014. * @returns true if fully ready
  86015. */
  86016. isReady(): boolean;
  86017. private _cachedSize;
  86018. /**
  86019. * Get the size of the texture.
  86020. * @returns the texture size.
  86021. */
  86022. getSize(): ISize;
  86023. /**
  86024. * Get the base size of the texture.
  86025. * It can be different from the size if the texture has been resized for POT for instance
  86026. * @returns the base size
  86027. */
  86028. getBaseSize(): ISize;
  86029. /**
  86030. * Update the sampling mode of the texture.
  86031. * Default is Trilinear mode.
  86032. *
  86033. * | Value | Type | Description |
  86034. * | ----- | ------------------ | ----------- |
  86035. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86036. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86037. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86038. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86039. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86040. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86041. * | 7 | NEAREST_LINEAR | |
  86042. * | 8 | NEAREST_NEAREST | |
  86043. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86044. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86045. * | 11 | LINEAR_LINEAR | |
  86046. * | 12 | LINEAR_NEAREST | |
  86047. *
  86048. * > _mag_: magnification filter (close to the viewer)
  86049. * > _min_: minification filter (far from the viewer)
  86050. * > _mip_: filter used between mip map levels
  86051. *@param samplingMode Define the new sampling mode of the texture
  86052. */
  86053. updateSamplingMode(samplingMode: number): void;
  86054. /**
  86055. * Scales the texture if is `canRescale()`
  86056. * @param ratio the resize factor we want to use to rescale
  86057. */
  86058. scale(ratio: number): void;
  86059. /**
  86060. * Get if the texture can rescale.
  86061. */
  86062. readonly canRescale: boolean;
  86063. /** @hidden */
  86064. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86065. /** @hidden */
  86066. _rebuild(): void;
  86067. /**
  86068. * Triggers the load sequence in delayed load mode.
  86069. */
  86070. delayLoad(): void;
  86071. /**
  86072. * Clones the texture.
  86073. * @returns the cloned texture
  86074. */
  86075. clone(): Nullable<BaseTexture>;
  86076. /**
  86077. * Get the texture underlying type (INT, FLOAT...)
  86078. */
  86079. readonly textureType: number;
  86080. /**
  86081. * Get the texture underlying format (RGB, RGBA...)
  86082. */
  86083. readonly textureFormat: number;
  86084. /**
  86085. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86086. * This will returns an RGBA array buffer containing either in values (0-255) or
  86087. * float values (0-1) depending of the underlying buffer type.
  86088. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86089. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86090. * @param buffer defines a user defined buffer to fill with data (can be null)
  86091. * @returns The Array buffer containing the pixels data.
  86092. */
  86093. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86094. /**
  86095. * Release and destroy the underlying lower level texture aka internalTexture.
  86096. */
  86097. releaseInternalTexture(): void;
  86098. /**
  86099. * Get the polynomial representation of the texture data.
  86100. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86101. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86102. */
  86103. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86104. /** @hidden */
  86105. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86106. /** @hidden */
  86107. readonly _lodTextureMid: Nullable<BaseTexture>;
  86108. /** @hidden */
  86109. readonly _lodTextureLow: Nullable<BaseTexture>;
  86110. /**
  86111. * Dispose the texture and release its associated resources.
  86112. */
  86113. dispose(): void;
  86114. /**
  86115. * Serialize the texture into a JSON representation that can be parsed later on.
  86116. * @returns the JSON representation of the texture
  86117. */
  86118. serialize(): any;
  86119. /**
  86120. * Helper function to be called back once a list of texture contains only ready textures.
  86121. * @param textures Define the list of textures to wait for
  86122. * @param callback Define the callback triggered once the entire list will be ready
  86123. */
  86124. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86125. }
  86126. }
  86127. declare module BABYLON {
  86128. /**
  86129. * Uniform buffer objects.
  86130. *
  86131. * Handles blocks of uniform on the GPU.
  86132. *
  86133. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86134. *
  86135. * For more information, please refer to :
  86136. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86137. */
  86138. export class UniformBuffer {
  86139. private _engine;
  86140. private _buffer;
  86141. private _data;
  86142. private _bufferData;
  86143. private _dynamic?;
  86144. private _uniformLocations;
  86145. private _uniformSizes;
  86146. private _uniformLocationPointer;
  86147. private _needSync;
  86148. private _noUBO;
  86149. private _currentEffect;
  86150. private static _MAX_UNIFORM_SIZE;
  86151. private static _tempBuffer;
  86152. /**
  86153. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86154. * This is dynamic to allow compat with webgl 1 and 2.
  86155. * You will need to pass the name of the uniform as well as the value.
  86156. */
  86157. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86158. /**
  86159. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86160. * This is dynamic to allow compat with webgl 1 and 2.
  86161. * You will need to pass the name of the uniform as well as the value.
  86162. */
  86163. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86164. /**
  86165. * Lambda to Update a single float in a uniform buffer.
  86166. * This is dynamic to allow compat with webgl 1 and 2.
  86167. * You will need to pass the name of the uniform as well as the value.
  86168. */
  86169. updateFloat: (name: string, x: number) => void;
  86170. /**
  86171. * Lambda to Update a vec2 of float in a uniform buffer.
  86172. * This is dynamic to allow compat with webgl 1 and 2.
  86173. * You will need to pass the name of the uniform as well as the value.
  86174. */
  86175. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86176. /**
  86177. * Lambda to Update a vec3 of float in a uniform buffer.
  86178. * This is dynamic to allow compat with webgl 1 and 2.
  86179. * You will need to pass the name of the uniform as well as the value.
  86180. */
  86181. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86182. /**
  86183. * Lambda to Update a vec4 of float in a uniform buffer.
  86184. * This is dynamic to allow compat with webgl 1 and 2.
  86185. * You will need to pass the name of the uniform as well as the value.
  86186. */
  86187. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86188. /**
  86189. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86190. * This is dynamic to allow compat with webgl 1 and 2.
  86191. * You will need to pass the name of the uniform as well as the value.
  86192. */
  86193. updateMatrix: (name: string, mat: Matrix) => void;
  86194. /**
  86195. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86196. * This is dynamic to allow compat with webgl 1 and 2.
  86197. * You will need to pass the name of the uniform as well as the value.
  86198. */
  86199. updateVector3: (name: string, vector: Vector3) => void;
  86200. /**
  86201. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86202. * This is dynamic to allow compat with webgl 1 and 2.
  86203. * You will need to pass the name of the uniform as well as the value.
  86204. */
  86205. updateVector4: (name: string, vector: Vector4) => void;
  86206. /**
  86207. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86208. * This is dynamic to allow compat with webgl 1 and 2.
  86209. * You will need to pass the name of the uniform as well as the value.
  86210. */
  86211. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86212. /**
  86213. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86214. * This is dynamic to allow compat with webgl 1 and 2.
  86215. * You will need to pass the name of the uniform as well as the value.
  86216. */
  86217. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86218. /**
  86219. * Instantiates a new Uniform buffer objects.
  86220. *
  86221. * Handles blocks of uniform on the GPU.
  86222. *
  86223. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86224. *
  86225. * For more information, please refer to :
  86226. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86227. * @param engine Define the engine the buffer is associated with
  86228. * @param data Define the data contained in the buffer
  86229. * @param dynamic Define if the buffer is updatable
  86230. */
  86231. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86232. /**
  86233. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86234. * or just falling back on setUniformXXX calls.
  86235. */
  86236. readonly useUbo: boolean;
  86237. /**
  86238. * Indicates if the WebGL underlying uniform buffer is in sync
  86239. * with the javascript cache data.
  86240. */
  86241. readonly isSync: boolean;
  86242. /**
  86243. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86244. * Also, a dynamic UniformBuffer will disable cache verification and always
  86245. * update the underlying WebGL uniform buffer to the GPU.
  86246. * @returns if Dynamic, otherwise false
  86247. */
  86248. isDynamic(): boolean;
  86249. /**
  86250. * The data cache on JS side.
  86251. * @returns the underlying data as a float array
  86252. */
  86253. getData(): Float32Array;
  86254. /**
  86255. * The underlying WebGL Uniform buffer.
  86256. * @returns the webgl buffer
  86257. */
  86258. getBuffer(): Nullable<DataBuffer>;
  86259. /**
  86260. * std140 layout specifies how to align data within an UBO structure.
  86261. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86262. * for specs.
  86263. */
  86264. private _fillAlignment;
  86265. /**
  86266. * Adds an uniform in the buffer.
  86267. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86268. * for the layout to be correct !
  86269. * @param name Name of the uniform, as used in the uniform block in the shader.
  86270. * @param size Data size, or data directly.
  86271. */
  86272. addUniform(name: string, size: number | number[]): void;
  86273. /**
  86274. * Adds a Matrix 4x4 to the uniform buffer.
  86275. * @param name Name of the uniform, as used in the uniform block in the shader.
  86276. * @param mat A 4x4 matrix.
  86277. */
  86278. addMatrix(name: string, mat: Matrix): void;
  86279. /**
  86280. * Adds a vec2 to the uniform buffer.
  86281. * @param name Name of the uniform, as used in the uniform block in the shader.
  86282. * @param x Define the x component value of the vec2
  86283. * @param y Define the y component value of the vec2
  86284. */
  86285. addFloat2(name: string, x: number, y: number): void;
  86286. /**
  86287. * Adds a vec3 to the uniform buffer.
  86288. * @param name Name of the uniform, as used in the uniform block in the shader.
  86289. * @param x Define the x component value of the vec3
  86290. * @param y Define the y component value of the vec3
  86291. * @param z Define the z component value of the vec3
  86292. */
  86293. addFloat3(name: string, x: number, y: number, z: number): void;
  86294. /**
  86295. * Adds a vec3 to the uniform buffer.
  86296. * @param name Name of the uniform, as used in the uniform block in the shader.
  86297. * @param color Define the vec3 from a Color
  86298. */
  86299. addColor3(name: string, color: Color3): void;
  86300. /**
  86301. * Adds a vec4 to the uniform buffer.
  86302. * @param name Name of the uniform, as used in the uniform block in the shader.
  86303. * @param color Define the rgb components from a Color
  86304. * @param alpha Define the a component of the vec4
  86305. */
  86306. addColor4(name: string, color: Color3, alpha: number): void;
  86307. /**
  86308. * Adds a vec3 to the uniform buffer.
  86309. * @param name Name of the uniform, as used in the uniform block in the shader.
  86310. * @param vector Define the vec3 components from a Vector
  86311. */
  86312. addVector3(name: string, vector: Vector3): void;
  86313. /**
  86314. * Adds a Matrix 3x3 to the uniform buffer.
  86315. * @param name Name of the uniform, as used in the uniform block in the shader.
  86316. */
  86317. addMatrix3x3(name: string): void;
  86318. /**
  86319. * Adds a Matrix 2x2 to the uniform buffer.
  86320. * @param name Name of the uniform, as used in the uniform block in the shader.
  86321. */
  86322. addMatrix2x2(name: string): void;
  86323. /**
  86324. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86325. */
  86326. create(): void;
  86327. /** @hidden */
  86328. _rebuild(): void;
  86329. /**
  86330. * Updates the WebGL Uniform Buffer on the GPU.
  86331. * If the `dynamic` flag is set to true, no cache comparison is done.
  86332. * Otherwise, the buffer will be updated only if the cache differs.
  86333. */
  86334. update(): void;
  86335. /**
  86336. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86337. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86338. * @param data Define the flattened data
  86339. * @param size Define the size of the data.
  86340. */
  86341. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86342. private _updateMatrix3x3ForUniform;
  86343. private _updateMatrix3x3ForEffect;
  86344. private _updateMatrix2x2ForEffect;
  86345. private _updateMatrix2x2ForUniform;
  86346. private _updateFloatForEffect;
  86347. private _updateFloatForUniform;
  86348. private _updateFloat2ForEffect;
  86349. private _updateFloat2ForUniform;
  86350. private _updateFloat3ForEffect;
  86351. private _updateFloat3ForUniform;
  86352. private _updateFloat4ForEffect;
  86353. private _updateFloat4ForUniform;
  86354. private _updateMatrixForEffect;
  86355. private _updateMatrixForUniform;
  86356. private _updateVector3ForEffect;
  86357. private _updateVector3ForUniform;
  86358. private _updateVector4ForEffect;
  86359. private _updateVector4ForUniform;
  86360. private _updateColor3ForEffect;
  86361. private _updateColor3ForUniform;
  86362. private _updateColor4ForEffect;
  86363. private _updateColor4ForUniform;
  86364. /**
  86365. * Sets a sampler uniform on the effect.
  86366. * @param name Define the name of the sampler.
  86367. * @param texture Define the texture to set in the sampler
  86368. */
  86369. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86370. /**
  86371. * Directly updates the value of the uniform in the cache AND on the GPU.
  86372. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86373. * @param data Define the flattened data
  86374. */
  86375. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86376. /**
  86377. * Binds this uniform buffer to an effect.
  86378. * @param effect Define the effect to bind the buffer to
  86379. * @param name Name of the uniform block in the shader.
  86380. */
  86381. bindToEffect(effect: Effect, name: string): void;
  86382. /**
  86383. * Disposes the uniform buffer.
  86384. */
  86385. dispose(): void;
  86386. }
  86387. }
  86388. declare module BABYLON {
  86389. /**
  86390. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86392. */
  86393. export class Analyser {
  86394. /**
  86395. * Gets or sets the smoothing
  86396. * @ignorenaming
  86397. */
  86398. SMOOTHING: number;
  86399. /**
  86400. * Gets or sets the FFT table size
  86401. * @ignorenaming
  86402. */
  86403. FFT_SIZE: number;
  86404. /**
  86405. * Gets or sets the bar graph amplitude
  86406. * @ignorenaming
  86407. */
  86408. BARGRAPHAMPLITUDE: number;
  86409. /**
  86410. * Gets or sets the position of the debug canvas
  86411. * @ignorenaming
  86412. */
  86413. DEBUGCANVASPOS: {
  86414. x: number;
  86415. y: number;
  86416. };
  86417. /**
  86418. * Gets or sets the debug canvas size
  86419. * @ignorenaming
  86420. */
  86421. DEBUGCANVASSIZE: {
  86422. width: number;
  86423. height: number;
  86424. };
  86425. private _byteFreqs;
  86426. private _byteTime;
  86427. private _floatFreqs;
  86428. private _webAudioAnalyser;
  86429. private _debugCanvas;
  86430. private _debugCanvasContext;
  86431. private _scene;
  86432. private _registerFunc;
  86433. private _audioEngine;
  86434. /**
  86435. * Creates a new analyser
  86436. * @param scene defines hosting scene
  86437. */
  86438. constructor(scene: Scene);
  86439. /**
  86440. * Get the number of data values you will have to play with for the visualization
  86441. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86442. * @returns a number
  86443. */
  86444. getFrequencyBinCount(): number;
  86445. /**
  86446. * Gets the current frequency data as a byte array
  86447. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86448. * @returns a Uint8Array
  86449. */
  86450. getByteFrequencyData(): Uint8Array;
  86451. /**
  86452. * Gets the current waveform as a byte array
  86453. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86454. * @returns a Uint8Array
  86455. */
  86456. getByteTimeDomainData(): Uint8Array;
  86457. /**
  86458. * Gets the current frequency data as a float array
  86459. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86460. * @returns a Float32Array
  86461. */
  86462. getFloatFrequencyData(): Float32Array;
  86463. /**
  86464. * Renders the debug canvas
  86465. */
  86466. drawDebugCanvas(): void;
  86467. /**
  86468. * Stops rendering the debug canvas and removes it
  86469. */
  86470. stopDebugCanvas(): void;
  86471. /**
  86472. * Connects two audio nodes
  86473. * @param inputAudioNode defines first node to connect
  86474. * @param outputAudioNode defines second node to connect
  86475. */
  86476. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86477. /**
  86478. * Releases all associated resources
  86479. */
  86480. dispose(): void;
  86481. }
  86482. }
  86483. declare module BABYLON {
  86484. /**
  86485. * This represents an audio engine and it is responsible
  86486. * to play, synchronize and analyse sounds throughout the application.
  86487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86488. */
  86489. export interface IAudioEngine extends IDisposable {
  86490. /**
  86491. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86492. */
  86493. readonly canUseWebAudio: boolean;
  86494. /**
  86495. * Gets the current AudioContext if available.
  86496. */
  86497. readonly audioContext: Nullable<AudioContext>;
  86498. /**
  86499. * The master gain node defines the global audio volume of your audio engine.
  86500. */
  86501. readonly masterGain: GainNode;
  86502. /**
  86503. * Gets whether or not mp3 are supported by your browser.
  86504. */
  86505. readonly isMP3supported: boolean;
  86506. /**
  86507. * Gets whether or not ogg are supported by your browser.
  86508. */
  86509. readonly isOGGsupported: boolean;
  86510. /**
  86511. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86512. * @ignoreNaming
  86513. */
  86514. WarnedWebAudioUnsupported: boolean;
  86515. /**
  86516. * Defines if the audio engine relies on a custom unlocked button.
  86517. * In this case, the embedded button will not be displayed.
  86518. */
  86519. useCustomUnlockedButton: boolean;
  86520. /**
  86521. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86522. */
  86523. readonly unlocked: boolean;
  86524. /**
  86525. * Event raised when audio has been unlocked on the browser.
  86526. */
  86527. onAudioUnlockedObservable: Observable<AudioEngine>;
  86528. /**
  86529. * Event raised when audio has been locked on the browser.
  86530. */
  86531. onAudioLockedObservable: Observable<AudioEngine>;
  86532. /**
  86533. * Flags the audio engine in Locked state.
  86534. * This happens due to new browser policies preventing audio to autoplay.
  86535. */
  86536. lock(): void;
  86537. /**
  86538. * Unlocks the audio engine once a user action has been done on the dom.
  86539. * This is helpful to resume play once browser policies have been satisfied.
  86540. */
  86541. unlock(): void;
  86542. }
  86543. /**
  86544. * This represents the default audio engine used in babylon.
  86545. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86547. */
  86548. export class AudioEngine implements IAudioEngine {
  86549. private _audioContext;
  86550. private _audioContextInitialized;
  86551. private _muteButton;
  86552. private _hostElement;
  86553. /**
  86554. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86555. */
  86556. canUseWebAudio: boolean;
  86557. /**
  86558. * The master gain node defines the global audio volume of your audio engine.
  86559. */
  86560. masterGain: GainNode;
  86561. /**
  86562. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86563. * @ignoreNaming
  86564. */
  86565. WarnedWebAudioUnsupported: boolean;
  86566. /**
  86567. * Gets whether or not mp3 are supported by your browser.
  86568. */
  86569. isMP3supported: boolean;
  86570. /**
  86571. * Gets whether or not ogg are supported by your browser.
  86572. */
  86573. isOGGsupported: boolean;
  86574. /**
  86575. * Gets whether audio has been unlocked on the device.
  86576. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86577. * a user interaction has happened.
  86578. */
  86579. unlocked: boolean;
  86580. /**
  86581. * Defines if the audio engine relies on a custom unlocked button.
  86582. * In this case, the embedded button will not be displayed.
  86583. */
  86584. useCustomUnlockedButton: boolean;
  86585. /**
  86586. * Event raised when audio has been unlocked on the browser.
  86587. */
  86588. onAudioUnlockedObservable: Observable<AudioEngine>;
  86589. /**
  86590. * Event raised when audio has been locked on the browser.
  86591. */
  86592. onAudioLockedObservable: Observable<AudioEngine>;
  86593. /**
  86594. * Gets the current AudioContext if available.
  86595. */
  86596. readonly audioContext: Nullable<AudioContext>;
  86597. private _connectedAnalyser;
  86598. /**
  86599. * Instantiates a new audio engine.
  86600. *
  86601. * There should be only one per page as some browsers restrict the number
  86602. * of audio contexts you can create.
  86603. * @param hostElement defines the host element where to display the mute icon if necessary
  86604. */
  86605. constructor(hostElement?: Nullable<HTMLElement>);
  86606. /**
  86607. * Flags the audio engine in Locked state.
  86608. * This happens due to new browser policies preventing audio to autoplay.
  86609. */
  86610. lock(): void;
  86611. /**
  86612. * Unlocks the audio engine once a user action has been done on the dom.
  86613. * This is helpful to resume play once browser policies have been satisfied.
  86614. */
  86615. unlock(): void;
  86616. private _resumeAudioContext;
  86617. private _initializeAudioContext;
  86618. private _tryToRun;
  86619. private _triggerRunningState;
  86620. private _triggerSuspendedState;
  86621. private _displayMuteButton;
  86622. private _moveButtonToTopLeft;
  86623. private _onResize;
  86624. private _hideMuteButton;
  86625. /**
  86626. * Destroy and release the resources associated with the audio ccontext.
  86627. */
  86628. dispose(): void;
  86629. /**
  86630. * Gets the global volume sets on the master gain.
  86631. * @returns the global volume if set or -1 otherwise
  86632. */
  86633. getGlobalVolume(): number;
  86634. /**
  86635. * Sets the global volume of your experience (sets on the master gain).
  86636. * @param newVolume Defines the new global volume of the application
  86637. */
  86638. setGlobalVolume(newVolume: number): void;
  86639. /**
  86640. * Connect the audio engine to an audio analyser allowing some amazing
  86641. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86643. * @param analyser The analyser to connect to the engine
  86644. */
  86645. connectToAnalyser(analyser: Analyser): void;
  86646. }
  86647. }
  86648. declare module BABYLON {
  86649. /**
  86650. * Interface used to present a loading screen while loading a scene
  86651. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86652. */
  86653. export interface ILoadingScreen {
  86654. /**
  86655. * Function called to display the loading screen
  86656. */
  86657. displayLoadingUI: () => void;
  86658. /**
  86659. * Function called to hide the loading screen
  86660. */
  86661. hideLoadingUI: () => void;
  86662. /**
  86663. * Gets or sets the color to use for the background
  86664. */
  86665. loadingUIBackgroundColor: string;
  86666. /**
  86667. * Gets or sets the text to display while loading
  86668. */
  86669. loadingUIText: string;
  86670. }
  86671. /**
  86672. * Class used for the default loading screen
  86673. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86674. */
  86675. export class DefaultLoadingScreen implements ILoadingScreen {
  86676. private _renderingCanvas;
  86677. private _loadingText;
  86678. private _loadingDivBackgroundColor;
  86679. private _loadingDiv;
  86680. private _loadingTextDiv;
  86681. /**
  86682. * Creates a new default loading screen
  86683. * @param _renderingCanvas defines the canvas used to render the scene
  86684. * @param _loadingText defines the default text to display
  86685. * @param _loadingDivBackgroundColor defines the default background color
  86686. */
  86687. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86688. /**
  86689. * Function called to display the loading screen
  86690. */
  86691. displayLoadingUI(): void;
  86692. /**
  86693. * Function called to hide the loading screen
  86694. */
  86695. hideLoadingUI(): void;
  86696. /**
  86697. * Gets or sets the text to display while loading
  86698. */
  86699. loadingUIText: string;
  86700. /**
  86701. * Gets or sets the color to use for the background
  86702. */
  86703. loadingUIBackgroundColor: string;
  86704. private _resizeLoadingUI;
  86705. }
  86706. }
  86707. declare module BABYLON {
  86708. /** @hidden */
  86709. export class WebGLPipelineContext implements IPipelineContext {
  86710. engine: Engine;
  86711. program: Nullable<WebGLProgram>;
  86712. context?: WebGLRenderingContext;
  86713. vertexShader?: WebGLShader;
  86714. fragmentShader?: WebGLShader;
  86715. isParallelCompiled: boolean;
  86716. onCompiled?: () => void;
  86717. transformFeedback?: WebGLTransformFeedback | null;
  86718. readonly isAsync: boolean;
  86719. readonly isReady: boolean;
  86720. }
  86721. }
  86722. declare module BABYLON {
  86723. /** @hidden */
  86724. export class WebGLDataBuffer extends DataBuffer {
  86725. private _buffer;
  86726. constructor(resource: WebGLBuffer);
  86727. readonly underlyingResource: any;
  86728. }
  86729. }
  86730. declare module BABYLON {
  86731. /**
  86732. * Settings for finer control over video usage
  86733. */
  86734. export interface VideoTextureSettings {
  86735. /**
  86736. * Applies `autoplay` to video, if specified
  86737. */
  86738. autoPlay?: boolean;
  86739. /**
  86740. * Applies `loop` to video, if specified
  86741. */
  86742. loop?: boolean;
  86743. /**
  86744. * Automatically updates internal texture from video at every frame in the render loop
  86745. */
  86746. autoUpdateTexture: boolean;
  86747. /**
  86748. * Image src displayed during the video loading or until the user interacts with the video.
  86749. */
  86750. poster?: string;
  86751. }
  86752. /**
  86753. * If you want to display a video in your scene, this is the special texture for that.
  86754. * This special texture works similar to other textures, with the exception of a few parameters.
  86755. * @see https://doc.babylonjs.com/how_to/video_texture
  86756. */
  86757. export class VideoTexture extends Texture {
  86758. /**
  86759. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86760. */
  86761. readonly autoUpdateTexture: boolean;
  86762. /**
  86763. * The video instance used by the texture internally
  86764. */
  86765. readonly video: HTMLVideoElement;
  86766. private _onUserActionRequestedObservable;
  86767. /**
  86768. * Event triggerd when a dom action is required by the user to play the video.
  86769. * This happens due to recent changes in browser policies preventing video to auto start.
  86770. */
  86771. readonly onUserActionRequestedObservable: Observable<Texture>;
  86772. private _generateMipMaps;
  86773. private _engine;
  86774. private _stillImageCaptured;
  86775. private _displayingPosterTexture;
  86776. private _settings;
  86777. private _createInternalTextureOnEvent;
  86778. /**
  86779. * Creates a video texture.
  86780. * If you want to display a video in your scene, this is the special texture for that.
  86781. * This special texture works similar to other textures, with the exception of a few parameters.
  86782. * @see https://doc.babylonjs.com/how_to/video_texture
  86783. * @param name optional name, will detect from video source, if not defined
  86784. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86785. * @param scene is obviously the current scene.
  86786. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86787. * @param invertY is false by default but can be used to invert video on Y axis
  86788. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86789. * @param settings allows finer control over video usage
  86790. */
  86791. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86792. private _getName;
  86793. private _getVideo;
  86794. private _createInternalTexture;
  86795. private reset;
  86796. /**
  86797. * @hidden Internal method to initiate `update`.
  86798. */
  86799. _rebuild(): void;
  86800. /**
  86801. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86802. */
  86803. update(): void;
  86804. /**
  86805. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86806. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86807. */
  86808. updateTexture(isVisible: boolean): void;
  86809. protected _updateInternalTexture: () => void;
  86810. /**
  86811. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86812. * @param url New url.
  86813. */
  86814. updateURL(url: string): void;
  86815. /**
  86816. * Dispose the texture and release its associated resources.
  86817. */
  86818. dispose(): void;
  86819. /**
  86820. * Creates a video texture straight from a stream.
  86821. * @param scene Define the scene the texture should be created in
  86822. * @param stream Define the stream the texture should be created from
  86823. * @returns The created video texture as a promise
  86824. */
  86825. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86826. /**
  86827. * Creates a video texture straight from your WebCam video feed.
  86828. * @param scene Define the scene the texture should be created in
  86829. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86830. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86831. * @returns The created video texture as a promise
  86832. */
  86833. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86834. minWidth: number;
  86835. maxWidth: number;
  86836. minHeight: number;
  86837. maxHeight: number;
  86838. deviceId: string;
  86839. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86840. /**
  86841. * Creates a video texture straight from your WebCam video feed.
  86842. * @param scene Define the scene the texture should be created in
  86843. * @param onReady Define a callback to triggered once the texture will be ready
  86844. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86845. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86846. */
  86847. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86848. minWidth: number;
  86849. maxWidth: number;
  86850. minHeight: number;
  86851. maxHeight: number;
  86852. deviceId: string;
  86853. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86854. }
  86855. }
  86856. declare module BABYLON {
  86857. /**
  86858. * Interface for attribute information associated with buffer instanciation
  86859. */
  86860. export class InstancingAttributeInfo {
  86861. /**
  86862. * Index/offset of the attribute in the vertex shader
  86863. */
  86864. index: number;
  86865. /**
  86866. * size of the attribute, 1, 2, 3 or 4
  86867. */
  86868. attributeSize: number;
  86869. /**
  86870. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86871. * default is FLOAT
  86872. */
  86873. attribyteType: number;
  86874. /**
  86875. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86876. */
  86877. normalized: boolean;
  86878. /**
  86879. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86880. */
  86881. offset: number;
  86882. /**
  86883. * Name of the GLSL attribute, for debugging purpose only
  86884. */
  86885. attributeName: string;
  86886. }
  86887. /**
  86888. * Define options used to create a depth texture
  86889. */
  86890. export class DepthTextureCreationOptions {
  86891. /** Specifies whether or not a stencil should be allocated in the texture */
  86892. generateStencil?: boolean;
  86893. /** Specifies whether or not bilinear filtering is enable on the texture */
  86894. bilinearFiltering?: boolean;
  86895. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86896. comparisonFunction?: number;
  86897. /** Specifies if the created texture is a cube texture */
  86898. isCube?: boolean;
  86899. }
  86900. /**
  86901. * Class used to describe the capabilities of the engine relatively to the current browser
  86902. */
  86903. export class EngineCapabilities {
  86904. /** Maximum textures units per fragment shader */
  86905. maxTexturesImageUnits: number;
  86906. /** Maximum texture units per vertex shader */
  86907. maxVertexTextureImageUnits: number;
  86908. /** Maximum textures units in the entire pipeline */
  86909. maxCombinedTexturesImageUnits: number;
  86910. /** Maximum texture size */
  86911. maxTextureSize: number;
  86912. /** Maximum cube texture size */
  86913. maxCubemapTextureSize: number;
  86914. /** Maximum render texture size */
  86915. maxRenderTextureSize: number;
  86916. /** Maximum number of vertex attributes */
  86917. maxVertexAttribs: number;
  86918. /** Maximum number of varyings */
  86919. maxVaryingVectors: number;
  86920. /** Maximum number of uniforms per vertex shader */
  86921. maxVertexUniformVectors: number;
  86922. /** Maximum number of uniforms per fragment shader */
  86923. maxFragmentUniformVectors: number;
  86924. /** Defines if standard derivates (dx/dy) are supported */
  86925. standardDerivatives: boolean;
  86926. /** Defines if s3tc texture compression is supported */
  86927. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86928. /** Defines if pvrtc texture compression is supported */
  86929. pvrtc: any;
  86930. /** Defines if etc1 texture compression is supported */
  86931. etc1: any;
  86932. /** Defines if etc2 texture compression is supported */
  86933. etc2: any;
  86934. /** Defines if astc texture compression is supported */
  86935. astc: any;
  86936. /** Defines if float textures are supported */
  86937. textureFloat: boolean;
  86938. /** Defines if vertex array objects are supported */
  86939. vertexArrayObject: boolean;
  86940. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86941. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86942. /** Gets the maximum level of anisotropy supported */
  86943. maxAnisotropy: number;
  86944. /** Defines if instancing is supported */
  86945. instancedArrays: boolean;
  86946. /** Defines if 32 bits indices are supported */
  86947. uintIndices: boolean;
  86948. /** Defines if high precision shaders are supported */
  86949. highPrecisionShaderSupported: boolean;
  86950. /** Defines if depth reading in the fragment shader is supported */
  86951. fragmentDepthSupported: boolean;
  86952. /** Defines if float texture linear filtering is supported*/
  86953. textureFloatLinearFiltering: boolean;
  86954. /** Defines if rendering to float textures is supported */
  86955. textureFloatRender: boolean;
  86956. /** Defines if half float textures are supported*/
  86957. textureHalfFloat: boolean;
  86958. /** Defines if half float texture linear filtering is supported*/
  86959. textureHalfFloatLinearFiltering: boolean;
  86960. /** Defines if rendering to half float textures is supported */
  86961. textureHalfFloatRender: boolean;
  86962. /** Defines if textureLOD shader command is supported */
  86963. textureLOD: boolean;
  86964. /** Defines if draw buffers extension is supported */
  86965. drawBuffersExtension: boolean;
  86966. /** Defines if depth textures are supported */
  86967. depthTextureExtension: boolean;
  86968. /** Defines if float color buffer are supported */
  86969. colorBufferFloat: boolean;
  86970. /** Gets disjoint timer query extension (null if not supported) */
  86971. timerQuery: EXT_disjoint_timer_query;
  86972. /** Defines if timestamp can be used with timer query */
  86973. canUseTimestampForTimerQuery: boolean;
  86974. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86975. multiview: any;
  86976. /** Function used to let the system compiles shaders in background */
  86977. parallelShaderCompile: {
  86978. COMPLETION_STATUS_KHR: number;
  86979. };
  86980. }
  86981. /** Interface defining initialization parameters for Engine class */
  86982. export interface EngineOptions extends WebGLContextAttributes {
  86983. /**
  86984. * Defines if the engine should no exceed a specified device ratio
  86985. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86986. */
  86987. limitDeviceRatio?: number;
  86988. /**
  86989. * Defines if webvr should be enabled automatically
  86990. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86991. */
  86992. autoEnableWebVR?: boolean;
  86993. /**
  86994. * Defines if webgl2 should be turned off even if supported
  86995. * @see http://doc.babylonjs.com/features/webgl2
  86996. */
  86997. disableWebGL2Support?: boolean;
  86998. /**
  86999. * Defines if webaudio should be initialized as well
  87000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87001. */
  87002. audioEngine?: boolean;
  87003. /**
  87004. * Defines if animations should run using a deterministic lock step
  87005. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87006. */
  87007. deterministicLockstep?: boolean;
  87008. /** Defines the maximum steps to use with deterministic lock step mode */
  87009. lockstepMaxSteps?: number;
  87010. /**
  87011. * Defines that engine should ignore context lost events
  87012. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87013. */
  87014. doNotHandleContextLost?: boolean;
  87015. /**
  87016. * Defines that engine should ignore modifying touch action attribute and style
  87017. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87018. */
  87019. doNotHandleTouchAction?: boolean;
  87020. /**
  87021. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87022. */
  87023. useHighPrecisionFloats?: boolean;
  87024. }
  87025. /**
  87026. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87027. */
  87028. export class Engine {
  87029. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87030. static ExceptionList: ({
  87031. key: string;
  87032. capture: string;
  87033. captureConstraint: number;
  87034. targets: string[];
  87035. } | {
  87036. key: string;
  87037. capture: null;
  87038. captureConstraint: null;
  87039. targets: string[];
  87040. })[];
  87041. /** Gets the list of created engines */
  87042. static readonly Instances: Engine[];
  87043. /**
  87044. * Gets the latest created engine
  87045. */
  87046. static readonly LastCreatedEngine: Nullable<Engine>;
  87047. /**
  87048. * Gets the latest created scene
  87049. */
  87050. static readonly LastCreatedScene: Nullable<Scene>;
  87051. /**
  87052. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87053. * @param flag defines which part of the materials must be marked as dirty
  87054. * @param predicate defines a predicate used to filter which materials should be affected
  87055. */
  87056. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87057. /**
  87058. * Hidden
  87059. */
  87060. static _TextureLoaders: IInternalTextureLoader[];
  87061. /** Defines that alpha blending is disabled */
  87062. static readonly ALPHA_DISABLE: number;
  87063. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87064. static readonly ALPHA_ADD: number;
  87065. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87066. static readonly ALPHA_COMBINE: number;
  87067. /** Defines that alpha blending to DEST - SRC * DEST */
  87068. static readonly ALPHA_SUBTRACT: number;
  87069. /** Defines that alpha blending to SRC * DEST */
  87070. static readonly ALPHA_MULTIPLY: number;
  87071. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87072. static readonly ALPHA_MAXIMIZED: number;
  87073. /** Defines that alpha blending to SRC + DEST */
  87074. static readonly ALPHA_ONEONE: number;
  87075. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87076. static readonly ALPHA_PREMULTIPLIED: number;
  87077. /**
  87078. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87079. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87080. */
  87081. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87082. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87083. static readonly ALPHA_INTERPOLATE: number;
  87084. /**
  87085. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87086. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87087. */
  87088. static readonly ALPHA_SCREENMODE: number;
  87089. /** Defines that the ressource is not delayed*/
  87090. static readonly DELAYLOADSTATE_NONE: number;
  87091. /** Defines that the ressource was successfully delay loaded */
  87092. static readonly DELAYLOADSTATE_LOADED: number;
  87093. /** Defines that the ressource is currently delay loading */
  87094. static readonly DELAYLOADSTATE_LOADING: number;
  87095. /** Defines that the ressource is delayed and has not started loading */
  87096. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87098. static readonly NEVER: number;
  87099. /** 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 */
  87100. static readonly ALWAYS: number;
  87101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87102. static readonly LESS: number;
  87103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87104. static readonly EQUAL: number;
  87105. /** 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 */
  87106. static readonly LEQUAL: number;
  87107. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87108. static readonly GREATER: number;
  87109. /** 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 */
  87110. static readonly GEQUAL: number;
  87111. /** 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 */
  87112. static readonly NOTEQUAL: number;
  87113. /** Passed to stencilOperation to specify that stencil value must be kept */
  87114. static readonly KEEP: number;
  87115. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87116. static readonly REPLACE: number;
  87117. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87118. static readonly INCR: number;
  87119. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87120. static readonly DECR: number;
  87121. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87122. static readonly INVERT: number;
  87123. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87124. static readonly INCR_WRAP: number;
  87125. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87126. static readonly DECR_WRAP: number;
  87127. /** Texture is not repeating outside of 0..1 UVs */
  87128. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87129. /** Texture is repeating outside of 0..1 UVs */
  87130. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87131. /** Texture is repeating and mirrored */
  87132. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87133. /** ALPHA */
  87134. static readonly TEXTUREFORMAT_ALPHA: number;
  87135. /** LUMINANCE */
  87136. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87137. /** LUMINANCE_ALPHA */
  87138. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87139. /** RGB */
  87140. static readonly TEXTUREFORMAT_RGB: number;
  87141. /** RGBA */
  87142. static readonly TEXTUREFORMAT_RGBA: number;
  87143. /** RED */
  87144. static readonly TEXTUREFORMAT_RED: number;
  87145. /** RED (2nd reference) */
  87146. static readonly TEXTUREFORMAT_R: number;
  87147. /** RG */
  87148. static readonly TEXTUREFORMAT_RG: number;
  87149. /** RED_INTEGER */
  87150. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87151. /** RED_INTEGER (2nd reference) */
  87152. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87153. /** RG_INTEGER */
  87154. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87155. /** RGB_INTEGER */
  87156. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87157. /** RGBA_INTEGER */
  87158. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87159. /** UNSIGNED_BYTE */
  87160. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87161. /** UNSIGNED_BYTE (2nd reference) */
  87162. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87163. /** FLOAT */
  87164. static readonly TEXTURETYPE_FLOAT: number;
  87165. /** HALF_FLOAT */
  87166. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87167. /** BYTE */
  87168. static readonly TEXTURETYPE_BYTE: number;
  87169. /** SHORT */
  87170. static readonly TEXTURETYPE_SHORT: number;
  87171. /** UNSIGNED_SHORT */
  87172. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87173. /** INT */
  87174. static readonly TEXTURETYPE_INT: number;
  87175. /** UNSIGNED_INT */
  87176. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87177. /** UNSIGNED_SHORT_4_4_4_4 */
  87178. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87179. /** UNSIGNED_SHORT_5_5_5_1 */
  87180. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87181. /** UNSIGNED_SHORT_5_6_5 */
  87182. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87183. /** UNSIGNED_INT_2_10_10_10_REV */
  87184. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87185. /** UNSIGNED_INT_24_8 */
  87186. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87187. /** UNSIGNED_INT_10F_11F_11F_REV */
  87188. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87189. /** UNSIGNED_INT_5_9_9_9_REV */
  87190. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87191. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87192. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87193. /** nearest is mag = nearest and min = nearest and mip = linear */
  87194. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87196. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87197. /** Trilinear is mag = linear and min = linear and mip = linear */
  87198. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87199. /** nearest is mag = nearest and min = nearest and mip = linear */
  87200. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87201. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87202. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87203. /** Trilinear is mag = linear and min = linear and mip = linear */
  87204. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87205. /** mag = nearest and min = nearest and mip = nearest */
  87206. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87207. /** mag = nearest and min = linear and mip = nearest */
  87208. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87209. /** mag = nearest and min = linear and mip = linear */
  87210. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87211. /** mag = nearest and min = linear and mip = none */
  87212. static readonly TEXTURE_NEAREST_LINEAR: number;
  87213. /** mag = nearest and min = nearest and mip = none */
  87214. static readonly TEXTURE_NEAREST_NEAREST: number;
  87215. /** mag = linear and min = nearest and mip = nearest */
  87216. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87217. /** mag = linear and min = nearest and mip = linear */
  87218. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87219. /** mag = linear and min = linear and mip = none */
  87220. static readonly TEXTURE_LINEAR_LINEAR: number;
  87221. /** mag = linear and min = nearest and mip = none */
  87222. static readonly TEXTURE_LINEAR_NEAREST: number;
  87223. /** Explicit coordinates mode */
  87224. static readonly TEXTURE_EXPLICIT_MODE: number;
  87225. /** Spherical coordinates mode */
  87226. static readonly TEXTURE_SPHERICAL_MODE: number;
  87227. /** Planar coordinates mode */
  87228. static readonly TEXTURE_PLANAR_MODE: number;
  87229. /** Cubic coordinates mode */
  87230. static readonly TEXTURE_CUBIC_MODE: number;
  87231. /** Projection coordinates mode */
  87232. static readonly TEXTURE_PROJECTION_MODE: number;
  87233. /** Skybox coordinates mode */
  87234. static readonly TEXTURE_SKYBOX_MODE: number;
  87235. /** Inverse Cubic coordinates mode */
  87236. static readonly TEXTURE_INVCUBIC_MODE: number;
  87237. /** Equirectangular coordinates mode */
  87238. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87239. /** Equirectangular Fixed coordinates mode */
  87240. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87241. /** Equirectangular Fixed Mirrored coordinates mode */
  87242. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87243. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87244. static readonly SCALEMODE_FLOOR: number;
  87245. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87246. static readonly SCALEMODE_NEAREST: number;
  87247. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87248. static readonly SCALEMODE_CEILING: number;
  87249. /**
  87250. * Returns the current npm package of the sdk
  87251. */
  87252. static readonly NpmPackage: string;
  87253. /**
  87254. * Returns the current version of the framework
  87255. */
  87256. static readonly Version: string;
  87257. /**
  87258. * Returns a string describing the current engine
  87259. */
  87260. readonly description: string;
  87261. /**
  87262. * Gets or sets the epsilon value used by collision engine
  87263. */
  87264. static CollisionsEpsilon: number;
  87265. /**
  87266. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87267. */
  87268. static ShadersRepository: string;
  87269. /**
  87270. * Method called to create the default loading screen.
  87271. * This can be overriden in your own app.
  87272. * @param canvas The rendering canvas element
  87273. * @returns The loading screen
  87274. */
  87275. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87276. /**
  87277. * Method called to create the default rescale post process on each engine.
  87278. */
  87279. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87280. /**
  87281. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87282. */
  87283. forcePOTTextures: boolean;
  87284. /**
  87285. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87286. */
  87287. isFullscreen: boolean;
  87288. /**
  87289. * Gets a boolean indicating if the pointer is currently locked
  87290. */
  87291. isPointerLock: boolean;
  87292. /**
  87293. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87294. */
  87295. cullBackFaces: boolean;
  87296. /**
  87297. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87298. */
  87299. renderEvenInBackground: boolean;
  87300. /**
  87301. * Gets or sets a boolean indicating that cache can be kept between frames
  87302. */
  87303. preventCacheWipeBetweenFrames: boolean;
  87304. /**
  87305. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87306. **/
  87307. enableOfflineSupport: boolean;
  87308. /**
  87309. * 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)
  87310. **/
  87311. disableManifestCheck: boolean;
  87312. /**
  87313. * Gets the list of created scenes
  87314. */
  87315. scenes: Scene[];
  87316. /**
  87317. * Event raised when a new scene is created
  87318. */
  87319. onNewSceneAddedObservable: Observable<Scene>;
  87320. /**
  87321. * Gets the list of created postprocesses
  87322. */
  87323. postProcesses: PostProcess[];
  87324. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87325. validateShaderPrograms: boolean;
  87326. /**
  87327. * Observable event triggered each time the rendering canvas is resized
  87328. */
  87329. onResizeObservable: Observable<Engine>;
  87330. /**
  87331. * Observable event triggered each time the canvas loses focus
  87332. */
  87333. onCanvasBlurObservable: Observable<Engine>;
  87334. /**
  87335. * Observable event triggered each time the canvas gains focus
  87336. */
  87337. onCanvasFocusObservable: Observable<Engine>;
  87338. /**
  87339. * Observable event triggered each time the canvas receives pointerout event
  87340. */
  87341. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87342. /**
  87343. * Observable event triggered before each texture is initialized
  87344. */
  87345. onBeforeTextureInitObservable: Observable<Texture>;
  87346. /**
  87347. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87348. */
  87349. disableUniformBuffers: boolean;
  87350. /** @hidden */
  87351. _uniformBuffers: UniformBuffer[];
  87352. /**
  87353. * Gets a boolean indicating that the engine supports uniform buffers
  87354. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87355. */
  87356. readonly supportsUniformBuffers: boolean;
  87357. /**
  87358. * Observable raised when the engine begins a new frame
  87359. */
  87360. onBeginFrameObservable: Observable<Engine>;
  87361. /**
  87362. * If set, will be used to request the next animation frame for the render loop
  87363. */
  87364. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87365. /**
  87366. * Observable raised when the engine ends the current frame
  87367. */
  87368. onEndFrameObservable: Observable<Engine>;
  87369. /**
  87370. * Observable raised when the engine is about to compile a shader
  87371. */
  87372. onBeforeShaderCompilationObservable: Observable<Engine>;
  87373. /**
  87374. * Observable raised when the engine has jsut compiled a shader
  87375. */
  87376. onAfterShaderCompilationObservable: Observable<Engine>;
  87377. /** @hidden */
  87378. _gl: WebGLRenderingContext;
  87379. private _renderingCanvas;
  87380. private _windowIsBackground;
  87381. private _webGLVersion;
  87382. protected _highPrecisionShadersAllowed: boolean;
  87383. /** @hidden */
  87384. readonly _shouldUseHighPrecisionShader: boolean;
  87385. /**
  87386. * Gets a boolean indicating that only power of 2 textures are supported
  87387. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87388. */
  87389. readonly needPOTTextures: boolean;
  87390. /** @hidden */
  87391. _badOS: boolean;
  87392. /** @hidden */
  87393. _badDesktopOS: boolean;
  87394. /**
  87395. * Gets the audio engine
  87396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87397. * @ignorenaming
  87398. */
  87399. static audioEngine: IAudioEngine;
  87400. /**
  87401. * Default AudioEngine factory responsible of creating the Audio Engine.
  87402. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87403. */
  87404. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87405. /**
  87406. * Default offline support factory responsible of creating a tool used to store data locally.
  87407. * By default, this will create a Database object if the workload has been embedded.
  87408. */
  87409. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87410. private _onFocus;
  87411. private _onBlur;
  87412. private _onCanvasPointerOut;
  87413. private _onCanvasBlur;
  87414. private _onCanvasFocus;
  87415. private _onFullscreenChange;
  87416. private _onPointerLockChange;
  87417. private _hardwareScalingLevel;
  87418. /** @hidden */
  87419. _caps: EngineCapabilities;
  87420. private _pointerLockRequested;
  87421. private _isStencilEnable;
  87422. private _colorWrite;
  87423. private _loadingScreen;
  87424. /** @hidden */
  87425. _drawCalls: PerfCounter;
  87426. private _glVersion;
  87427. private _glRenderer;
  87428. private _glVendor;
  87429. private _videoTextureSupported;
  87430. private _renderingQueueLaunched;
  87431. private _activeRenderLoops;
  87432. private _deterministicLockstep;
  87433. private _lockstepMaxSteps;
  87434. /**
  87435. * Observable signaled when a context lost event is raised
  87436. */
  87437. onContextLostObservable: Observable<Engine>;
  87438. /**
  87439. * Observable signaled when a context restored event is raised
  87440. */
  87441. onContextRestoredObservable: Observable<Engine>;
  87442. private _onContextLost;
  87443. private _onContextRestored;
  87444. private _contextWasLost;
  87445. /** @hidden */
  87446. _doNotHandleContextLost: boolean;
  87447. /**
  87448. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87449. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87450. */
  87451. doNotHandleContextLost: boolean;
  87452. private _performanceMonitor;
  87453. private _fps;
  87454. private _deltaTime;
  87455. /**
  87456. * Turn this value on if you want to pause FPS computation when in background
  87457. */
  87458. disablePerformanceMonitorInBackground: boolean;
  87459. /**
  87460. * Gets the performance monitor attached to this engine
  87461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87462. */
  87463. readonly performanceMonitor: PerformanceMonitor;
  87464. /**
  87465. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87466. */
  87467. disableVertexArrayObjects: boolean;
  87468. /** @hidden */
  87469. protected _depthCullingState: _DepthCullingState;
  87470. /** @hidden */
  87471. protected _stencilState: _StencilState;
  87472. /** @hidden */
  87473. protected _alphaState: _AlphaState;
  87474. /** @hidden */
  87475. protected _alphaMode: number;
  87476. /** @hidden */
  87477. _internalTexturesCache: InternalTexture[];
  87478. /** @hidden */
  87479. protected _activeChannel: number;
  87480. private _currentTextureChannel;
  87481. /** @hidden */
  87482. protected _boundTexturesCache: {
  87483. [key: string]: Nullable<InternalTexture>;
  87484. };
  87485. /** @hidden */
  87486. protected _currentEffect: Nullable<Effect>;
  87487. /** @hidden */
  87488. protected _currentProgram: Nullable<WebGLProgram>;
  87489. private _compiledEffects;
  87490. private _vertexAttribArraysEnabled;
  87491. /** @hidden */
  87492. protected _cachedViewport: Nullable<Viewport>;
  87493. private _cachedVertexArrayObject;
  87494. /** @hidden */
  87495. protected _cachedVertexBuffers: any;
  87496. /** @hidden */
  87497. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87498. /** @hidden */
  87499. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87500. /** @hidden */
  87501. _currentRenderTarget: Nullable<InternalTexture>;
  87502. private _uintIndicesCurrentlySet;
  87503. private _currentBoundBuffer;
  87504. /** @hidden */
  87505. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87506. private _currentBufferPointers;
  87507. private _currentInstanceLocations;
  87508. private _currentInstanceBuffers;
  87509. private _textureUnits;
  87510. /** @hidden */
  87511. _workingCanvas: Nullable<HTMLCanvasElement>;
  87512. /** @hidden */
  87513. _workingContext: Nullable<CanvasRenderingContext2D>;
  87514. private _rescalePostProcess;
  87515. private _dummyFramebuffer;
  87516. private _externalData;
  87517. /** @hidden */
  87518. _bindedRenderFunction: any;
  87519. private _vaoRecordInProgress;
  87520. private _mustWipeVertexAttributes;
  87521. private _emptyTexture;
  87522. private _emptyCubeTexture;
  87523. private _emptyTexture3D;
  87524. /** @hidden */
  87525. _frameHandler: number;
  87526. private _nextFreeTextureSlots;
  87527. private _maxSimultaneousTextures;
  87528. private _activeRequests;
  87529. private _texturesSupported;
  87530. /** @hidden */
  87531. _textureFormatInUse: Nullable<string>;
  87532. /**
  87533. * Gets the list of texture formats supported
  87534. */
  87535. readonly texturesSupported: Array<string>;
  87536. /**
  87537. * Gets the list of texture formats in use
  87538. */
  87539. readonly textureFormatInUse: Nullable<string>;
  87540. /**
  87541. * Gets the current viewport
  87542. */
  87543. readonly currentViewport: Nullable<Viewport>;
  87544. /**
  87545. * Gets the default empty texture
  87546. */
  87547. readonly emptyTexture: InternalTexture;
  87548. /**
  87549. * Gets the default empty 3D texture
  87550. */
  87551. readonly emptyTexture3D: InternalTexture;
  87552. /**
  87553. * Gets the default empty cube texture
  87554. */
  87555. readonly emptyCubeTexture: InternalTexture;
  87556. /**
  87557. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87558. */
  87559. readonly premultipliedAlpha: boolean;
  87560. /**
  87561. * Creates a new engine
  87562. * @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
  87563. * @param antialias defines enable antialiasing (default: false)
  87564. * @param options defines further options to be sent to the getContext() function
  87565. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87566. */
  87567. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87568. /**
  87569. * Initializes a webVR display and starts listening to display change events
  87570. * The onVRDisplayChangedObservable will be notified upon these changes
  87571. * @returns The onVRDisplayChangedObservable
  87572. */
  87573. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87574. /** @hidden */
  87575. _prepareVRComponent(): void;
  87576. /** @hidden */
  87577. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87578. /** @hidden */
  87579. _submitVRFrame(): void;
  87580. /**
  87581. * Call this function to leave webVR mode
  87582. * Will do nothing if webVR is not supported or if there is no webVR device
  87583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87584. */
  87585. disableVR(): void;
  87586. /**
  87587. * Gets a boolean indicating that the system is in VR mode and is presenting
  87588. * @returns true if VR mode is engaged
  87589. */
  87590. isVRPresenting(): boolean;
  87591. /** @hidden */
  87592. _requestVRFrame(): void;
  87593. private _disableTouchAction;
  87594. private _rebuildInternalTextures;
  87595. private _rebuildEffects;
  87596. /**
  87597. * Gets a boolean indicating if all created effects are ready
  87598. * @returns true if all effects are ready
  87599. */
  87600. areAllEffectsReady(): boolean;
  87601. private _rebuildBuffers;
  87602. private _initGLContext;
  87603. /**
  87604. * Gets version of the current webGL context
  87605. */
  87606. readonly webGLVersion: number;
  87607. /**
  87608. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87609. */
  87610. readonly isStencilEnable: boolean;
  87611. /** @hidden */
  87612. _prepareWorkingCanvas(): void;
  87613. /**
  87614. * Reset the texture cache to empty state
  87615. */
  87616. resetTextureCache(): void;
  87617. /**
  87618. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87619. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87620. * @returns true if engine is in deterministic lock step mode
  87621. */
  87622. isDeterministicLockStep(): boolean;
  87623. /**
  87624. * Gets the max steps when engine is running in deterministic lock step
  87625. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87626. * @returns the max steps
  87627. */
  87628. getLockstepMaxSteps(): number;
  87629. /**
  87630. * Gets an object containing information about the current webGL context
  87631. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87632. */
  87633. getGlInfo(): {
  87634. vendor: string;
  87635. renderer: string;
  87636. version: string;
  87637. };
  87638. /**
  87639. * Gets current aspect ratio
  87640. * @param camera defines the camera to use to get the aspect ratio
  87641. * @param useScreen defines if screen size must be used (or the current render target if any)
  87642. * @returns a number defining the aspect ratio
  87643. */
  87644. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87645. /**
  87646. * Gets current screen aspect ratio
  87647. * @returns a number defining the aspect ratio
  87648. */
  87649. getScreenAspectRatio(): number;
  87650. /**
  87651. * Gets the current render width
  87652. * @param useScreen defines if screen size must be used (or the current render target if any)
  87653. * @returns a number defining the current render width
  87654. */
  87655. getRenderWidth(useScreen?: boolean): number;
  87656. /**
  87657. * Gets the current render height
  87658. * @param useScreen defines if screen size must be used (or the current render target if any)
  87659. * @returns a number defining the current render height
  87660. */
  87661. getRenderHeight(useScreen?: boolean): number;
  87662. /**
  87663. * Gets the HTML canvas attached with the current webGL context
  87664. * @returns a HTML canvas
  87665. */
  87666. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87667. /**
  87668. * Gets the client rect of the HTML canvas attached with the current webGL context
  87669. * @returns a client rectanglee
  87670. */
  87671. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87672. /**
  87673. * Defines the hardware scaling level.
  87674. * By default the hardware scaling level is computed from the window device ratio.
  87675. * 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.
  87676. * @param level defines the level to use
  87677. */
  87678. setHardwareScalingLevel(level: number): void;
  87679. /**
  87680. * Gets the current hardware scaling level.
  87681. * By default the hardware scaling level is computed from the window device ratio.
  87682. * 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.
  87683. * @returns a number indicating the current hardware scaling level
  87684. */
  87685. getHardwareScalingLevel(): number;
  87686. /**
  87687. * Gets the list of loaded textures
  87688. * @returns an array containing all loaded textures
  87689. */
  87690. getLoadedTexturesCache(): InternalTexture[];
  87691. /**
  87692. * Gets the object containing all engine capabilities
  87693. * @returns the EngineCapabilities object
  87694. */
  87695. getCaps(): EngineCapabilities;
  87696. /**
  87697. * Gets the current depth function
  87698. * @returns a number defining the depth function
  87699. */
  87700. getDepthFunction(): Nullable<number>;
  87701. /**
  87702. * Sets the current depth function
  87703. * @param depthFunc defines the function to use
  87704. */
  87705. setDepthFunction(depthFunc: number): void;
  87706. /**
  87707. * Sets the current depth function to GREATER
  87708. */
  87709. setDepthFunctionToGreater(): void;
  87710. /**
  87711. * Sets the current depth function to GEQUAL
  87712. */
  87713. setDepthFunctionToGreaterOrEqual(): void;
  87714. /**
  87715. * Sets the current depth function to LESS
  87716. */
  87717. setDepthFunctionToLess(): void;
  87718. private _cachedStencilBuffer;
  87719. private _cachedStencilFunction;
  87720. private _cachedStencilMask;
  87721. private _cachedStencilOperationPass;
  87722. private _cachedStencilOperationFail;
  87723. private _cachedStencilOperationDepthFail;
  87724. private _cachedStencilReference;
  87725. /**
  87726. * Caches the the state of the stencil buffer
  87727. */
  87728. cacheStencilState(): void;
  87729. /**
  87730. * Restores the state of the stencil buffer
  87731. */
  87732. restoreStencilState(): void;
  87733. /**
  87734. * Sets the current depth function to LEQUAL
  87735. */
  87736. setDepthFunctionToLessOrEqual(): void;
  87737. /**
  87738. * Gets a boolean indicating if stencil buffer is enabled
  87739. * @returns the current stencil buffer state
  87740. */
  87741. getStencilBuffer(): boolean;
  87742. /**
  87743. * Enable or disable the stencil buffer
  87744. * @param enable defines if the stencil buffer must be enabled or disabled
  87745. */
  87746. setStencilBuffer(enable: boolean): void;
  87747. /**
  87748. * Gets the current stencil mask
  87749. * @returns a number defining the new stencil mask to use
  87750. */
  87751. getStencilMask(): number;
  87752. /**
  87753. * Sets the current stencil mask
  87754. * @param mask defines the new stencil mask to use
  87755. */
  87756. setStencilMask(mask: number): void;
  87757. /**
  87758. * Gets the current stencil function
  87759. * @returns a number defining the stencil function to use
  87760. */
  87761. getStencilFunction(): number;
  87762. /**
  87763. * Gets the current stencil reference value
  87764. * @returns a number defining the stencil reference value to use
  87765. */
  87766. getStencilFunctionReference(): number;
  87767. /**
  87768. * Gets the current stencil mask
  87769. * @returns a number defining the stencil mask to use
  87770. */
  87771. getStencilFunctionMask(): number;
  87772. /**
  87773. * Sets the current stencil function
  87774. * @param stencilFunc defines the new stencil function to use
  87775. */
  87776. setStencilFunction(stencilFunc: number): void;
  87777. /**
  87778. * Sets the current stencil reference
  87779. * @param reference defines the new stencil reference to use
  87780. */
  87781. setStencilFunctionReference(reference: number): void;
  87782. /**
  87783. * Sets the current stencil mask
  87784. * @param mask defines the new stencil mask to use
  87785. */
  87786. setStencilFunctionMask(mask: number): void;
  87787. /**
  87788. * Gets the current stencil operation when stencil fails
  87789. * @returns a number defining stencil operation to use when stencil fails
  87790. */
  87791. getStencilOperationFail(): number;
  87792. /**
  87793. * Gets the current stencil operation when depth fails
  87794. * @returns a number defining stencil operation to use when depth fails
  87795. */
  87796. getStencilOperationDepthFail(): number;
  87797. /**
  87798. * Gets the current stencil operation when stencil passes
  87799. * @returns a number defining stencil operation to use when stencil passes
  87800. */
  87801. getStencilOperationPass(): number;
  87802. /**
  87803. * Sets the stencil operation to use when stencil fails
  87804. * @param operation defines the stencil operation to use when stencil fails
  87805. */
  87806. setStencilOperationFail(operation: number): void;
  87807. /**
  87808. * Sets the stencil operation to use when depth fails
  87809. * @param operation defines the stencil operation to use when depth fails
  87810. */
  87811. setStencilOperationDepthFail(operation: number): void;
  87812. /**
  87813. * Sets the stencil operation to use when stencil passes
  87814. * @param operation defines the stencil operation to use when stencil passes
  87815. */
  87816. setStencilOperationPass(operation: number): void;
  87817. /**
  87818. * Sets a boolean indicating if the dithering state is enabled or disabled
  87819. * @param value defines the dithering state
  87820. */
  87821. setDitheringState(value: boolean): void;
  87822. /**
  87823. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87824. * @param value defines the rasterizer state
  87825. */
  87826. setRasterizerState(value: boolean): void;
  87827. /**
  87828. * stop executing a render loop function and remove it from the execution array
  87829. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87830. */
  87831. stopRenderLoop(renderFunction?: () => void): void;
  87832. /** @hidden */
  87833. _renderLoop(): void;
  87834. /**
  87835. * Register and execute a render loop. The engine can have more than one render function
  87836. * @param renderFunction defines the function to continuously execute
  87837. */
  87838. runRenderLoop(renderFunction: () => void): void;
  87839. /**
  87840. * Toggle full screen mode
  87841. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87842. */
  87843. switchFullscreen(requestPointerLock: boolean): void;
  87844. /**
  87845. * Enters full screen mode
  87846. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87847. */
  87848. enterFullscreen(requestPointerLock: boolean): void;
  87849. /**
  87850. * Exits full screen mode
  87851. */
  87852. exitFullscreen(): void;
  87853. /**
  87854. * Clear the current render buffer or the current render target (if any is set up)
  87855. * @param color defines the color to use
  87856. * @param backBuffer defines if the back buffer must be cleared
  87857. * @param depth defines if the depth buffer must be cleared
  87858. * @param stencil defines if the stencil buffer must be cleared
  87859. */
  87860. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87861. /**
  87862. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87863. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87864. * @param y defines the y-coordinate of the corner of the clear rectangle
  87865. * @param width defines the width of the clear rectangle
  87866. * @param height defines the height of the clear rectangle
  87867. * @param clearColor defines the clear color
  87868. */
  87869. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87870. /**
  87871. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87872. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87873. * @param y defines the y-coordinate of the corner of the clear rectangle
  87874. * @param width defines the width of the clear rectangle
  87875. * @param height defines the height of the clear rectangle
  87876. */
  87877. enableScissor(x: number, y: number, width: number, height: number): void;
  87878. /**
  87879. * Disable previously set scissor test rectangle
  87880. */
  87881. disableScissor(): void;
  87882. private _viewportCached;
  87883. /** @hidden */
  87884. _viewport(x: number, y: number, width: number, height: number): void;
  87885. /**
  87886. * Set the WebGL's viewport
  87887. * @param viewport defines the viewport element to be used
  87888. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87889. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87890. */
  87891. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87892. /**
  87893. * Directly set the WebGL Viewport
  87894. * @param x defines the x coordinate of the viewport (in screen space)
  87895. * @param y defines the y coordinate of the viewport (in screen space)
  87896. * @param width defines the width of the viewport (in screen space)
  87897. * @param height defines the height of the viewport (in screen space)
  87898. * @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
  87899. */
  87900. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87901. /**
  87902. * Begin a new frame
  87903. */
  87904. beginFrame(): void;
  87905. /**
  87906. * Enf the current frame
  87907. */
  87908. endFrame(): void;
  87909. /**
  87910. * Resize the view according to the canvas' size
  87911. */
  87912. resize(): void;
  87913. /**
  87914. * Force a specific size of the canvas
  87915. * @param width defines the new canvas' width
  87916. * @param height defines the new canvas' height
  87917. */
  87918. setSize(width: number, height: number): void;
  87919. /**
  87920. * Binds the frame buffer to the specified texture.
  87921. * @param texture The texture to render to or null for the default canvas
  87922. * @param faceIndex The face of the texture to render to in case of cube texture
  87923. * @param requiredWidth The width of the target to render to
  87924. * @param requiredHeight The height of the target to render to
  87925. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87926. * @param depthStencilTexture The depth stencil texture to use to render
  87927. * @param lodLevel defines le lod level to bind to the frame buffer
  87928. */
  87929. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87930. /** @hidden */
  87931. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  87932. /**
  87933. * Unbind the current render target texture from the webGL context
  87934. * @param texture defines the render target texture to unbind
  87935. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87936. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87937. */
  87938. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87939. /**
  87940. * Force the mipmap generation for the given render target texture
  87941. * @param texture defines the render target texture to use
  87942. */
  87943. generateMipMapsForCubemap(texture: InternalTexture): void;
  87944. /**
  87945. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87946. */
  87947. flushFramebuffer(): void;
  87948. /**
  87949. * Unbind the current render target and bind the default framebuffer
  87950. */
  87951. restoreDefaultFramebuffer(): void;
  87952. /**
  87953. * Create an uniform buffer
  87954. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87955. * @param elements defines the content of the uniform buffer
  87956. * @returns the webGL uniform buffer
  87957. */
  87958. createUniformBuffer(elements: FloatArray): DataBuffer;
  87959. /**
  87960. * Create a dynamic uniform buffer
  87961. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87962. * @param elements defines the content of the uniform buffer
  87963. * @returns the webGL uniform buffer
  87964. */
  87965. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87966. /**
  87967. * Update an existing uniform buffer
  87968. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87969. * @param uniformBuffer defines the target uniform buffer
  87970. * @param elements defines the content to update
  87971. * @param offset defines the offset in the uniform buffer where update should start
  87972. * @param count defines the size of the data to update
  87973. */
  87974. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87975. private _resetVertexBufferBinding;
  87976. /**
  87977. * Creates a vertex buffer
  87978. * @param data the data for the vertex buffer
  87979. * @returns the new WebGL static buffer
  87980. */
  87981. createVertexBuffer(data: DataArray): DataBuffer;
  87982. /**
  87983. * Creates a dynamic vertex buffer
  87984. * @param data the data for the dynamic vertex buffer
  87985. * @returns the new WebGL dynamic buffer
  87986. */
  87987. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  87988. /**
  87989. * Update a dynamic index buffer
  87990. * @param indexBuffer defines the target index buffer
  87991. * @param indices defines the data to update
  87992. * @param offset defines the offset in the target index buffer where update should start
  87993. */
  87994. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  87995. /**
  87996. * Updates a dynamic vertex buffer.
  87997. * @param vertexBuffer the vertex buffer to update
  87998. * @param data the data used to update the vertex buffer
  87999. * @param byteOffset the byte offset of the data
  88000. * @param byteLength the byte length of the data
  88001. */
  88002. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88003. private _resetIndexBufferBinding;
  88004. /**
  88005. * Creates a new index buffer
  88006. * @param indices defines the content of the index buffer
  88007. * @param updatable defines if the index buffer must be updatable
  88008. * @returns a new webGL buffer
  88009. */
  88010. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88011. /**
  88012. * Bind a webGL buffer to the webGL context
  88013. * @param buffer defines the buffer to bind
  88014. */
  88015. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88016. /**
  88017. * Bind an uniform buffer to the current webGL context
  88018. * @param buffer defines the buffer to bind
  88019. */
  88020. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88021. /**
  88022. * Bind a buffer to the current webGL context at a given location
  88023. * @param buffer defines the buffer to bind
  88024. * @param location defines the index where to bind the buffer
  88025. */
  88026. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88027. /**
  88028. * Bind a specific block at a given index in a specific shader program
  88029. * @param pipelineContext defines the pipeline context to use
  88030. * @param blockName defines the block name
  88031. * @param index defines the index where to bind the block
  88032. */
  88033. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88034. private bindIndexBuffer;
  88035. private bindBuffer;
  88036. /**
  88037. * update the bound buffer with the given data
  88038. * @param data defines the data to update
  88039. */
  88040. updateArrayBuffer(data: Float32Array): void;
  88041. private _vertexAttribPointer;
  88042. private _bindIndexBufferWithCache;
  88043. private _bindVertexBuffersAttributes;
  88044. /**
  88045. * Records a vertex array object
  88046. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88047. * @param vertexBuffers defines the list of vertex buffers to store
  88048. * @param indexBuffer defines the index buffer to store
  88049. * @param effect defines the effect to store
  88050. * @returns the new vertex array object
  88051. */
  88052. recordVertexArrayObject(vertexBuffers: {
  88053. [key: string]: VertexBuffer;
  88054. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88055. /**
  88056. * Bind a specific vertex array object
  88057. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88058. * @param vertexArrayObject defines the vertex array object to bind
  88059. * @param indexBuffer defines the index buffer to bind
  88060. */
  88061. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88062. /**
  88063. * Bind webGl buffers directly to the webGL context
  88064. * @param vertexBuffer defines the vertex buffer to bind
  88065. * @param indexBuffer defines the index buffer to bind
  88066. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88067. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88068. * @param effect defines the effect associated with the vertex buffer
  88069. */
  88070. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88071. private _unbindVertexArrayObject;
  88072. /**
  88073. * Bind a list of vertex buffers to the webGL context
  88074. * @param vertexBuffers defines the list of vertex buffers to bind
  88075. * @param indexBuffer defines the index buffer to bind
  88076. * @param effect defines the effect associated with the vertex buffers
  88077. */
  88078. bindBuffers(vertexBuffers: {
  88079. [key: string]: Nullable<VertexBuffer>;
  88080. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88081. /**
  88082. * Unbind all instance attributes
  88083. */
  88084. unbindInstanceAttributes(): void;
  88085. /**
  88086. * Release and free the memory of a vertex array object
  88087. * @param vao defines the vertex array object to delete
  88088. */
  88089. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88090. /** @hidden */
  88091. _releaseBuffer(buffer: DataBuffer): boolean;
  88092. /**
  88093. * Creates a webGL buffer to use with instanciation
  88094. * @param capacity defines the size of the buffer
  88095. * @returns the webGL buffer
  88096. */
  88097. createInstancesBuffer(capacity: number): DataBuffer;
  88098. /**
  88099. * Delete a webGL buffer used with instanciation
  88100. * @param buffer defines the webGL buffer to delete
  88101. */
  88102. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88103. /**
  88104. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88105. * @param instancesBuffer defines the webGL buffer to update and bind
  88106. * @param data defines the data to store in the buffer
  88107. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88108. */
  88109. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88110. /**
  88111. * Apply all cached states (depth, culling, stencil and alpha)
  88112. */
  88113. applyStates(): void;
  88114. /**
  88115. * Send a draw order
  88116. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88117. * @param indexStart defines the starting index
  88118. * @param indexCount defines the number of index to draw
  88119. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88120. */
  88121. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88122. /**
  88123. * Draw a list of points
  88124. * @param verticesStart defines the index of first vertex to draw
  88125. * @param verticesCount defines the count of vertices to draw
  88126. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88127. */
  88128. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88129. /**
  88130. * Draw a list of unindexed primitives
  88131. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88132. * @param verticesStart defines the index of first vertex to draw
  88133. * @param verticesCount defines the count of vertices to draw
  88134. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88135. */
  88136. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88137. /**
  88138. * Draw a list of indexed primitives
  88139. * @param fillMode defines the primitive to use
  88140. * @param indexStart defines the starting index
  88141. * @param indexCount defines the number of index to draw
  88142. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88143. */
  88144. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88145. /**
  88146. * Draw a list of unindexed primitives
  88147. * @param fillMode defines the primitive to use
  88148. * @param verticesStart defines the index of first vertex to draw
  88149. * @param verticesCount defines the count of vertices to draw
  88150. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88151. */
  88152. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88153. private _drawMode;
  88154. /** @hidden */
  88155. _releaseEffect(effect: Effect): void;
  88156. /** @hidden */
  88157. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88158. /**
  88159. * Create a new effect (used to store vertex/fragment shaders)
  88160. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88161. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88162. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88163. * @param samplers defines an array of string used to represent textures
  88164. * @param defines defines the string containing the defines to use to compile the shaders
  88165. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88166. * @param onCompiled defines a function to call when the effect creation is successful
  88167. * @param onError defines a function to call when the effect creation has failed
  88168. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88169. * @returns the new Effect
  88170. */
  88171. 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;
  88172. private _compileShader;
  88173. private _compileRawShader;
  88174. /**
  88175. * Directly creates a webGL program
  88176. * @param pipelineContext defines the pipeline context to attach to
  88177. * @param vertexCode defines the vertex shader code to use
  88178. * @param fragmentCode defines the fragment shader code to use
  88179. * @param context defines the webGL context to use (if not set, the current one will be used)
  88180. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88181. * @returns the new webGL program
  88182. */
  88183. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88184. /**
  88185. * Creates a webGL program
  88186. * @param pipelineContext defines the pipeline context to attach to
  88187. * @param vertexCode defines the vertex shader code to use
  88188. * @param fragmentCode defines the fragment shader code to use
  88189. * @param defines defines the string containing the defines to use to compile the shaders
  88190. * @param context defines the webGL context to use (if not set, the current one will be used)
  88191. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88192. * @returns the new webGL program
  88193. */
  88194. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88195. /**
  88196. * Creates a new pipeline context
  88197. * @returns the new pipeline
  88198. */
  88199. createPipelineContext(): WebGLPipelineContext;
  88200. private _createShaderProgram;
  88201. private _finalizePipelineContext;
  88202. /** @hidden */
  88203. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88204. /** @hidden */
  88205. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88206. /** @hidden */
  88207. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88208. /**
  88209. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88210. * @param pipelineContext defines the pipeline context to use
  88211. * @param uniformsNames defines the list of uniform names
  88212. * @returns an array of webGL uniform locations
  88213. */
  88214. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88215. /**
  88216. * Gets the lsit of active attributes for a given webGL program
  88217. * @param pipelineContext defines the pipeline context to use
  88218. * @param attributesNames defines the list of attribute names to get
  88219. * @returns an array of indices indicating the offset of each attribute
  88220. */
  88221. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88222. /**
  88223. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88224. * @param effect defines the effect to activate
  88225. */
  88226. enableEffect(effect: Nullable<Effect>): void;
  88227. /**
  88228. * Set the value of an uniform to an array of int32
  88229. * @param uniform defines the webGL uniform location where to store the value
  88230. * @param array defines the array of int32 to store
  88231. */
  88232. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88233. /**
  88234. * Set the value of an uniform to an array of int32 (stored as vec2)
  88235. * @param uniform defines the webGL uniform location where to store the value
  88236. * @param array defines the array of int32 to store
  88237. */
  88238. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88239. /**
  88240. * Set the value of an uniform to an array of int32 (stored as vec3)
  88241. * @param uniform defines the webGL uniform location where to store the value
  88242. * @param array defines the array of int32 to store
  88243. */
  88244. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88245. /**
  88246. * Set the value of an uniform to an array of int32 (stored as vec4)
  88247. * @param uniform defines the webGL uniform location where to store the value
  88248. * @param array defines the array of int32 to store
  88249. */
  88250. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88251. /**
  88252. * Set the value of an uniform to an array of float32
  88253. * @param uniform defines the webGL uniform location where to store the value
  88254. * @param array defines the array of float32 to store
  88255. */
  88256. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88257. /**
  88258. * Set the value of an uniform to an array of float32 (stored as vec2)
  88259. * @param uniform defines the webGL uniform location where to store the value
  88260. * @param array defines the array of float32 to store
  88261. */
  88262. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88263. /**
  88264. * Set the value of an uniform to an array of float32 (stored as vec3)
  88265. * @param uniform defines the webGL uniform location where to store the value
  88266. * @param array defines the array of float32 to store
  88267. */
  88268. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88269. /**
  88270. * Set the value of an uniform to an array of float32 (stored as vec4)
  88271. * @param uniform defines the webGL uniform location where to store the value
  88272. * @param array defines the array of float32 to store
  88273. */
  88274. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88275. /**
  88276. * Set the value of an uniform to an array of number
  88277. * @param uniform defines the webGL uniform location where to store the value
  88278. * @param array defines the array of number to store
  88279. */
  88280. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88281. /**
  88282. * Set the value of an uniform to an array of number (stored as vec2)
  88283. * @param uniform defines the webGL uniform location where to store the value
  88284. * @param array defines the array of number to store
  88285. */
  88286. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88287. /**
  88288. * Set the value of an uniform to an array of number (stored as vec3)
  88289. * @param uniform defines the webGL uniform location where to store the value
  88290. * @param array defines the array of number to store
  88291. */
  88292. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88293. /**
  88294. * Set the value of an uniform to an array of number (stored as vec4)
  88295. * @param uniform defines the webGL uniform location where to store the value
  88296. * @param array defines the array of number to store
  88297. */
  88298. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88299. /**
  88300. * Set the value of an uniform to an array of float32 (stored as matrices)
  88301. * @param uniform defines the webGL uniform location where to store the value
  88302. * @param matrices defines the array of float32 to store
  88303. */
  88304. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88305. /**
  88306. * Set the value of an uniform to a matrix
  88307. * @param uniform defines the webGL uniform location where to store the value
  88308. * @param matrix defines the matrix to store
  88309. */
  88310. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88311. /**
  88312. * Set the value of an uniform to a matrix (3x3)
  88313. * @param uniform defines the webGL uniform location where to store the value
  88314. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88315. */
  88316. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88317. /**
  88318. * Set the value of an uniform to a matrix (2x2)
  88319. * @param uniform defines the webGL uniform location where to store the value
  88320. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88321. */
  88322. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88323. /**
  88324. * Set the value of an uniform to a number (int)
  88325. * @param uniform defines the webGL uniform location where to store the value
  88326. * @param value defines the int number to store
  88327. */
  88328. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88329. /**
  88330. * Set the value of an uniform to a number (float)
  88331. * @param uniform defines the webGL uniform location where to store the value
  88332. * @param value defines the float number to store
  88333. */
  88334. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88335. /**
  88336. * Set the value of an uniform to a vec2
  88337. * @param uniform defines the webGL uniform location where to store the value
  88338. * @param x defines the 1st component of the value
  88339. * @param y defines the 2nd component of the value
  88340. */
  88341. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88342. /**
  88343. * Set the value of an uniform to a vec3
  88344. * @param uniform defines the webGL uniform location where to store the value
  88345. * @param x defines the 1st component of the value
  88346. * @param y defines the 2nd component of the value
  88347. * @param z defines the 3rd component of the value
  88348. */
  88349. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88350. /**
  88351. * Set the value of an uniform to a boolean
  88352. * @param uniform defines the webGL uniform location where to store the value
  88353. * @param bool defines the boolean to store
  88354. */
  88355. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88356. /**
  88357. * Set the value of an uniform to a vec4
  88358. * @param uniform defines the webGL uniform location where to store the value
  88359. * @param x defines the 1st component of the value
  88360. * @param y defines the 2nd component of the value
  88361. * @param z defines the 3rd component of the value
  88362. * @param w defines the 4th component of the value
  88363. */
  88364. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88365. /**
  88366. * Set the value of an uniform to a Color3
  88367. * @param uniform defines the webGL uniform location where to store the value
  88368. * @param color3 defines the color to store
  88369. */
  88370. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88371. /**
  88372. * Set the value of an uniform to a Color3 and an alpha value
  88373. * @param uniform defines the webGL uniform location where to store the value
  88374. * @param color3 defines the color to store
  88375. * @param alpha defines the alpha component to store
  88376. */
  88377. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88378. /**
  88379. * Sets a Color4 on a uniform variable
  88380. * @param uniform defines the uniform location
  88381. * @param color4 defines the value to be set
  88382. */
  88383. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88384. /**
  88385. * Set various states to the webGL context
  88386. * @param culling defines backface culling state
  88387. * @param zOffset defines the value to apply to zOffset (0 by default)
  88388. * @param force defines if states must be applied even if cache is up to date
  88389. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88390. */
  88391. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88392. /**
  88393. * Set the z offset to apply to current rendering
  88394. * @param value defines the offset to apply
  88395. */
  88396. setZOffset(value: number): void;
  88397. /**
  88398. * Gets the current value of the zOffset
  88399. * @returns the current zOffset state
  88400. */
  88401. getZOffset(): number;
  88402. /**
  88403. * Enable or disable depth buffering
  88404. * @param enable defines the state to set
  88405. */
  88406. setDepthBuffer(enable: boolean): void;
  88407. /**
  88408. * Gets a boolean indicating if depth writing is enabled
  88409. * @returns the current depth writing state
  88410. */
  88411. getDepthWrite(): boolean;
  88412. /**
  88413. * Enable or disable depth writing
  88414. * @param enable defines the state to set
  88415. */
  88416. setDepthWrite(enable: boolean): void;
  88417. /**
  88418. * Enable or disable color writing
  88419. * @param enable defines the state to set
  88420. */
  88421. setColorWrite(enable: boolean): void;
  88422. /**
  88423. * Gets a boolean indicating if color writing is enabled
  88424. * @returns the current color writing state
  88425. */
  88426. getColorWrite(): boolean;
  88427. /**
  88428. * Sets alpha constants used by some alpha blending modes
  88429. * @param r defines the red component
  88430. * @param g defines the green component
  88431. * @param b defines the blue component
  88432. * @param a defines the alpha component
  88433. */
  88434. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88435. /**
  88436. * Sets the current alpha mode
  88437. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88438. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88439. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88440. */
  88441. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88442. /**
  88443. * Gets the current alpha mode
  88444. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88445. * @returns the current alpha mode
  88446. */
  88447. getAlphaMode(): number;
  88448. /**
  88449. * Clears the list of texture accessible through engine.
  88450. * This can help preventing texture load conflict due to name collision.
  88451. */
  88452. clearInternalTexturesCache(): void;
  88453. /**
  88454. * Force the entire cache to be cleared
  88455. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88456. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88457. */
  88458. wipeCaches(bruteForce?: boolean): void;
  88459. /**
  88460. * Set the compressed texture format to use, based on the formats you have, and the formats
  88461. * supported by the hardware / browser.
  88462. *
  88463. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88464. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88465. * to API arguments needed to compressed textures. This puts the burden on the container
  88466. * generator to house the arcane code for determining these for current & future formats.
  88467. *
  88468. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88469. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88470. *
  88471. * Note: The result of this call is not taken into account when a texture is base64.
  88472. *
  88473. * @param formatsAvailable defines the list of those format families you have created
  88474. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88475. *
  88476. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88477. * @returns The extension selected.
  88478. */
  88479. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88480. /** @hidden */
  88481. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88482. min: number;
  88483. mag: number;
  88484. };
  88485. /** @hidden */
  88486. _createTexture(): WebGLTexture;
  88487. /**
  88488. * Usually called from Texture.ts.
  88489. * Passed information to create a WebGLTexture
  88490. * @param urlArg defines a value which contains one of the following:
  88491. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88492. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88493. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88494. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88495. * @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)
  88496. * @param scene needed for loading to the correct scene
  88497. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88498. * @param onLoad optional callback to be called upon successful completion
  88499. * @param onError optional callback to be called upon failure
  88500. * @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
  88501. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88502. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88503. * @param forcedExtension defines the extension to use to pick the right loader
  88504. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88505. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88506. */
  88507. 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;
  88508. private _rescaleTexture;
  88509. private _unpackFlipYCached;
  88510. /**
  88511. * In case you are sharing the context with other applications, it might
  88512. * be interested to not cache the unpack flip y state to ensure a consistent
  88513. * value would be set.
  88514. */
  88515. enableUnpackFlipYCached: boolean;
  88516. /** @hidden */
  88517. _unpackFlipY(value: boolean): void;
  88518. /** @hidden */
  88519. _getUnpackAlignement(): number;
  88520. /**
  88521. * Creates a dynamic texture
  88522. * @param width defines the width of the texture
  88523. * @param height defines the height of the texture
  88524. * @param generateMipMaps defines if the engine should generate the mip levels
  88525. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88526. * @returns the dynamic texture inside an InternalTexture
  88527. */
  88528. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88529. /**
  88530. * Update the sampling mode of a given texture
  88531. * @param samplingMode defines the required sampling mode
  88532. * @param texture defines the texture to update
  88533. */
  88534. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88535. /**
  88536. * Update the content of a dynamic texture
  88537. * @param texture defines the texture to update
  88538. * @param canvas defines the canvas containing the source
  88539. * @param invertY defines if data must be stored with Y axis inverted
  88540. * @param premulAlpha defines if alpha is stored as premultiplied
  88541. * @param format defines the format of the data
  88542. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88543. */
  88544. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88545. /**
  88546. * Update a video texture
  88547. * @param texture defines the texture to update
  88548. * @param video defines the video element to use
  88549. * @param invertY defines if data must be stored with Y axis inverted
  88550. */
  88551. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88552. /**
  88553. * Updates a depth texture Comparison Mode and Function.
  88554. * If the comparison Function is equal to 0, the mode will be set to none.
  88555. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88556. * @param texture The texture to set the comparison function for
  88557. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88558. */
  88559. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88560. /** @hidden */
  88561. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88562. width: number;
  88563. height: number;
  88564. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88565. /**
  88566. * Creates a depth stencil texture.
  88567. * This is only available in WebGL 2 or with the depth texture extension available.
  88568. * @param size The size of face edge in the texture.
  88569. * @param options The options defining the texture.
  88570. * @returns The texture
  88571. */
  88572. createDepthStencilTexture(size: number | {
  88573. width: number;
  88574. height: number;
  88575. }, options: DepthTextureCreationOptions): InternalTexture;
  88576. /**
  88577. * Creates a depth stencil texture.
  88578. * This is only available in WebGL 2 or with the depth texture extension available.
  88579. * @param size The size of face edge in the texture.
  88580. * @param options The options defining the texture.
  88581. * @returns The texture
  88582. */
  88583. private _createDepthStencilTexture;
  88584. /**
  88585. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88586. * @param renderTarget The render target to set the frame buffer for
  88587. */
  88588. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88589. /**
  88590. * Creates a new render target texture
  88591. * @param size defines the size of the texture
  88592. * @param options defines the options used to create the texture
  88593. * @returns a new render target texture stored in an InternalTexture
  88594. */
  88595. createRenderTargetTexture(size: number | {
  88596. width: number;
  88597. height: number;
  88598. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88599. /** @hidden */
  88600. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88601. /**
  88602. * Updates the sample count of a render target texture
  88603. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88604. * @param texture defines the texture to update
  88605. * @param samples defines the sample count to set
  88606. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88607. */
  88608. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88609. /** @hidden */
  88610. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88611. /** @hidden */
  88612. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88613. /** @hidden */
  88614. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88615. /** @hidden */
  88616. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88617. /**
  88618. * @hidden
  88619. */
  88620. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88621. private _prepareWebGLTextureContinuation;
  88622. private _prepareWebGLTexture;
  88623. /** @hidden */
  88624. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88625. /** @hidden */
  88626. _releaseFramebufferObjects(texture: InternalTexture): void;
  88627. /** @hidden */
  88628. _releaseTexture(texture: InternalTexture): void;
  88629. private setProgram;
  88630. private _boundUniforms;
  88631. /**
  88632. * Binds an effect to the webGL context
  88633. * @param effect defines the effect to bind
  88634. */
  88635. bindSamplers(effect: Effect): void;
  88636. private _activateCurrentTexture;
  88637. /** @hidden */
  88638. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88639. /** @hidden */
  88640. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88641. /**
  88642. * Sets a texture to the webGL context from a postprocess
  88643. * @param channel defines the channel to use
  88644. * @param postProcess defines the source postprocess
  88645. */
  88646. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88647. /**
  88648. * Binds the output of the passed in post process to the texture channel specified
  88649. * @param channel The channel the texture should be bound to
  88650. * @param postProcess The post process which's output should be bound
  88651. */
  88652. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88653. /**
  88654. * Unbind all textures from the webGL context
  88655. */
  88656. unbindAllTextures(): void;
  88657. /**
  88658. * Sets a texture to the according uniform.
  88659. * @param channel The texture channel
  88660. * @param uniform The uniform to set
  88661. * @param texture The texture to apply
  88662. */
  88663. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88664. /**
  88665. * Sets a depth stencil texture from a render target to the according uniform.
  88666. * @param channel The texture channel
  88667. * @param uniform The uniform to set
  88668. * @param texture The render target texture containing the depth stencil texture to apply
  88669. */
  88670. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88671. private _bindSamplerUniformToChannel;
  88672. private _getTextureWrapMode;
  88673. private _setTexture;
  88674. /**
  88675. * Sets an array of texture to the webGL context
  88676. * @param channel defines the channel where the texture array must be set
  88677. * @param uniform defines the associated uniform location
  88678. * @param textures defines the array of textures to bind
  88679. */
  88680. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88681. /** @hidden */
  88682. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88683. private _setTextureParameterFloat;
  88684. private _setTextureParameterInteger;
  88685. /**
  88686. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88687. * @param x defines the x coordinate of the rectangle where pixels must be read
  88688. * @param y defines the y coordinate of the rectangle where pixels must be read
  88689. * @param width defines the width of the rectangle where pixels must be read
  88690. * @param height defines the height of the rectangle where pixels must be read
  88691. * @returns a Uint8Array containing RGBA colors
  88692. */
  88693. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88694. /**
  88695. * Add an externaly attached data from its key.
  88696. * This method call will fail and return false, if such key already exists.
  88697. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88698. * @param key the unique key that identifies the data
  88699. * @param data the data object to associate to the key for this Engine instance
  88700. * @return true if no such key were already present and the data was added successfully, false otherwise
  88701. */
  88702. addExternalData<T>(key: string, data: T): boolean;
  88703. /**
  88704. * Get an externaly attached data from its key
  88705. * @param key the unique key that identifies the data
  88706. * @return the associated data, if present (can be null), or undefined if not present
  88707. */
  88708. getExternalData<T>(key: string): T;
  88709. /**
  88710. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88711. * @param key the unique key that identifies the data
  88712. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88713. * @return the associated data, can be null if the factory returned null.
  88714. */
  88715. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88716. /**
  88717. * Remove an externaly attached data from the Engine instance
  88718. * @param key the unique key that identifies the data
  88719. * @return true if the data was successfully removed, false if it doesn't exist
  88720. */
  88721. removeExternalData(key: string): boolean;
  88722. /**
  88723. * Unbind all vertex attributes from the webGL context
  88724. */
  88725. unbindAllAttributes(): void;
  88726. /**
  88727. * 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
  88728. */
  88729. releaseEffects(): void;
  88730. /**
  88731. * Dispose and release all associated resources
  88732. */
  88733. dispose(): void;
  88734. /**
  88735. * Display the loading screen
  88736. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88737. */
  88738. displayLoadingUI(): void;
  88739. /**
  88740. * Hide the loading screen
  88741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88742. */
  88743. hideLoadingUI(): void;
  88744. /**
  88745. * Gets the current loading screen object
  88746. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88747. */
  88748. /**
  88749. * Sets the current loading screen object
  88750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88751. */
  88752. loadingScreen: ILoadingScreen;
  88753. /**
  88754. * Sets the current loading screen text
  88755. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88756. */
  88757. loadingUIText: string;
  88758. /**
  88759. * Sets the current loading screen background color
  88760. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88761. */
  88762. loadingUIBackgroundColor: string;
  88763. /**
  88764. * Attach a new callback raised when context lost event is fired
  88765. * @param callback defines the callback to call
  88766. */
  88767. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88768. /**
  88769. * Attach a new callback raised when context restored event is fired
  88770. * @param callback defines the callback to call
  88771. */
  88772. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88773. /**
  88774. * Gets the source code of the vertex shader associated with a specific webGL program
  88775. * @param program defines the program to use
  88776. * @returns a string containing the source code of the vertex shader associated with the program
  88777. */
  88778. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88779. /**
  88780. * Gets the source code of the fragment shader associated with a specific webGL program
  88781. * @param program defines the program to use
  88782. * @returns a string containing the source code of the fragment shader associated with the program
  88783. */
  88784. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88785. /**
  88786. * Get the current error code of the webGL context
  88787. * @returns the error code
  88788. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88789. */
  88790. getError(): number;
  88791. /**
  88792. * Gets the current framerate
  88793. * @returns a number representing the framerate
  88794. */
  88795. getFps(): number;
  88796. /**
  88797. * Gets the time spent between current and previous frame
  88798. * @returns a number representing the delta time in ms
  88799. */
  88800. getDeltaTime(): number;
  88801. private _measureFps;
  88802. /** @hidden */
  88803. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88804. private _canRenderToFloatFramebuffer;
  88805. private _canRenderToHalfFloatFramebuffer;
  88806. private _canRenderToFramebuffer;
  88807. /** @hidden */
  88808. _getWebGLTextureType(type: number): number;
  88809. /** @hidden */
  88810. _getInternalFormat(format: number): number;
  88811. /** @hidden */
  88812. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88813. /** @hidden */
  88814. _getRGBAMultiSampleBufferFormat(type: number): number;
  88815. /** @hidden */
  88816. _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;
  88817. /** @hidden */
  88818. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88819. /**
  88820. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88821. * @returns true if the engine can be created
  88822. * @ignorenaming
  88823. */
  88824. static isSupported(): boolean;
  88825. }
  88826. }
  88827. declare module BABYLON {
  88828. /**
  88829. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88830. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88831. */
  88832. export class EffectFallbacks {
  88833. private _defines;
  88834. private _currentRank;
  88835. private _maxRank;
  88836. private _mesh;
  88837. /**
  88838. * Removes the fallback from the bound mesh.
  88839. */
  88840. unBindMesh(): void;
  88841. /**
  88842. * Adds a fallback on the specified property.
  88843. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88844. * @param define The name of the define in the shader
  88845. */
  88846. addFallback(rank: number, define: string): void;
  88847. /**
  88848. * Sets the mesh to use CPU skinning when needing to fallback.
  88849. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88850. * @param mesh The mesh to use the fallbacks.
  88851. */
  88852. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88853. /**
  88854. * Checks to see if more fallbacks are still availible.
  88855. */
  88856. readonly isMoreFallbacks: boolean;
  88857. /**
  88858. * Removes the defines that shoould be removed when falling back.
  88859. * @param currentDefines defines the current define statements for the shader.
  88860. * @param effect defines the current effect we try to compile
  88861. * @returns The resulting defines with defines of the current rank removed.
  88862. */
  88863. reduce(currentDefines: string, effect: Effect): string;
  88864. }
  88865. /**
  88866. * Options to be used when creating an effect.
  88867. */
  88868. export class EffectCreationOptions {
  88869. /**
  88870. * Atrributes that will be used in the shader.
  88871. */
  88872. attributes: string[];
  88873. /**
  88874. * Uniform varible names that will be set in the shader.
  88875. */
  88876. uniformsNames: string[];
  88877. /**
  88878. * Uniform buffer varible names that will be set in the shader.
  88879. */
  88880. uniformBuffersNames: string[];
  88881. /**
  88882. * Sampler texture variable names that will be set in the shader.
  88883. */
  88884. samplers: string[];
  88885. /**
  88886. * Define statements that will be set in the shader.
  88887. */
  88888. defines: any;
  88889. /**
  88890. * Possible fallbacks for this effect to improve performance when needed.
  88891. */
  88892. fallbacks: Nullable<EffectFallbacks>;
  88893. /**
  88894. * Callback that will be called when the shader is compiled.
  88895. */
  88896. onCompiled: Nullable<(effect: Effect) => void>;
  88897. /**
  88898. * Callback that will be called if an error occurs during shader compilation.
  88899. */
  88900. onError: Nullable<(effect: Effect, errors: string) => void>;
  88901. /**
  88902. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88903. */
  88904. indexParameters: any;
  88905. /**
  88906. * Max number of lights that can be used in the shader.
  88907. */
  88908. maxSimultaneousLights: number;
  88909. /**
  88910. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88911. */
  88912. transformFeedbackVaryings: Nullable<string[]>;
  88913. }
  88914. /**
  88915. * Effect containing vertex and fragment shader that can be executed on an object.
  88916. */
  88917. export class Effect implements IDisposable {
  88918. /**
  88919. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88920. */
  88921. static ShadersRepository: string;
  88922. /**
  88923. * Name of the effect.
  88924. */
  88925. name: any;
  88926. /**
  88927. * String container all the define statements that should be set on the shader.
  88928. */
  88929. defines: string;
  88930. /**
  88931. * Callback that will be called when the shader is compiled.
  88932. */
  88933. onCompiled: Nullable<(effect: Effect) => void>;
  88934. /**
  88935. * Callback that will be called if an error occurs during shader compilation.
  88936. */
  88937. onError: Nullable<(effect: Effect, errors: string) => void>;
  88938. /**
  88939. * Callback that will be called when effect is bound.
  88940. */
  88941. onBind: Nullable<(effect: Effect) => void>;
  88942. /**
  88943. * Unique ID of the effect.
  88944. */
  88945. uniqueId: number;
  88946. /**
  88947. * Observable that will be called when the shader is compiled.
  88948. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88949. */
  88950. onCompileObservable: Observable<Effect>;
  88951. /**
  88952. * Observable that will be called if an error occurs during shader compilation.
  88953. */
  88954. onErrorObservable: Observable<Effect>;
  88955. /** @hidden */
  88956. _onBindObservable: Nullable<Observable<Effect>>;
  88957. /**
  88958. * Observable that will be called when effect is bound.
  88959. */
  88960. readonly onBindObservable: Observable<Effect>;
  88961. /** @hidden */
  88962. _bonesComputationForcedToCPU: boolean;
  88963. private static _uniqueIdSeed;
  88964. private _engine;
  88965. private _uniformBuffersNames;
  88966. private _uniformsNames;
  88967. private _samplerList;
  88968. private _samplers;
  88969. private _isReady;
  88970. private _compilationError;
  88971. private _attributesNames;
  88972. private _attributes;
  88973. private _uniforms;
  88974. /**
  88975. * Key for the effect.
  88976. * @hidden
  88977. */
  88978. _key: string;
  88979. private _indexParameters;
  88980. private _fallbacks;
  88981. private _vertexSourceCode;
  88982. private _fragmentSourceCode;
  88983. private _vertexSourceCodeOverride;
  88984. private _fragmentSourceCodeOverride;
  88985. private _transformFeedbackVaryings;
  88986. /**
  88987. * Compiled shader to webGL program.
  88988. * @hidden
  88989. */
  88990. _pipelineContext: IPipelineContext;
  88991. private _valueCache;
  88992. private static _baseCache;
  88993. /**
  88994. * Instantiates an effect.
  88995. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88996. * @param baseName Name of the effect.
  88997. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88998. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88999. * @param samplers List of sampler variables that will be passed to the shader.
  89000. * @param engine Engine to be used to render the effect
  89001. * @param defines Define statements to be added to the shader.
  89002. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89003. * @param onCompiled Callback that will be called when the shader is compiled.
  89004. * @param onError Callback that will be called if an error occurs during shader compilation.
  89005. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89006. */
  89007. 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);
  89008. /**
  89009. * Unique key for this effect
  89010. */
  89011. readonly key: string;
  89012. /**
  89013. * If the effect has been compiled and prepared.
  89014. * @returns if the effect is compiled and prepared.
  89015. */
  89016. isReady(): boolean;
  89017. /**
  89018. * The engine the effect was initialized with.
  89019. * @returns the engine.
  89020. */
  89021. getEngine(): Engine;
  89022. /**
  89023. * The pipeline context for this effect
  89024. * @returns the associated pipeline context
  89025. */
  89026. getPipelineContext(): IPipelineContext;
  89027. /**
  89028. * The set of names of attribute variables for the shader.
  89029. * @returns An array of attribute names.
  89030. */
  89031. getAttributesNames(): string[];
  89032. /**
  89033. * Returns the attribute at the given index.
  89034. * @param index The index of the attribute.
  89035. * @returns The location of the attribute.
  89036. */
  89037. getAttributeLocation(index: number): number;
  89038. /**
  89039. * Returns the attribute based on the name of the variable.
  89040. * @param name of the attribute to look up.
  89041. * @returns the attribute location.
  89042. */
  89043. getAttributeLocationByName(name: string): number;
  89044. /**
  89045. * The number of attributes.
  89046. * @returns the numnber of attributes.
  89047. */
  89048. getAttributesCount(): number;
  89049. /**
  89050. * Gets the index of a uniform variable.
  89051. * @param uniformName of the uniform to look up.
  89052. * @returns the index.
  89053. */
  89054. getUniformIndex(uniformName: string): number;
  89055. /**
  89056. * Returns the attribute based on the name of the variable.
  89057. * @param uniformName of the uniform to look up.
  89058. * @returns the location of the uniform.
  89059. */
  89060. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89061. /**
  89062. * Returns an array of sampler variable names
  89063. * @returns The array of sampler variable neames.
  89064. */
  89065. getSamplers(): string[];
  89066. /**
  89067. * The error from the last compilation.
  89068. * @returns the error string.
  89069. */
  89070. getCompilationError(): string;
  89071. /**
  89072. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89073. * @param func The callback to be used.
  89074. */
  89075. executeWhenCompiled(func: (effect: Effect) => void): void;
  89076. private _checkIsReady;
  89077. /** @hidden */
  89078. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89079. /** @hidden */
  89080. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89081. /** @hidden */
  89082. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89083. private _processShaderConversion;
  89084. private _processIncludes;
  89085. private _processPrecision;
  89086. /**
  89087. * Recompiles the webGL program
  89088. * @param vertexSourceCode The source code for the vertex shader.
  89089. * @param fragmentSourceCode The source code for the fragment shader.
  89090. * @param onCompiled Callback called when completed.
  89091. * @param onError Callback called on error.
  89092. * @hidden
  89093. */
  89094. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89095. /**
  89096. * Prepares the effect
  89097. * @hidden
  89098. */
  89099. _prepareEffect(): void;
  89100. /**
  89101. * Checks if the effect is supported. (Must be called after compilation)
  89102. */
  89103. readonly isSupported: boolean;
  89104. /**
  89105. * Binds a texture to the engine to be used as output of the shader.
  89106. * @param channel Name of the output variable.
  89107. * @param texture Texture to bind.
  89108. * @hidden
  89109. */
  89110. _bindTexture(channel: string, texture: InternalTexture): void;
  89111. /**
  89112. * Sets a texture on the engine to be used in the shader.
  89113. * @param channel Name of the sampler variable.
  89114. * @param texture Texture to set.
  89115. */
  89116. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89117. /**
  89118. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89119. * @param channel Name of the sampler variable.
  89120. * @param texture Texture to set.
  89121. */
  89122. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89123. /**
  89124. * Sets an array of textures on the engine to be used in the shader.
  89125. * @param channel Name of the variable.
  89126. * @param textures Textures to set.
  89127. */
  89128. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89129. /**
  89130. * 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)
  89131. * @param channel Name of the sampler variable.
  89132. * @param postProcess Post process to get the input texture from.
  89133. */
  89134. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89135. /**
  89136. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89137. * 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)
  89138. * @param channel Name of the sampler variable.
  89139. * @param postProcess Post process to get the output texture from.
  89140. */
  89141. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89142. /** @hidden */
  89143. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89144. /** @hidden */
  89145. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89146. /** @hidden */
  89147. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89148. /** @hidden */
  89149. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89150. /**
  89151. * Binds a buffer to a uniform.
  89152. * @param buffer Buffer to bind.
  89153. * @param name Name of the uniform variable to bind to.
  89154. */
  89155. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89156. /**
  89157. * Binds block to a uniform.
  89158. * @param blockName Name of the block to bind.
  89159. * @param index Index to bind.
  89160. */
  89161. bindUniformBlock(blockName: string, index: number): void;
  89162. /**
  89163. * Sets an interger value on a uniform variable.
  89164. * @param uniformName Name of the variable.
  89165. * @param value Value to be set.
  89166. * @returns this effect.
  89167. */
  89168. setInt(uniformName: string, value: number): Effect;
  89169. /**
  89170. * Sets an int array on a uniform variable.
  89171. * @param uniformName Name of the variable.
  89172. * @param array array to be set.
  89173. * @returns this effect.
  89174. */
  89175. setIntArray(uniformName: string, array: Int32Array): Effect;
  89176. /**
  89177. * 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)
  89178. * @param uniformName Name of the variable.
  89179. * @param array array to be set.
  89180. * @returns this effect.
  89181. */
  89182. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89183. /**
  89184. * 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)
  89185. * @param uniformName Name of the variable.
  89186. * @param array array to be set.
  89187. * @returns this effect.
  89188. */
  89189. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89190. /**
  89191. * 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)
  89192. * @param uniformName Name of the variable.
  89193. * @param array array to be set.
  89194. * @returns this effect.
  89195. */
  89196. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89197. /**
  89198. * Sets an float array on a uniform variable.
  89199. * @param uniformName Name of the variable.
  89200. * @param array array to be set.
  89201. * @returns this effect.
  89202. */
  89203. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89204. /**
  89205. * 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)
  89206. * @param uniformName Name of the variable.
  89207. * @param array array to be set.
  89208. * @returns this effect.
  89209. */
  89210. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89211. /**
  89212. * 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)
  89213. * @param uniformName Name of the variable.
  89214. * @param array array to be set.
  89215. * @returns this effect.
  89216. */
  89217. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89218. /**
  89219. * 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)
  89220. * @param uniformName Name of the variable.
  89221. * @param array array to be set.
  89222. * @returns this effect.
  89223. */
  89224. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89225. /**
  89226. * Sets an array on a uniform variable.
  89227. * @param uniformName Name of the variable.
  89228. * @param array array to be set.
  89229. * @returns this effect.
  89230. */
  89231. setArray(uniformName: string, array: number[]): Effect;
  89232. /**
  89233. * 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)
  89234. * @param uniformName Name of the variable.
  89235. * @param array array to be set.
  89236. * @returns this effect.
  89237. */
  89238. setArray2(uniformName: string, array: number[]): Effect;
  89239. /**
  89240. * 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)
  89241. * @param uniformName Name of the variable.
  89242. * @param array array to be set.
  89243. * @returns this effect.
  89244. */
  89245. setArray3(uniformName: string, array: number[]): Effect;
  89246. /**
  89247. * 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)
  89248. * @param uniformName Name of the variable.
  89249. * @param array array to be set.
  89250. * @returns this effect.
  89251. */
  89252. setArray4(uniformName: string, array: number[]): Effect;
  89253. /**
  89254. * Sets matrices on a uniform variable.
  89255. * @param uniformName Name of the variable.
  89256. * @param matrices matrices to be set.
  89257. * @returns this effect.
  89258. */
  89259. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89260. /**
  89261. * Sets matrix on a uniform variable.
  89262. * @param uniformName Name of the variable.
  89263. * @param matrix matrix to be set.
  89264. * @returns this effect.
  89265. */
  89266. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89267. /**
  89268. * 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)
  89269. * @param uniformName Name of the variable.
  89270. * @param matrix matrix to be set.
  89271. * @returns this effect.
  89272. */
  89273. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89274. /**
  89275. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89276. * @param uniformName Name of the variable.
  89277. * @param matrix matrix to be set.
  89278. * @returns this effect.
  89279. */
  89280. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89281. /**
  89282. * Sets a float on a uniform variable.
  89283. * @param uniformName Name of the variable.
  89284. * @param value value to be set.
  89285. * @returns this effect.
  89286. */
  89287. setFloat(uniformName: string, value: number): Effect;
  89288. /**
  89289. * Sets a boolean on a uniform variable.
  89290. * @param uniformName Name of the variable.
  89291. * @param bool value to be set.
  89292. * @returns this effect.
  89293. */
  89294. setBool(uniformName: string, bool: boolean): Effect;
  89295. /**
  89296. * Sets a Vector2 on a uniform variable.
  89297. * @param uniformName Name of the variable.
  89298. * @param vector2 vector2 to be set.
  89299. * @returns this effect.
  89300. */
  89301. setVector2(uniformName: string, vector2: Vector2): Effect;
  89302. /**
  89303. * Sets a float2 on a uniform variable.
  89304. * @param uniformName Name of the variable.
  89305. * @param x First float in float2.
  89306. * @param y Second float in float2.
  89307. * @returns this effect.
  89308. */
  89309. setFloat2(uniformName: string, x: number, y: number): Effect;
  89310. /**
  89311. * Sets a Vector3 on a uniform variable.
  89312. * @param uniformName Name of the variable.
  89313. * @param vector3 Value to be set.
  89314. * @returns this effect.
  89315. */
  89316. setVector3(uniformName: string, vector3: Vector3): Effect;
  89317. /**
  89318. * Sets a float3 on a uniform variable.
  89319. * @param uniformName Name of the variable.
  89320. * @param x First float in float3.
  89321. * @param y Second float in float3.
  89322. * @param z Third float in float3.
  89323. * @returns this effect.
  89324. */
  89325. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89326. /**
  89327. * Sets a Vector4 on a uniform variable.
  89328. * @param uniformName Name of the variable.
  89329. * @param vector4 Value to be set.
  89330. * @returns this effect.
  89331. */
  89332. setVector4(uniformName: string, vector4: Vector4): Effect;
  89333. /**
  89334. * Sets a float4 on a uniform variable.
  89335. * @param uniformName Name of the variable.
  89336. * @param x First float in float4.
  89337. * @param y Second float in float4.
  89338. * @param z Third float in float4.
  89339. * @param w Fourth float in float4.
  89340. * @returns this effect.
  89341. */
  89342. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89343. /**
  89344. * Sets a Color3 on a uniform variable.
  89345. * @param uniformName Name of the variable.
  89346. * @param color3 Value to be set.
  89347. * @returns this effect.
  89348. */
  89349. setColor3(uniformName: string, color3: Color3): Effect;
  89350. /**
  89351. * Sets a Color4 on a uniform variable.
  89352. * @param uniformName Name of the variable.
  89353. * @param color3 Value to be set.
  89354. * @param alpha Alpha value to be set.
  89355. * @returns this effect.
  89356. */
  89357. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89358. /**
  89359. * Sets a Color4 on a uniform variable
  89360. * @param uniformName defines the name of the variable
  89361. * @param color4 defines the value to be set
  89362. * @returns this effect.
  89363. */
  89364. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89365. /** Release all associated resources */
  89366. dispose(): void;
  89367. /**
  89368. * This function will add a new shader to the shader store
  89369. * @param name the name of the shader
  89370. * @param pixelShader optional pixel shader content
  89371. * @param vertexShader optional vertex shader content
  89372. */
  89373. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89374. /**
  89375. * Store of each shader (The can be looked up using effect.key)
  89376. */
  89377. static ShadersStore: {
  89378. [key: string]: string;
  89379. };
  89380. /**
  89381. * Store of each included file for a shader (The can be looked up using effect.key)
  89382. */
  89383. static IncludesShadersStore: {
  89384. [key: string]: string;
  89385. };
  89386. /**
  89387. * Resets the cache of effects.
  89388. */
  89389. static ResetCache(): void;
  89390. }
  89391. }
  89392. declare module BABYLON {
  89393. /**
  89394. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89395. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89396. * 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;
  89397. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89398. */
  89399. export class ColorCurves {
  89400. private _dirty;
  89401. private _tempColor;
  89402. private _globalCurve;
  89403. private _highlightsCurve;
  89404. private _midtonesCurve;
  89405. private _shadowsCurve;
  89406. private _positiveCurve;
  89407. private _negativeCurve;
  89408. private _globalHue;
  89409. private _globalDensity;
  89410. private _globalSaturation;
  89411. private _globalExposure;
  89412. /**
  89413. * Gets the global Hue value.
  89414. * 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).
  89415. */
  89416. /**
  89417. * Sets the global Hue value.
  89418. * 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).
  89419. */
  89420. globalHue: number;
  89421. /**
  89422. * Gets the global Density value.
  89423. * 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.
  89424. * Values less than zero provide a filter of opposite hue.
  89425. */
  89426. /**
  89427. * Sets the global Density value.
  89428. * 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.
  89429. * Values less than zero provide a filter of opposite hue.
  89430. */
  89431. globalDensity: number;
  89432. /**
  89433. * Gets the global Saturation value.
  89434. * 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.
  89435. */
  89436. /**
  89437. * Sets the global Saturation value.
  89438. * 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.
  89439. */
  89440. globalSaturation: number;
  89441. /**
  89442. * Gets the global Exposure value.
  89443. * 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.
  89444. */
  89445. /**
  89446. * Sets the global Exposure value.
  89447. * 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.
  89448. */
  89449. globalExposure: number;
  89450. private _highlightsHue;
  89451. private _highlightsDensity;
  89452. private _highlightsSaturation;
  89453. private _highlightsExposure;
  89454. /**
  89455. * Gets the highlights Hue value.
  89456. * 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).
  89457. */
  89458. /**
  89459. * Sets the highlights Hue value.
  89460. * 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).
  89461. */
  89462. highlightsHue: number;
  89463. /**
  89464. * Gets the highlights Density value.
  89465. * 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.
  89466. * Values less than zero provide a filter of opposite hue.
  89467. */
  89468. /**
  89469. * Sets the highlights Density value.
  89470. * 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.
  89471. * Values less than zero provide a filter of opposite hue.
  89472. */
  89473. highlightsDensity: number;
  89474. /**
  89475. * Gets the highlights Saturation value.
  89476. * 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.
  89477. */
  89478. /**
  89479. * Sets the highlights Saturation value.
  89480. * 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.
  89481. */
  89482. highlightsSaturation: number;
  89483. /**
  89484. * Gets the highlights Exposure value.
  89485. * 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.
  89486. */
  89487. /**
  89488. * Sets the highlights Exposure value.
  89489. * 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.
  89490. */
  89491. highlightsExposure: number;
  89492. private _midtonesHue;
  89493. private _midtonesDensity;
  89494. private _midtonesSaturation;
  89495. private _midtonesExposure;
  89496. /**
  89497. * Gets the midtones Hue value.
  89498. * 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).
  89499. */
  89500. /**
  89501. * Sets the midtones Hue value.
  89502. * 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).
  89503. */
  89504. midtonesHue: number;
  89505. /**
  89506. * Gets the midtones Density value.
  89507. * 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.
  89508. * Values less than zero provide a filter of opposite hue.
  89509. */
  89510. /**
  89511. * Sets the midtones Density value.
  89512. * 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.
  89513. * Values less than zero provide a filter of opposite hue.
  89514. */
  89515. midtonesDensity: number;
  89516. /**
  89517. * Gets the midtones Saturation value.
  89518. * 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.
  89519. */
  89520. /**
  89521. * Sets the midtones Saturation value.
  89522. * 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.
  89523. */
  89524. midtonesSaturation: number;
  89525. /**
  89526. * Gets the midtones Exposure value.
  89527. * 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.
  89528. */
  89529. /**
  89530. * Sets the midtones Exposure value.
  89531. * 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.
  89532. */
  89533. midtonesExposure: number;
  89534. private _shadowsHue;
  89535. private _shadowsDensity;
  89536. private _shadowsSaturation;
  89537. private _shadowsExposure;
  89538. /**
  89539. * Gets the shadows Hue value.
  89540. * 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).
  89541. */
  89542. /**
  89543. * Sets the shadows Hue value.
  89544. * 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).
  89545. */
  89546. shadowsHue: number;
  89547. /**
  89548. * Gets the shadows Density value.
  89549. * 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.
  89550. * Values less than zero provide a filter of opposite hue.
  89551. */
  89552. /**
  89553. * Sets the shadows Density value.
  89554. * 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.
  89555. * Values less than zero provide a filter of opposite hue.
  89556. */
  89557. shadowsDensity: number;
  89558. /**
  89559. * Gets the shadows Saturation value.
  89560. * 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.
  89561. */
  89562. /**
  89563. * Sets the shadows Saturation value.
  89564. * 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.
  89565. */
  89566. shadowsSaturation: number;
  89567. /**
  89568. * Gets the shadows Exposure value.
  89569. * 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.
  89570. */
  89571. /**
  89572. * Sets the shadows Exposure value.
  89573. * 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.
  89574. */
  89575. shadowsExposure: number;
  89576. /**
  89577. * Returns the class name
  89578. * @returns The class name
  89579. */
  89580. getClassName(): string;
  89581. /**
  89582. * Binds the color curves to the shader.
  89583. * @param colorCurves The color curve to bind
  89584. * @param effect The effect to bind to
  89585. * @param positiveUniform The positive uniform shader parameter
  89586. * @param neutralUniform The neutral uniform shader parameter
  89587. * @param negativeUniform The negative uniform shader parameter
  89588. */
  89589. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89590. /**
  89591. * Prepare the list of uniforms associated with the ColorCurves effects.
  89592. * @param uniformsList The list of uniforms used in the effect
  89593. */
  89594. static PrepareUniforms(uniformsList: string[]): void;
  89595. /**
  89596. * Returns color grading data based on a hue, density, saturation and exposure value.
  89597. * @param filterHue The hue of the color filter.
  89598. * @param filterDensity The density of the color filter.
  89599. * @param saturation The saturation.
  89600. * @param exposure The exposure.
  89601. * @param result The result data container.
  89602. */
  89603. private getColorGradingDataToRef;
  89604. /**
  89605. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89606. * @param value The input slider value in range [-100,100].
  89607. * @returns Adjusted value.
  89608. */
  89609. private static applyColorGradingSliderNonlinear;
  89610. /**
  89611. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89612. * @param hue The hue (H) input.
  89613. * @param saturation The saturation (S) input.
  89614. * @param brightness The brightness (B) input.
  89615. * @result An RGBA color represented as Vector4.
  89616. */
  89617. private static fromHSBToRef;
  89618. /**
  89619. * Returns a value clamped between min and max
  89620. * @param value The value to clamp
  89621. * @param min The minimum of value
  89622. * @param max The maximum of value
  89623. * @returns The clamped value.
  89624. */
  89625. private static clamp;
  89626. /**
  89627. * Clones the current color curve instance.
  89628. * @return The cloned curves
  89629. */
  89630. clone(): ColorCurves;
  89631. /**
  89632. * Serializes the current color curve instance to a json representation.
  89633. * @return a JSON representation
  89634. */
  89635. serialize(): any;
  89636. /**
  89637. * Parses the color curve from a json representation.
  89638. * @param source the JSON source to parse
  89639. * @return The parsed curves
  89640. */
  89641. static Parse(source: any): ColorCurves;
  89642. }
  89643. }
  89644. declare module BABYLON {
  89645. /**
  89646. * Interface to follow in your material defines to integrate easily the
  89647. * Image proccessing functions.
  89648. * @hidden
  89649. */
  89650. export interface IImageProcessingConfigurationDefines {
  89651. IMAGEPROCESSING: boolean;
  89652. VIGNETTE: boolean;
  89653. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89654. VIGNETTEBLENDMODEOPAQUE: boolean;
  89655. TONEMAPPING: boolean;
  89656. TONEMAPPING_ACES: boolean;
  89657. CONTRAST: boolean;
  89658. EXPOSURE: boolean;
  89659. COLORCURVES: boolean;
  89660. COLORGRADING: boolean;
  89661. COLORGRADING3D: boolean;
  89662. SAMPLER3DGREENDEPTH: boolean;
  89663. SAMPLER3DBGRMAP: boolean;
  89664. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89665. }
  89666. /**
  89667. * @hidden
  89668. */
  89669. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89670. IMAGEPROCESSING: boolean;
  89671. VIGNETTE: boolean;
  89672. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89673. VIGNETTEBLENDMODEOPAQUE: boolean;
  89674. TONEMAPPING: boolean;
  89675. TONEMAPPING_ACES: boolean;
  89676. CONTRAST: boolean;
  89677. COLORCURVES: boolean;
  89678. COLORGRADING: boolean;
  89679. COLORGRADING3D: boolean;
  89680. SAMPLER3DGREENDEPTH: boolean;
  89681. SAMPLER3DBGRMAP: boolean;
  89682. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89683. EXPOSURE: boolean;
  89684. constructor();
  89685. }
  89686. /**
  89687. * This groups together the common properties used for image processing either in direct forward pass
  89688. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89689. * or not.
  89690. */
  89691. export class ImageProcessingConfiguration {
  89692. /**
  89693. * Default tone mapping applied in BabylonJS.
  89694. */
  89695. static readonly TONEMAPPING_STANDARD: number;
  89696. /**
  89697. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89698. * to other engines rendering to increase portability.
  89699. */
  89700. static readonly TONEMAPPING_ACES: number;
  89701. /**
  89702. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89703. */
  89704. colorCurves: Nullable<ColorCurves>;
  89705. private _colorCurvesEnabled;
  89706. /**
  89707. * Gets wether the color curves effect is enabled.
  89708. */
  89709. /**
  89710. * Sets wether the color curves effect is enabled.
  89711. */
  89712. colorCurvesEnabled: boolean;
  89713. private _colorGradingTexture;
  89714. /**
  89715. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89716. */
  89717. /**
  89718. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89719. */
  89720. colorGradingTexture: Nullable<BaseTexture>;
  89721. private _colorGradingEnabled;
  89722. /**
  89723. * Gets wether the color grading effect is enabled.
  89724. */
  89725. /**
  89726. * Sets wether the color grading effect is enabled.
  89727. */
  89728. colorGradingEnabled: boolean;
  89729. private _colorGradingWithGreenDepth;
  89730. /**
  89731. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89732. */
  89733. /**
  89734. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89735. */
  89736. colorGradingWithGreenDepth: boolean;
  89737. private _colorGradingBGR;
  89738. /**
  89739. * Gets wether the color grading texture contains BGR values.
  89740. */
  89741. /**
  89742. * Sets wether the color grading texture contains BGR values.
  89743. */
  89744. colorGradingBGR: boolean;
  89745. /** @hidden */
  89746. _exposure: number;
  89747. /**
  89748. * Gets the Exposure used in the effect.
  89749. */
  89750. /**
  89751. * Sets the Exposure used in the effect.
  89752. */
  89753. exposure: number;
  89754. private _toneMappingEnabled;
  89755. /**
  89756. * Gets wether the tone mapping effect is enabled.
  89757. */
  89758. /**
  89759. * Sets wether the tone mapping effect is enabled.
  89760. */
  89761. toneMappingEnabled: boolean;
  89762. private _toneMappingType;
  89763. /**
  89764. * Gets the type of tone mapping effect.
  89765. */
  89766. /**
  89767. * Sets the type of tone mapping effect used in BabylonJS.
  89768. */
  89769. toneMappingType: number;
  89770. protected _contrast: number;
  89771. /**
  89772. * Gets the contrast used in the effect.
  89773. */
  89774. /**
  89775. * Sets the contrast used in the effect.
  89776. */
  89777. contrast: number;
  89778. /**
  89779. * Vignette stretch size.
  89780. */
  89781. vignetteStretch: number;
  89782. /**
  89783. * Vignette centre X Offset.
  89784. */
  89785. vignetteCentreX: number;
  89786. /**
  89787. * Vignette centre Y Offset.
  89788. */
  89789. vignetteCentreY: number;
  89790. /**
  89791. * Vignette weight or intensity of the vignette effect.
  89792. */
  89793. vignetteWeight: number;
  89794. /**
  89795. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89796. * if vignetteEnabled is set to true.
  89797. */
  89798. vignetteColor: Color4;
  89799. /**
  89800. * Camera field of view used by the Vignette effect.
  89801. */
  89802. vignetteCameraFov: number;
  89803. private _vignetteBlendMode;
  89804. /**
  89805. * Gets the vignette blend mode allowing different kind of effect.
  89806. */
  89807. /**
  89808. * Sets the vignette blend mode allowing different kind of effect.
  89809. */
  89810. vignetteBlendMode: number;
  89811. private _vignetteEnabled;
  89812. /**
  89813. * Gets wether the vignette effect is enabled.
  89814. */
  89815. /**
  89816. * Sets wether the vignette effect is enabled.
  89817. */
  89818. vignetteEnabled: boolean;
  89819. private _applyByPostProcess;
  89820. /**
  89821. * Gets wether the image processing is applied through a post process or not.
  89822. */
  89823. /**
  89824. * Sets wether the image processing is applied through a post process or not.
  89825. */
  89826. applyByPostProcess: boolean;
  89827. private _isEnabled;
  89828. /**
  89829. * Gets wether the image processing is enabled or not.
  89830. */
  89831. /**
  89832. * Sets wether the image processing is enabled or not.
  89833. */
  89834. isEnabled: boolean;
  89835. /**
  89836. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89837. */
  89838. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89839. /**
  89840. * Method called each time the image processing information changes requires to recompile the effect.
  89841. */
  89842. protected _updateParameters(): void;
  89843. /**
  89844. * Gets the current class name.
  89845. * @return "ImageProcessingConfiguration"
  89846. */
  89847. getClassName(): string;
  89848. /**
  89849. * Prepare the list of uniforms associated with the Image Processing effects.
  89850. * @param uniforms The list of uniforms used in the effect
  89851. * @param defines the list of defines currently in use
  89852. */
  89853. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89854. /**
  89855. * Prepare the list of samplers associated with the Image Processing effects.
  89856. * @param samplersList The list of uniforms used in the effect
  89857. * @param defines the list of defines currently in use
  89858. */
  89859. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89860. /**
  89861. * Prepare the list of defines associated to the shader.
  89862. * @param defines the list of defines to complete
  89863. * @param forPostProcess Define if we are currently in post process mode or not
  89864. */
  89865. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89866. /**
  89867. * Returns true if all the image processing information are ready.
  89868. * @returns True if ready, otherwise, false
  89869. */
  89870. isReady(): boolean;
  89871. /**
  89872. * Binds the image processing to the shader.
  89873. * @param effect The effect to bind to
  89874. * @param aspectRatio Define the current aspect ratio of the effect
  89875. */
  89876. bind(effect: Effect, aspectRatio?: number): void;
  89877. /**
  89878. * Clones the current image processing instance.
  89879. * @return The cloned image processing
  89880. */
  89881. clone(): ImageProcessingConfiguration;
  89882. /**
  89883. * Serializes the current image processing instance to a json representation.
  89884. * @return a JSON representation
  89885. */
  89886. serialize(): any;
  89887. /**
  89888. * Parses the image processing from a json representation.
  89889. * @param source the JSON source to parse
  89890. * @return The parsed image processing
  89891. */
  89892. static Parse(source: any): ImageProcessingConfiguration;
  89893. private static _VIGNETTEMODE_MULTIPLY;
  89894. private static _VIGNETTEMODE_OPAQUE;
  89895. /**
  89896. * Used to apply the vignette as a mix with the pixel color.
  89897. */
  89898. static readonly VIGNETTEMODE_MULTIPLY: number;
  89899. /**
  89900. * Used to apply the vignette as a replacement of the pixel color.
  89901. */
  89902. static readonly VIGNETTEMODE_OPAQUE: number;
  89903. }
  89904. }
  89905. declare module BABYLON {
  89906. /**
  89907. * This represents all the required information to add a fresnel effect on a material:
  89908. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89909. */
  89910. export class FresnelParameters {
  89911. private _isEnabled;
  89912. /**
  89913. * Define if the fresnel effect is enable or not.
  89914. */
  89915. isEnabled: boolean;
  89916. /**
  89917. * Define the color used on edges (grazing angle)
  89918. */
  89919. leftColor: Color3;
  89920. /**
  89921. * Define the color used on center
  89922. */
  89923. rightColor: Color3;
  89924. /**
  89925. * Define bias applied to computed fresnel term
  89926. */
  89927. bias: number;
  89928. /**
  89929. * Defined the power exponent applied to fresnel term
  89930. */
  89931. power: number;
  89932. /**
  89933. * Clones the current fresnel and its valuues
  89934. * @returns a clone fresnel configuration
  89935. */
  89936. clone(): FresnelParameters;
  89937. /**
  89938. * Serializes the current fresnel parameters to a JSON representation.
  89939. * @return the JSON serialization
  89940. */
  89941. serialize(): any;
  89942. /**
  89943. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89944. * @param parsedFresnelParameters Define the JSON representation
  89945. * @returns the parsed parameters
  89946. */
  89947. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89948. }
  89949. }
  89950. declare module BABYLON {
  89951. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89952. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89953. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89954. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89955. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89956. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89957. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89958. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89959. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89960. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89961. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89962. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89963. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89964. /**
  89965. * Decorator used to define property that can be serialized as reference to a camera
  89966. * @param sourceName defines the name of the property to decorate
  89967. */
  89968. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89969. /**
  89970. * Class used to help serialization objects
  89971. */
  89972. export class SerializationHelper {
  89973. /** hidden */
  89974. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89975. /** hidden */
  89976. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89977. /** hidden */
  89978. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89979. /** hidden */
  89980. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89981. /**
  89982. * Appends the serialized animations from the source animations
  89983. * @param source Source containing the animations
  89984. * @param destination Target to store the animations
  89985. */
  89986. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89987. /**
  89988. * Static function used to serialized a specific entity
  89989. * @param entity defines the entity to serialize
  89990. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89991. * @returns a JSON compatible object representing the serialization of the entity
  89992. */
  89993. static Serialize<T>(entity: T, serializationObject?: any): any;
  89994. /**
  89995. * Creates a new entity from a serialization data object
  89996. * @param creationFunction defines a function used to instanciated the new entity
  89997. * @param source defines the source serialization data
  89998. * @param scene defines the hosting scene
  89999. * @param rootUrl defines the root url for resources
  90000. * @returns a new entity
  90001. */
  90002. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90003. /**
  90004. * Clones an object
  90005. * @param creationFunction defines the function used to instanciate the new object
  90006. * @param source defines the source object
  90007. * @returns the cloned object
  90008. */
  90009. static Clone<T>(creationFunction: () => T, source: T): T;
  90010. /**
  90011. * Instanciates a new object based on a source one (some data will be shared between both object)
  90012. * @param creationFunction defines the function used to instanciate the new object
  90013. * @param source defines the source object
  90014. * @returns the new object
  90015. */
  90016. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90017. }
  90018. }
  90019. declare module BABYLON {
  90020. /**
  90021. * This is the base class of all the camera used in the application.
  90022. * @see http://doc.babylonjs.com/features/cameras
  90023. */
  90024. export class Camera extends Node {
  90025. /** @hidden */
  90026. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90027. /**
  90028. * This is the default projection mode used by the cameras.
  90029. * It helps recreating a feeling of perspective and better appreciate depth.
  90030. * This is the best way to simulate real life cameras.
  90031. */
  90032. static readonly PERSPECTIVE_CAMERA: number;
  90033. /**
  90034. * This helps creating camera with an orthographic mode.
  90035. * 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.
  90036. */
  90037. static readonly ORTHOGRAPHIC_CAMERA: number;
  90038. /**
  90039. * This is the default FOV mode for perspective cameras.
  90040. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90041. */
  90042. static readonly FOVMODE_VERTICAL_FIXED: number;
  90043. /**
  90044. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90045. */
  90046. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90047. /**
  90048. * This specifies ther is no need for a camera rig.
  90049. * Basically only one eye is rendered corresponding to the camera.
  90050. */
  90051. static readonly RIG_MODE_NONE: number;
  90052. /**
  90053. * Simulates a camera Rig with one blue eye and one red eye.
  90054. * This can be use with 3d blue and red glasses.
  90055. */
  90056. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90057. /**
  90058. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90059. */
  90060. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90061. /**
  90062. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90063. */
  90064. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90065. /**
  90066. * Defines that both eyes of the camera will be rendered over under each other.
  90067. */
  90068. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90069. /**
  90070. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90071. */
  90072. static readonly RIG_MODE_VR: number;
  90073. /**
  90074. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90075. */
  90076. static readonly RIG_MODE_WEBVR: number;
  90077. /**
  90078. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90079. */
  90080. static readonly RIG_MODE_CUSTOM: number;
  90081. /**
  90082. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90083. */
  90084. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90085. /**
  90086. * Define the input manager associated with the camera.
  90087. */
  90088. inputs: CameraInputsManager<Camera>;
  90089. /** @hidden */
  90090. _position: Vector3;
  90091. /**
  90092. * Define the current local position of the camera in the scene
  90093. */
  90094. position: Vector3;
  90095. /**
  90096. * The vector the camera should consider as up.
  90097. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90098. */
  90099. upVector: Vector3;
  90100. /**
  90101. * Define the current limit on the left side for an orthographic camera
  90102. * In scene unit
  90103. */
  90104. orthoLeft: Nullable<number>;
  90105. /**
  90106. * Define the current limit on the right side for an orthographic camera
  90107. * In scene unit
  90108. */
  90109. orthoRight: Nullable<number>;
  90110. /**
  90111. * Define the current limit on the bottom side for an orthographic camera
  90112. * In scene unit
  90113. */
  90114. orthoBottom: Nullable<number>;
  90115. /**
  90116. * Define the current limit on the top side for an orthographic camera
  90117. * In scene unit
  90118. */
  90119. orthoTop: Nullable<number>;
  90120. /**
  90121. * Field Of View is set in Radians. (default is 0.8)
  90122. */
  90123. fov: number;
  90124. /**
  90125. * Define the minimum distance the camera can see from.
  90126. * This is important to note that the depth buffer are not infinite and the closer it starts
  90127. * the more your scene might encounter depth fighting issue.
  90128. */
  90129. minZ: number;
  90130. /**
  90131. * Define the maximum distance the camera can see to.
  90132. * This is important to note that the depth buffer are not infinite and the further it end
  90133. * the more your scene might encounter depth fighting issue.
  90134. */
  90135. maxZ: number;
  90136. /**
  90137. * Define the default inertia of the camera.
  90138. * This helps giving a smooth feeling to the camera movement.
  90139. */
  90140. inertia: number;
  90141. /**
  90142. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90143. */
  90144. mode: number;
  90145. /**
  90146. * Define wether the camera is intermediate.
  90147. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90148. */
  90149. isIntermediate: boolean;
  90150. /**
  90151. * Define the viewport of the camera.
  90152. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90153. */
  90154. viewport: Viewport;
  90155. /**
  90156. * Restricts the camera to viewing objects with the same layerMask.
  90157. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90158. */
  90159. layerMask: number;
  90160. /**
  90161. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90162. */
  90163. fovMode: number;
  90164. /**
  90165. * Rig mode of the camera.
  90166. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90167. * This is normally controlled byt the camera themselves as internal use.
  90168. */
  90169. cameraRigMode: number;
  90170. /**
  90171. * Defines the distance between both "eyes" in case of a RIG
  90172. */
  90173. interaxialDistance: number;
  90174. /**
  90175. * Defines if stereoscopic rendering is done side by side or over under.
  90176. */
  90177. isStereoscopicSideBySide: boolean;
  90178. /**
  90179. * 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
  90180. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90181. * else in the scene.
  90182. */
  90183. customRenderTargets: RenderTargetTexture[];
  90184. /**
  90185. * When set, the camera will render to this render target instead of the default canvas
  90186. */
  90187. outputRenderTarget: Nullable<RenderTargetTexture>;
  90188. /**
  90189. * Observable triggered when the camera view matrix has changed.
  90190. */
  90191. onViewMatrixChangedObservable: Observable<Camera>;
  90192. /**
  90193. * Observable triggered when the camera Projection matrix has changed.
  90194. */
  90195. onProjectionMatrixChangedObservable: Observable<Camera>;
  90196. /**
  90197. * Observable triggered when the inputs have been processed.
  90198. */
  90199. onAfterCheckInputsObservable: Observable<Camera>;
  90200. /**
  90201. * Observable triggered when reset has been called and applied to the camera.
  90202. */
  90203. onRestoreStateObservable: Observable<Camera>;
  90204. /** @hidden */
  90205. _cameraRigParams: any;
  90206. /** @hidden */
  90207. _rigCameras: Camera[];
  90208. /** @hidden */
  90209. _rigPostProcess: Nullable<PostProcess>;
  90210. protected _webvrViewMatrix: Matrix;
  90211. /** @hidden */
  90212. _skipRendering: boolean;
  90213. /** @hidden */
  90214. _projectionMatrix: Matrix;
  90215. /** @hidden */
  90216. _postProcesses: Nullable<PostProcess>[];
  90217. /** @hidden */
  90218. _activeMeshes: SmartArray<AbstractMesh>;
  90219. protected _globalPosition: Vector3;
  90220. /** hidden */
  90221. _computedViewMatrix: Matrix;
  90222. private _doNotComputeProjectionMatrix;
  90223. private _transformMatrix;
  90224. private _frustumPlanes;
  90225. private _refreshFrustumPlanes;
  90226. private _storedFov;
  90227. private _stateStored;
  90228. /**
  90229. * Instantiates a new camera object.
  90230. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90231. * @see http://doc.babylonjs.com/features/cameras
  90232. * @param name Defines the name of the camera in the scene
  90233. * @param position Defines the position of the camera
  90234. * @param scene Defines the scene the camera belongs too
  90235. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90236. */
  90237. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90238. /**
  90239. * Store current camera state (fov, position, etc..)
  90240. * @returns the camera
  90241. */
  90242. storeState(): Camera;
  90243. /**
  90244. * Restores the camera state values if it has been stored. You must call storeState() first
  90245. */
  90246. protected _restoreStateValues(): boolean;
  90247. /**
  90248. * Restored camera state. You must call storeState() first.
  90249. * @returns true if restored and false otherwise
  90250. */
  90251. restoreState(): boolean;
  90252. /**
  90253. * Gets the class name of the camera.
  90254. * @returns the class name
  90255. */
  90256. getClassName(): string;
  90257. /** @hidden */
  90258. readonly _isCamera: boolean;
  90259. /**
  90260. * Gets a string representation of the camera useful for debug purpose.
  90261. * @param fullDetails Defines that a more verboe level of logging is required
  90262. * @returns the string representation
  90263. */
  90264. toString(fullDetails?: boolean): string;
  90265. /**
  90266. * Gets the current world space position of the camera.
  90267. */
  90268. readonly globalPosition: Vector3;
  90269. /**
  90270. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90271. * @returns the active meshe list
  90272. */
  90273. getActiveMeshes(): SmartArray<AbstractMesh>;
  90274. /**
  90275. * Check wether a mesh is part of the current active mesh list of the camera
  90276. * @param mesh Defines the mesh to check
  90277. * @returns true if active, false otherwise
  90278. */
  90279. isActiveMesh(mesh: Mesh): boolean;
  90280. /**
  90281. * Is this camera ready to be used/rendered
  90282. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90283. * @return true if the camera is ready
  90284. */
  90285. isReady(completeCheck?: boolean): boolean;
  90286. /** @hidden */
  90287. _initCache(): void;
  90288. /** @hidden */
  90289. _updateCache(ignoreParentClass?: boolean): void;
  90290. /** @hidden */
  90291. _isSynchronized(): boolean;
  90292. /** @hidden */
  90293. _isSynchronizedViewMatrix(): boolean;
  90294. /** @hidden */
  90295. _isSynchronizedProjectionMatrix(): boolean;
  90296. /**
  90297. * Attach the input controls to a specific dom element to get the input from.
  90298. * @param element Defines the element the controls should be listened from
  90299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90300. */
  90301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90302. /**
  90303. * Detach the current controls from the specified dom element.
  90304. * @param element Defines the element to stop listening the inputs from
  90305. */
  90306. detachControl(element: HTMLElement): void;
  90307. /**
  90308. * Update the camera state according to the different inputs gathered during the frame.
  90309. */
  90310. update(): void;
  90311. /** @hidden */
  90312. _checkInputs(): void;
  90313. /** @hidden */
  90314. readonly rigCameras: Camera[];
  90315. /**
  90316. * Gets the post process used by the rig cameras
  90317. */
  90318. readonly rigPostProcess: Nullable<PostProcess>;
  90319. /**
  90320. * Internal, gets the first post proces.
  90321. * @returns the first post process to be run on this camera.
  90322. */
  90323. _getFirstPostProcess(): Nullable<PostProcess>;
  90324. private _cascadePostProcessesToRigCams;
  90325. /**
  90326. * Attach a post process to the camera.
  90327. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90328. * @param postProcess The post process to attach to the camera
  90329. * @param insertAt The position of the post process in case several of them are in use in the scene
  90330. * @returns the position the post process has been inserted at
  90331. */
  90332. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90333. /**
  90334. * Detach a post process to the camera.
  90335. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90336. * @param postProcess The post process to detach from the camera
  90337. */
  90338. detachPostProcess(postProcess: PostProcess): void;
  90339. /**
  90340. * Gets the current world matrix of the camera
  90341. */
  90342. getWorldMatrix(): Matrix;
  90343. /** @hidden */
  90344. _getViewMatrix(): Matrix;
  90345. /**
  90346. * Gets the current view matrix of the camera.
  90347. * @param force forces the camera to recompute the matrix without looking at the cached state
  90348. * @returns the view matrix
  90349. */
  90350. getViewMatrix(force?: boolean): Matrix;
  90351. /**
  90352. * Freeze the projection matrix.
  90353. * It will prevent the cache check of the camera projection compute and can speed up perf
  90354. * if no parameter of the camera are meant to change
  90355. * @param projection Defines manually a projection if necessary
  90356. */
  90357. freezeProjectionMatrix(projection?: Matrix): void;
  90358. /**
  90359. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90360. */
  90361. unfreezeProjectionMatrix(): void;
  90362. /**
  90363. * Gets the current projection matrix of the camera.
  90364. * @param force forces the camera to recompute the matrix without looking at the cached state
  90365. * @returns the projection matrix
  90366. */
  90367. getProjectionMatrix(force?: boolean): Matrix;
  90368. /**
  90369. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90370. * @returns a Matrix
  90371. */
  90372. getTransformationMatrix(): Matrix;
  90373. private _updateFrustumPlanes;
  90374. /**
  90375. * Checks if a cullable object (mesh...) is in the camera frustum
  90376. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90377. * @param target The object to check
  90378. * @returns true if the object is in frustum otherwise false
  90379. */
  90380. isInFrustum(target: ICullable): boolean;
  90381. /**
  90382. * Checks if a cullable object (mesh...) is in the camera frustum
  90383. * Unlike isInFrustum this cheks the full bounding box
  90384. * @param target The object to check
  90385. * @returns true if the object is in frustum otherwise false
  90386. */
  90387. isCompletelyInFrustum(target: ICullable): boolean;
  90388. /**
  90389. * Gets a ray in the forward direction from the camera.
  90390. * @param length Defines the length of the ray to create
  90391. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90392. * @param origin Defines the start point of the ray which defaults to the camera position
  90393. * @returns the forward ray
  90394. */
  90395. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90396. /**
  90397. * Releases resources associated with this node.
  90398. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90399. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90400. */
  90401. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90402. /** @hidden */
  90403. _isLeftCamera: boolean;
  90404. /**
  90405. * Gets the left camera of a rig setup in case of Rigged Camera
  90406. */
  90407. readonly isLeftCamera: boolean;
  90408. /** @hidden */
  90409. _isRightCamera: boolean;
  90410. /**
  90411. * Gets the right camera of a rig setup in case of Rigged Camera
  90412. */
  90413. readonly isRightCamera: boolean;
  90414. /**
  90415. * Gets the left camera of a rig setup in case of Rigged Camera
  90416. */
  90417. readonly leftCamera: Nullable<FreeCamera>;
  90418. /**
  90419. * Gets the right camera of a rig setup in case of Rigged Camera
  90420. */
  90421. readonly rightCamera: Nullable<FreeCamera>;
  90422. /**
  90423. * Gets the left camera target of a rig setup in case of Rigged Camera
  90424. * @returns the target position
  90425. */
  90426. getLeftTarget(): Nullable<Vector3>;
  90427. /**
  90428. * Gets the right camera target of a rig setup in case of Rigged Camera
  90429. * @returns the target position
  90430. */
  90431. getRightTarget(): Nullable<Vector3>;
  90432. /**
  90433. * @hidden
  90434. */
  90435. setCameraRigMode(mode: number, rigParams: any): void;
  90436. /** @hidden */
  90437. static _setStereoscopicRigMode(camera: Camera): void;
  90438. /** @hidden */
  90439. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90440. /** @hidden */
  90441. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90442. /** @hidden */
  90443. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90444. /** @hidden */
  90445. _getVRProjectionMatrix(): Matrix;
  90446. protected _updateCameraRotationMatrix(): void;
  90447. protected _updateWebVRCameraRotationMatrix(): void;
  90448. /**
  90449. * This function MUST be overwritten by the different WebVR cameras available.
  90450. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90451. * @hidden
  90452. */
  90453. _getWebVRProjectionMatrix(): Matrix;
  90454. /**
  90455. * This function MUST be overwritten by the different WebVR cameras available.
  90456. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90457. * @hidden
  90458. */
  90459. _getWebVRViewMatrix(): Matrix;
  90460. /** @hidden */
  90461. setCameraRigParameter(name: string, value: any): void;
  90462. /**
  90463. * needs to be overridden by children so sub has required properties to be copied
  90464. * @hidden
  90465. */
  90466. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90467. /**
  90468. * May need to be overridden by children
  90469. * @hidden
  90470. */
  90471. _updateRigCameras(): void;
  90472. /** @hidden */
  90473. _setupInputs(): void;
  90474. /**
  90475. * Serialiaze the camera setup to a json represention
  90476. * @returns the JSON representation
  90477. */
  90478. serialize(): any;
  90479. /**
  90480. * Clones the current camera.
  90481. * @param name The cloned camera name
  90482. * @returns the cloned camera
  90483. */
  90484. clone(name: string): Camera;
  90485. /**
  90486. * Gets the direction of the camera relative to a given local axis.
  90487. * @param localAxis Defines the reference axis to provide a relative direction.
  90488. * @return the direction
  90489. */
  90490. getDirection(localAxis: Vector3): Vector3;
  90491. /**
  90492. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90493. * @param localAxis Defines the reference axis to provide a relative direction.
  90494. * @param result Defines the vector to store the result in
  90495. */
  90496. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90497. /**
  90498. * Gets a camera constructor for a given camera type
  90499. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90500. * @param name The name of the camera the result will be able to instantiate
  90501. * @param scene The scene the result will construct the camera in
  90502. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90503. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90504. * @returns a factory method to construc the camera
  90505. */
  90506. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90507. /**
  90508. * Compute the world matrix of the camera.
  90509. * @returns the camera workd matrix
  90510. */
  90511. computeWorldMatrix(): Matrix;
  90512. /**
  90513. * Parse a JSON and creates the camera from the parsed information
  90514. * @param parsedCamera The JSON to parse
  90515. * @param scene The scene to instantiate the camera in
  90516. * @returns the newly constructed camera
  90517. */
  90518. static Parse(parsedCamera: any, scene: Scene): Camera;
  90519. }
  90520. }
  90521. declare module BABYLON {
  90522. /**
  90523. * Interface for any object that can request an animation frame
  90524. */
  90525. export interface ICustomAnimationFrameRequester {
  90526. /**
  90527. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90528. */
  90529. renderFunction?: Function;
  90530. /**
  90531. * Called to request the next frame to render to
  90532. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90533. */
  90534. requestAnimationFrame: Function;
  90535. /**
  90536. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90537. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90538. */
  90539. requestID?: number;
  90540. }
  90541. /**
  90542. * Interface containing an array of animations
  90543. */
  90544. export interface IAnimatable {
  90545. /**
  90546. * Array of animations
  90547. */
  90548. animations: Nullable<Array<Animation>>;
  90549. }
  90550. /** Interface used by value gradients (color, factor, ...) */
  90551. export interface IValueGradient {
  90552. /**
  90553. * Gets or sets the gradient value (between 0 and 1)
  90554. */
  90555. gradient: number;
  90556. }
  90557. /** Class used to store color4 gradient */
  90558. export class ColorGradient implements IValueGradient {
  90559. /**
  90560. * Gets or sets the gradient value (between 0 and 1)
  90561. */
  90562. gradient: number;
  90563. /**
  90564. * Gets or sets first associated color
  90565. */
  90566. color1: Color4;
  90567. /**
  90568. * Gets or sets second associated color
  90569. */
  90570. color2?: Color4;
  90571. /**
  90572. * Will get a color picked randomly between color1 and color2.
  90573. * If color2 is undefined then color1 will be used
  90574. * @param result defines the target Color4 to store the result in
  90575. */
  90576. getColorToRef(result: Color4): void;
  90577. }
  90578. /** Class used to store color 3 gradient */
  90579. export class Color3Gradient implements IValueGradient {
  90580. /**
  90581. * Gets or sets the gradient value (between 0 and 1)
  90582. */
  90583. gradient: number;
  90584. /**
  90585. * Gets or sets the associated color
  90586. */
  90587. color: Color3;
  90588. }
  90589. /** Class used to store factor gradient */
  90590. export class FactorGradient implements IValueGradient {
  90591. /**
  90592. * Gets or sets the gradient value (between 0 and 1)
  90593. */
  90594. gradient: number;
  90595. /**
  90596. * Gets or sets first associated factor
  90597. */
  90598. factor1: number;
  90599. /**
  90600. * Gets or sets second associated factor
  90601. */
  90602. factor2?: number;
  90603. /**
  90604. * Will get a number picked randomly between factor1 and factor2.
  90605. * If factor2 is undefined then factor1 will be used
  90606. * @returns the picked number
  90607. */
  90608. getFactor(): number;
  90609. }
  90610. /**
  90611. * @ignore
  90612. * Application error to support additional information when loading a file
  90613. */
  90614. export class LoadFileError extends Error {
  90615. /** defines the optional web request */
  90616. request?: WebRequest | undefined;
  90617. private static _setPrototypeOf;
  90618. /**
  90619. * Creates a new LoadFileError
  90620. * @param message defines the message of the error
  90621. * @param request defines the optional web request
  90622. */
  90623. constructor(message: string,
  90624. /** defines the optional web request */
  90625. request?: WebRequest | undefined);
  90626. }
  90627. /**
  90628. * Class used to define a retry strategy when error happens while loading assets
  90629. */
  90630. export class RetryStrategy {
  90631. /**
  90632. * Function used to defines an exponential back off strategy
  90633. * @param maxRetries defines the maximum number of retries (3 by default)
  90634. * @param baseInterval defines the interval between retries
  90635. * @returns the strategy function to use
  90636. */
  90637. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90638. }
  90639. /**
  90640. * File request interface
  90641. */
  90642. export interface IFileRequest {
  90643. /**
  90644. * Raised when the request is complete (success or error).
  90645. */
  90646. onCompleteObservable: Observable<IFileRequest>;
  90647. /**
  90648. * Aborts the request for a file.
  90649. */
  90650. abort: () => void;
  90651. }
  90652. /**
  90653. * Class containing a set of static utilities functions
  90654. */
  90655. export class Tools {
  90656. /**
  90657. * Gets or sets the base URL to use to load assets
  90658. */
  90659. static BaseUrl: string;
  90660. /**
  90661. * Enable/Disable Custom HTTP Request Headers globally.
  90662. * default = false
  90663. * @see CustomRequestHeaders
  90664. */
  90665. static UseCustomRequestHeaders: boolean;
  90666. /**
  90667. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90668. * i.e. when loading files, where the server/service expects an Authorization header
  90669. */
  90670. static CustomRequestHeaders: {
  90671. [key: string]: string;
  90672. };
  90673. /**
  90674. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90675. */
  90676. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90677. /**
  90678. * Default behaviour for cors in the application.
  90679. * It can be a string if the expected behavior is identical in the entire app.
  90680. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90681. */
  90682. static CorsBehavior: string | ((url: string | string[]) => string);
  90683. /**
  90684. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90685. * @ignorenaming
  90686. */
  90687. static UseFallbackTexture: boolean;
  90688. /**
  90689. * Use this object to register external classes like custom textures or material
  90690. * to allow the laoders to instantiate them
  90691. */
  90692. static RegisteredExternalClasses: {
  90693. [key: string]: Object;
  90694. };
  90695. /**
  90696. * Texture content used if a texture cannot loaded
  90697. * @ignorenaming
  90698. */
  90699. static fallbackTexture: string;
  90700. /**
  90701. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90702. * @param u defines the coordinate on X axis
  90703. * @param v defines the coordinate on Y axis
  90704. * @param width defines the width of the source data
  90705. * @param height defines the height of the source data
  90706. * @param pixels defines the source byte array
  90707. * @param color defines the output color
  90708. */
  90709. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90710. /**
  90711. * Interpolates between a and b via alpha
  90712. * @param a The lower value (returned when alpha = 0)
  90713. * @param b The upper value (returned when alpha = 1)
  90714. * @param alpha The interpolation-factor
  90715. * @return The mixed value
  90716. */
  90717. static Mix(a: number, b: number, alpha: number): number;
  90718. /**
  90719. * Tries to instantiate a new object from a given class name
  90720. * @param className defines the class name to instantiate
  90721. * @returns the new object or null if the system was not able to do the instantiation
  90722. */
  90723. static Instantiate(className: string): any;
  90724. /**
  90725. * Provides a slice function that will work even on IE
  90726. * @param data defines the array to slice
  90727. * @param start defines the start of the data (optional)
  90728. * @param end defines the end of the data (optional)
  90729. * @returns the new sliced array
  90730. */
  90731. static Slice<T>(data: T, start?: number, end?: number): T;
  90732. /**
  90733. * Polyfill for setImmediate
  90734. * @param action defines the action to execute after the current execution block
  90735. */
  90736. static SetImmediate(action: () => void): void;
  90737. /**
  90738. * Function indicating if a number is an exponent of 2
  90739. * @param value defines the value to test
  90740. * @returns true if the value is an exponent of 2
  90741. */
  90742. static IsExponentOfTwo(value: number): boolean;
  90743. private static _tmpFloatArray;
  90744. /**
  90745. * Returns the nearest 32-bit single precision float representation of a Number
  90746. * @param value A Number. If the parameter is of a different type, it will get converted
  90747. * to a number or to NaN if it cannot be converted
  90748. * @returns number
  90749. */
  90750. static FloatRound(value: number): number;
  90751. /**
  90752. * Find the next highest power of two.
  90753. * @param x Number to start search from.
  90754. * @return Next highest power of two.
  90755. */
  90756. static CeilingPOT(x: number): number;
  90757. /**
  90758. * Find the next lowest power of two.
  90759. * @param x Number to start search from.
  90760. * @return Next lowest power of two.
  90761. */
  90762. static FloorPOT(x: number): number;
  90763. /**
  90764. * Find the nearest power of two.
  90765. * @param x Number to start search from.
  90766. * @return Next nearest power of two.
  90767. */
  90768. static NearestPOT(x: number): number;
  90769. /**
  90770. * Get the closest exponent of two
  90771. * @param value defines the value to approximate
  90772. * @param max defines the maximum value to return
  90773. * @param mode defines how to define the closest value
  90774. * @returns closest exponent of two of the given value
  90775. */
  90776. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90777. /**
  90778. * Extracts the filename from a path
  90779. * @param path defines the path to use
  90780. * @returns the filename
  90781. */
  90782. static GetFilename(path: string): string;
  90783. /**
  90784. * Extracts the "folder" part of a path (everything before the filename).
  90785. * @param uri The URI to extract the info from
  90786. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90787. * @returns The "folder" part of the path
  90788. */
  90789. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90790. /**
  90791. * Extracts text content from a DOM element hierarchy
  90792. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90793. */
  90794. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90795. /**
  90796. * Convert an angle in radians to degrees
  90797. * @param angle defines the angle to convert
  90798. * @returns the angle in degrees
  90799. */
  90800. static ToDegrees(angle: number): number;
  90801. /**
  90802. * Convert an angle in degrees to radians
  90803. * @param angle defines the angle to convert
  90804. * @returns the angle in radians
  90805. */
  90806. static ToRadians(angle: number): number;
  90807. /**
  90808. * Encode a buffer to a base64 string
  90809. * @param buffer defines the buffer to encode
  90810. * @returns the encoded string
  90811. */
  90812. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90813. /**
  90814. * Extracts minimum and maximum values from a list of indexed positions
  90815. * @param positions defines the positions to use
  90816. * @param indices defines the indices to the positions
  90817. * @param indexStart defines the start index
  90818. * @param indexCount defines the end index
  90819. * @param bias defines bias value to add to the result
  90820. * @return minimum and maximum values
  90821. */
  90822. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90823. minimum: Vector3;
  90824. maximum: Vector3;
  90825. };
  90826. /**
  90827. * Extracts minimum and maximum values from a list of positions
  90828. * @param positions defines the positions to use
  90829. * @param start defines the start index in the positions array
  90830. * @param count defines the number of positions to handle
  90831. * @param bias defines bias value to add to the result
  90832. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90833. * @return minimum and maximum values
  90834. */
  90835. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90836. minimum: Vector3;
  90837. maximum: Vector3;
  90838. };
  90839. /**
  90840. * Returns an array if obj is not an array
  90841. * @param obj defines the object to evaluate as an array
  90842. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90843. * @returns either obj directly if obj is an array or a new array containing obj
  90844. */
  90845. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90846. /**
  90847. * Gets the pointer prefix to use
  90848. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90849. */
  90850. static GetPointerPrefix(): string;
  90851. /**
  90852. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90853. * @param func - the function to be called
  90854. * @param requester - the object that will request the next frame. Falls back to window.
  90855. * @returns frame number
  90856. */
  90857. static QueueNewFrame(func: () => void, requester?: any): number;
  90858. /**
  90859. * Ask the browser to promote the current element to fullscreen rendering mode
  90860. * @param element defines the DOM element to promote
  90861. */
  90862. static RequestFullscreen(element: HTMLElement): void;
  90863. /**
  90864. * Asks the browser to exit fullscreen mode
  90865. */
  90866. static ExitFullscreen(): void;
  90867. /**
  90868. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90869. * @param url define the url we are trying
  90870. * @param element define the dom element where to configure the cors policy
  90871. */
  90872. static SetCorsBehavior(url: string | string[], element: {
  90873. crossOrigin: string | null;
  90874. }): void;
  90875. /**
  90876. * Removes unwanted characters from an url
  90877. * @param url defines the url to clean
  90878. * @returns the cleaned url
  90879. */
  90880. static CleanUrl(url: string): string;
  90881. /**
  90882. * Gets or sets a function used to pre-process url before using them to load assets
  90883. */
  90884. static PreprocessUrl: (url: string) => string;
  90885. /**
  90886. * Loads an image as an HTMLImageElement.
  90887. * @param input url string, ArrayBuffer, or Blob to load
  90888. * @param onLoad callback called when the image successfully loads
  90889. * @param onError callback called when the image fails to load
  90890. * @param offlineProvider offline provider for caching
  90891. * @returns the HTMLImageElement of the loaded image
  90892. */
  90893. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90894. /**
  90895. * Loads a file
  90896. * @param url url string, ArrayBuffer, or Blob to load
  90897. * @param onSuccess callback called when the file successfully loads
  90898. * @param onProgress callback called while file is loading (if the server supports this mode)
  90899. * @param offlineProvider defines the offline provider for caching
  90900. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90901. * @param onError callback called when the file fails to load
  90902. * @returns a file request object
  90903. */
  90904. 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;
  90905. /**
  90906. * Load a script (identified by an url). When the url returns, the
  90907. * content of this file is added into a new script element, attached to the DOM (body element)
  90908. * @param scriptUrl defines the url of the script to laod
  90909. * @param onSuccess defines the callback called when the script is loaded
  90910. * @param onError defines the callback to call if an error occurs
  90911. * @param scriptId defines the id of the script element
  90912. */
  90913. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90914. /**
  90915. * Load an asynchronous script (identified by an url). When the url returns, the
  90916. * content of this file is added into a new script element, attached to the DOM (body element)
  90917. * @param scriptUrl defines the url of the script to laod
  90918. * @param scriptId defines the id of the script element
  90919. * @returns a promise request object
  90920. */
  90921. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90922. /**
  90923. * Loads a file from a blob
  90924. * @param fileToLoad defines the blob to use
  90925. * @param callback defines the callback to call when data is loaded
  90926. * @param progressCallback defines the callback to call during loading process
  90927. * @returns a file request object
  90928. */
  90929. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90930. /**
  90931. * Loads a file
  90932. * @param fileToLoad defines the file to load
  90933. * @param callback defines the callback to call when data is loaded
  90934. * @param progressCallBack defines the callback to call during loading process
  90935. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90936. * @returns a file request object
  90937. */
  90938. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90939. /**
  90940. * Creates a data url from a given string content
  90941. * @param content defines the content to convert
  90942. * @returns the new data url link
  90943. */
  90944. static FileAsURL(content: string): string;
  90945. /**
  90946. * Format the given number to a specific decimal format
  90947. * @param value defines the number to format
  90948. * @param decimals defines the number of decimals to use
  90949. * @returns the formatted string
  90950. */
  90951. static Format(value: number, decimals?: number): string;
  90952. /**
  90953. * Checks if a given vector is inside a specific range
  90954. * @param v defines the vector to test
  90955. * @param min defines the minimum range
  90956. * @param max defines the maximum range
  90957. */
  90958. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90959. /**
  90960. * Tries to copy an object by duplicating every property
  90961. * @param source defines the source object
  90962. * @param destination defines the target object
  90963. * @param doNotCopyList defines a list of properties to avoid
  90964. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90965. */
  90966. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90967. /**
  90968. * Gets a boolean indicating if the given object has no own property
  90969. * @param obj defines the object to test
  90970. * @returns true if object has no own property
  90971. */
  90972. static IsEmpty(obj: any): boolean;
  90973. /**
  90974. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90975. * @param str Source string
  90976. * @param suffix Suffix to search for in the source string
  90977. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90978. */
  90979. static EndsWith(str: string, suffix: string): boolean;
  90980. /**
  90981. * Function used to register events at window level
  90982. * @param events defines the events to register
  90983. */
  90984. static RegisterTopRootEvents(events: {
  90985. name: string;
  90986. handler: Nullable<(e: FocusEvent) => any>;
  90987. }[]): void;
  90988. /**
  90989. * Function used to unregister events from window level
  90990. * @param events defines the events to unregister
  90991. */
  90992. static UnregisterTopRootEvents(events: {
  90993. name: string;
  90994. handler: Nullable<(e: FocusEvent) => any>;
  90995. }[]): void;
  90996. /**
  90997. * @ignore
  90998. */
  90999. static _ScreenshotCanvas: HTMLCanvasElement;
  91000. /**
  91001. * Dumps the current bound framebuffer
  91002. * @param width defines the rendering width
  91003. * @param height defines the rendering height
  91004. * @param engine defines the hosting engine
  91005. * @param successCallback defines the callback triggered once the data are available
  91006. * @param mimeType defines the mime type of the result
  91007. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91008. */
  91009. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91010. /**
  91011. * Converts the canvas data to blob.
  91012. * This acts as a polyfill for browsers not supporting the to blob function.
  91013. * @param canvas Defines the canvas to extract the data from
  91014. * @param successCallback Defines the callback triggered once the data are available
  91015. * @param mimeType Defines the mime type of the result
  91016. */
  91017. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91018. /**
  91019. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91020. * @param successCallback defines the callback triggered once the data are available
  91021. * @param mimeType defines the mime type of the result
  91022. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91023. */
  91024. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91025. /**
  91026. * Downloads a blob in the browser
  91027. * @param blob defines the blob to download
  91028. * @param fileName defines the name of the downloaded file
  91029. */
  91030. static Download(blob: Blob, fileName: string): void;
  91031. /**
  91032. * Captures a screenshot of the current rendering
  91033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91034. * @param engine defines the rendering engine
  91035. * @param camera defines the source camera
  91036. * @param size This parameter can be set to a single number or to an object with the
  91037. * following (optional) properties: precision, width, height. If a single number is passed,
  91038. * it will be used for both width and height. If an object is passed, the screenshot size
  91039. * will be derived from the parameters. The precision property is a multiplier allowing
  91040. * rendering at a higher or lower resolution
  91041. * @param successCallback defines the callback receives a single parameter which contains the
  91042. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91043. * src parameter of an <img> to display it
  91044. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91045. * Check your browser for supported MIME types
  91046. */
  91047. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91048. /**
  91049. * Generates an image screenshot from the specified camera.
  91050. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91051. * @param engine The engine to use for rendering
  91052. * @param camera The camera to use for rendering
  91053. * @param size This parameter can be set to a single number or to an object with the
  91054. * following (optional) properties: precision, width, height. If a single number is passed,
  91055. * it will be used for both width and height. If an object is passed, the screenshot size
  91056. * will be derived from the parameters. The precision property is a multiplier allowing
  91057. * rendering at a higher or lower resolution
  91058. * @param successCallback The callback receives a single parameter which contains the
  91059. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91060. * src parameter of an <img> to display it
  91061. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91062. * Check your browser for supported MIME types
  91063. * @param samples Texture samples (default: 1)
  91064. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91065. * @param fileName A name for for the downloaded file.
  91066. */
  91067. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91068. /**
  91069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91070. * Be aware Math.random() could cause collisions, but:
  91071. * "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"
  91072. * @returns a pseudo random id
  91073. */
  91074. static RandomId(): string;
  91075. /**
  91076. * Test if the given uri is a base64 string
  91077. * @param uri The uri to test
  91078. * @return True if the uri is a base64 string or false otherwise
  91079. */
  91080. static IsBase64(uri: string): boolean;
  91081. /**
  91082. * Decode the given base64 uri.
  91083. * @param uri The uri to decode
  91084. * @return The decoded base64 data.
  91085. */
  91086. static DecodeBase64(uri: string): ArrayBuffer;
  91087. /**
  91088. * Gets the absolute url.
  91089. * @param url the input url
  91090. * @return the absolute url
  91091. */
  91092. static GetAbsoluteUrl(url: string): string;
  91093. /**
  91094. * No log
  91095. */
  91096. static readonly NoneLogLevel: number;
  91097. /**
  91098. * Only message logs
  91099. */
  91100. static readonly MessageLogLevel: number;
  91101. /**
  91102. * Only warning logs
  91103. */
  91104. static readonly WarningLogLevel: number;
  91105. /**
  91106. * Only error logs
  91107. */
  91108. static readonly ErrorLogLevel: number;
  91109. /**
  91110. * All logs
  91111. */
  91112. static readonly AllLogLevel: number;
  91113. /**
  91114. * Gets a value indicating the number of loading errors
  91115. * @ignorenaming
  91116. */
  91117. static readonly errorsCount: number;
  91118. /**
  91119. * Callback called when a new log is added
  91120. */
  91121. static OnNewCacheEntry: (entry: string) => void;
  91122. /**
  91123. * Log a message to the console
  91124. * @param message defines the message to log
  91125. */
  91126. static Log(message: string): void;
  91127. /**
  91128. * Write a warning message to the console
  91129. * @param message defines the message to log
  91130. */
  91131. static Warn(message: string): void;
  91132. /**
  91133. * Write an error message to the console
  91134. * @param message defines the message to log
  91135. */
  91136. static Error(message: string): void;
  91137. /**
  91138. * Gets current log cache (list of logs)
  91139. */
  91140. static readonly LogCache: string;
  91141. /**
  91142. * Clears the log cache
  91143. */
  91144. static ClearLogCache(): void;
  91145. /**
  91146. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91147. */
  91148. static LogLevels: number;
  91149. /**
  91150. * Checks if the loaded document was accessed via `file:`-Protocol.
  91151. * @returns boolean
  91152. */
  91153. static IsFileURL(): boolean;
  91154. /**
  91155. * Checks if the window object exists
  91156. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91157. */
  91158. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91159. /**
  91160. * No performance log
  91161. */
  91162. static readonly PerformanceNoneLogLevel: number;
  91163. /**
  91164. * Use user marks to log performance
  91165. */
  91166. static readonly PerformanceUserMarkLogLevel: number;
  91167. /**
  91168. * Log performance to the console
  91169. */
  91170. static readonly PerformanceConsoleLogLevel: number;
  91171. private static _performance;
  91172. /**
  91173. * Sets the current performance log level
  91174. */
  91175. static PerformanceLogLevel: number;
  91176. private static _StartPerformanceCounterDisabled;
  91177. private static _EndPerformanceCounterDisabled;
  91178. private static _StartUserMark;
  91179. private static _EndUserMark;
  91180. private static _StartPerformanceConsole;
  91181. private static _EndPerformanceConsole;
  91182. /**
  91183. * Starts a performance counter
  91184. */
  91185. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91186. /**
  91187. * Ends a specific performance coutner
  91188. */
  91189. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91190. /**
  91191. * Gets either window.performance.now() if supported or Date.now() else
  91192. */
  91193. static readonly Now: number;
  91194. /**
  91195. * This method will return the name of the class used to create the instance of the given object.
  91196. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91197. * @param object the object to get the class name from
  91198. * @param isType defines if the object is actually a type
  91199. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91200. */
  91201. static GetClassName(object: any, isType?: boolean): string;
  91202. /**
  91203. * Gets the first element of an array satisfying a given predicate
  91204. * @param array defines the array to browse
  91205. * @param predicate defines the predicate to use
  91206. * @returns null if not found or the element
  91207. */
  91208. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91209. /**
  91210. * This method will return the name of the full name of the class, including its owning module (if any).
  91211. * 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).
  91212. * @param object the object to get the class name from
  91213. * @param isType defines if the object is actually a type
  91214. * @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.
  91215. * @ignorenaming
  91216. */
  91217. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91218. /**
  91219. * Returns a promise that resolves after the given amount of time.
  91220. * @param delay Number of milliseconds to delay
  91221. * @returns Promise that resolves after the given amount of time
  91222. */
  91223. static DelayAsync(delay: number): Promise<void>;
  91224. /**
  91225. * Gets the current gradient from an array of IValueGradient
  91226. * @param ratio defines the current ratio to get
  91227. * @param gradients defines the array of IValueGradient
  91228. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91229. */
  91230. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91231. }
  91232. /**
  91233. * This class is used to track a performance counter which is number based.
  91234. * The user has access to many properties which give statistics of different nature.
  91235. *
  91236. * The implementer can track two kinds of Performance Counter: time and count.
  91237. * 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.
  91238. * 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.
  91239. */
  91240. export class PerfCounter {
  91241. /**
  91242. * Gets or sets a global boolean to turn on and off all the counters
  91243. */
  91244. static Enabled: boolean;
  91245. /**
  91246. * Returns the smallest value ever
  91247. */
  91248. readonly min: number;
  91249. /**
  91250. * Returns the biggest value ever
  91251. */
  91252. readonly max: number;
  91253. /**
  91254. * Returns the average value since the performance counter is running
  91255. */
  91256. readonly average: number;
  91257. /**
  91258. * Returns the average value of the last second the counter was monitored
  91259. */
  91260. readonly lastSecAverage: number;
  91261. /**
  91262. * Returns the current value
  91263. */
  91264. readonly current: number;
  91265. /**
  91266. * Gets the accumulated total
  91267. */
  91268. readonly total: number;
  91269. /**
  91270. * Gets the total value count
  91271. */
  91272. readonly count: number;
  91273. /**
  91274. * Creates a new counter
  91275. */
  91276. constructor();
  91277. /**
  91278. * Call this method to start monitoring a new frame.
  91279. * 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.
  91280. */
  91281. fetchNewFrame(): void;
  91282. /**
  91283. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91284. * @param newCount the count value to add to the monitored count
  91285. * @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.
  91286. */
  91287. addCount(newCount: number, fetchResult: boolean): void;
  91288. /**
  91289. * Start monitoring this performance counter
  91290. */
  91291. beginMonitoring(): void;
  91292. /**
  91293. * Compute the time lapsed since the previous beginMonitoring() call.
  91294. * @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
  91295. */
  91296. endMonitoring(newFrame?: boolean): void;
  91297. private _fetchResult;
  91298. private _startMonitoringTime;
  91299. private _min;
  91300. private _max;
  91301. private _average;
  91302. private _current;
  91303. private _totalValueCount;
  91304. private _totalAccumulated;
  91305. private _lastSecAverage;
  91306. private _lastSecAccumulated;
  91307. private _lastSecTime;
  91308. private _lastSecValueCount;
  91309. }
  91310. /**
  91311. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91312. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91313. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91314. * @param name The name of the class, case should be preserved
  91315. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91316. */
  91317. export function className(name: string, module?: string): (target: Object) => void;
  91318. /**
  91319. * An implementation of a loop for asynchronous functions.
  91320. */
  91321. export class AsyncLoop {
  91322. /**
  91323. * Defines the number of iterations for the loop
  91324. */
  91325. iterations: number;
  91326. /**
  91327. * Defines the current index of the loop.
  91328. */
  91329. index: number;
  91330. private _done;
  91331. private _fn;
  91332. private _successCallback;
  91333. /**
  91334. * Constructor.
  91335. * @param iterations the number of iterations.
  91336. * @param func the function to run each iteration
  91337. * @param successCallback the callback that will be called upon succesful execution
  91338. * @param offset starting offset.
  91339. */
  91340. constructor(
  91341. /**
  91342. * Defines the number of iterations for the loop
  91343. */
  91344. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91345. /**
  91346. * Execute the next iteration. Must be called after the last iteration was finished.
  91347. */
  91348. executeNext(): void;
  91349. /**
  91350. * Break the loop and run the success callback.
  91351. */
  91352. breakLoop(): void;
  91353. /**
  91354. * Create and run an async loop.
  91355. * @param iterations the number of iterations.
  91356. * @param fn the function to run each iteration
  91357. * @param successCallback the callback that will be called upon succesful execution
  91358. * @param offset starting offset.
  91359. * @returns the created async loop object
  91360. */
  91361. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91362. /**
  91363. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91364. * @param iterations total number of iterations
  91365. * @param syncedIterations number of synchronous iterations in each async iteration.
  91366. * @param fn the function to call each iteration.
  91367. * @param callback a success call back that will be called when iterating stops.
  91368. * @param breakFunction a break condition (optional)
  91369. * @param timeout timeout settings for the setTimeout function. default - 0.
  91370. * @returns the created async loop object
  91371. */
  91372. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91373. }
  91374. }
  91375. declare module BABYLON {
  91376. /** @hidden */
  91377. export interface ICollisionCoordinator {
  91378. createCollider(): Collider;
  91379. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91380. init(scene: Scene): void;
  91381. }
  91382. /** @hidden */
  91383. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91384. private _scene;
  91385. private _scaledPosition;
  91386. private _scaledVelocity;
  91387. private _finalPosition;
  91388. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91389. createCollider(): Collider;
  91390. init(scene: Scene): void;
  91391. private _collideWithWorld;
  91392. }
  91393. }
  91394. declare module BABYLON {
  91395. /**
  91396. * Class used to manage all inputs for the scene.
  91397. */
  91398. export class InputManager {
  91399. /** The distance in pixel that you have to move to prevent some events */
  91400. static DragMovementThreshold: number;
  91401. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91402. static LongPressDelay: number;
  91403. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91404. static DoubleClickDelay: number;
  91405. /** If you need to check double click without raising a single click at first click, enable this flag */
  91406. static ExclusiveDoubleClickMode: boolean;
  91407. private _wheelEventName;
  91408. private _onPointerMove;
  91409. private _onPointerDown;
  91410. private _onPointerUp;
  91411. private _initClickEvent;
  91412. private _initActionManager;
  91413. private _delayedSimpleClick;
  91414. private _delayedSimpleClickTimeout;
  91415. private _previousDelayedSimpleClickTimeout;
  91416. private _meshPickProceed;
  91417. private _previousButtonPressed;
  91418. private _currentPickResult;
  91419. private _previousPickResult;
  91420. private _totalPointersPressed;
  91421. private _doubleClickOccured;
  91422. private _pointerOverMesh;
  91423. private _pickedDownMesh;
  91424. private _pickedUpMesh;
  91425. private _pointerX;
  91426. private _pointerY;
  91427. private _unTranslatedPointerX;
  91428. private _unTranslatedPointerY;
  91429. private _startingPointerPosition;
  91430. private _previousStartingPointerPosition;
  91431. private _startingPointerTime;
  91432. private _previousStartingPointerTime;
  91433. private _pointerCaptures;
  91434. private _onKeyDown;
  91435. private _onKeyUp;
  91436. private _onCanvasFocusObserver;
  91437. private _onCanvasBlurObserver;
  91438. private _scene;
  91439. /**
  91440. * Creates a new InputManager
  91441. * @param scene defines the hosting scene
  91442. */
  91443. constructor(scene: Scene);
  91444. /**
  91445. * Gets the mesh that is currently under the pointer
  91446. */
  91447. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91448. /**
  91449. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91450. */
  91451. readonly unTranslatedPointer: Vector2;
  91452. /**
  91453. * Gets or sets the current on-screen X position of the pointer
  91454. */
  91455. pointerX: number;
  91456. /**
  91457. * Gets or sets the current on-screen Y position of the pointer
  91458. */
  91459. pointerY: number;
  91460. private _updatePointerPosition;
  91461. private _processPointerMove;
  91462. private _setRayOnPointerInfo;
  91463. private _checkPrePointerObservable;
  91464. /**
  91465. * Use this method to simulate a pointer move on a mesh
  91466. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91467. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91468. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91469. */
  91470. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91471. /**
  91472. * Use this method to simulate a pointer down on a mesh
  91473. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91474. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91475. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91476. */
  91477. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91478. private _processPointerDown;
  91479. /** @hidden */
  91480. _isPointerSwiping(): boolean;
  91481. /**
  91482. * Use this method to simulate a pointer up on a mesh
  91483. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91484. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91485. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91486. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91487. */
  91488. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91489. private _processPointerUp;
  91490. /**
  91491. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91492. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91493. * @returns true if the pointer was captured
  91494. */
  91495. isPointerCaptured(pointerId?: number): boolean;
  91496. /**
  91497. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91498. * @param attachUp defines if you want to attach events to pointerup
  91499. * @param attachDown defines if you want to attach events to pointerdown
  91500. * @param attachMove defines if you want to attach events to pointermove
  91501. */
  91502. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91503. /**
  91504. * Detaches all event handlers
  91505. */
  91506. detachControl(): void;
  91507. /**
  91508. * Force the value of meshUnderPointer
  91509. * @param mesh defines the mesh to use
  91510. */
  91511. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91512. /**
  91513. * Gets the mesh under the pointer
  91514. * @returns a Mesh or null if no mesh is under the pointer
  91515. */
  91516. getPointerOverMesh(): Nullable<AbstractMesh>;
  91517. }
  91518. }
  91519. declare module BABYLON {
  91520. /**
  91521. * This class defines the direct association between an animation and a target
  91522. */
  91523. export class TargetedAnimation {
  91524. /**
  91525. * Animation to perform
  91526. */
  91527. animation: Animation;
  91528. /**
  91529. * Target to animate
  91530. */
  91531. target: any;
  91532. }
  91533. /**
  91534. * Use this class to create coordinated animations on multiple targets
  91535. */
  91536. export class AnimationGroup implements IDisposable {
  91537. /** The name of the animation group */
  91538. name: string;
  91539. private _scene;
  91540. private _targetedAnimations;
  91541. private _animatables;
  91542. private _from;
  91543. private _to;
  91544. private _isStarted;
  91545. private _isPaused;
  91546. private _speedRatio;
  91547. /**
  91548. * Gets or sets the unique id of the node
  91549. */
  91550. uniqueId: number;
  91551. /**
  91552. * This observable will notify when one animation have ended
  91553. */
  91554. onAnimationEndObservable: Observable<TargetedAnimation>;
  91555. /**
  91556. * Observer raised when one animation loops
  91557. */
  91558. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91559. /**
  91560. * This observable will notify when all animations have ended.
  91561. */
  91562. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91563. /**
  91564. * This observable will notify when all animations have paused.
  91565. */
  91566. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91567. /**
  91568. * This observable will notify when all animations are playing.
  91569. */
  91570. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91571. /**
  91572. * Gets the first frame
  91573. */
  91574. readonly from: number;
  91575. /**
  91576. * Gets the last frame
  91577. */
  91578. readonly to: number;
  91579. /**
  91580. * Define if the animations are started
  91581. */
  91582. readonly isStarted: boolean;
  91583. /**
  91584. * Gets a value indicating that the current group is playing
  91585. */
  91586. readonly isPlaying: boolean;
  91587. /**
  91588. * Gets or sets the speed ratio to use for all animations
  91589. */
  91590. /**
  91591. * Gets or sets the speed ratio to use for all animations
  91592. */
  91593. speedRatio: number;
  91594. /**
  91595. * Gets the targeted animations for this animation group
  91596. */
  91597. readonly targetedAnimations: Array<TargetedAnimation>;
  91598. /**
  91599. * returning the list of animatables controlled by this animation group.
  91600. */
  91601. readonly animatables: Array<Animatable>;
  91602. /**
  91603. * Instantiates a new Animation Group.
  91604. * This helps managing several animations at once.
  91605. * @see http://doc.babylonjs.com/how_to/group
  91606. * @param name Defines the name of the group
  91607. * @param scene Defines the scene the group belongs to
  91608. */
  91609. constructor(
  91610. /** The name of the animation group */
  91611. name: string, scene?: Nullable<Scene>);
  91612. /**
  91613. * Add an animation (with its target) in the group
  91614. * @param animation defines the animation we want to add
  91615. * @param target defines the target of the animation
  91616. * @returns the TargetedAnimation object
  91617. */
  91618. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91619. /**
  91620. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91621. * It can add constant keys at begin or end
  91622. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91623. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91624. * @returns the animation group
  91625. */
  91626. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91627. /**
  91628. * Start all animations on given targets
  91629. * @param loop defines if animations must loop
  91630. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91631. * @param from defines the from key (optional)
  91632. * @param to defines the to key (optional)
  91633. * @returns the current animation group
  91634. */
  91635. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91636. /**
  91637. * Pause all animations
  91638. * @returns the animation group
  91639. */
  91640. pause(): AnimationGroup;
  91641. /**
  91642. * Play all animations to initial state
  91643. * This function will start() the animations if they were not started or will restart() them if they were paused
  91644. * @param loop defines if animations must loop
  91645. * @returns the animation group
  91646. */
  91647. play(loop?: boolean): AnimationGroup;
  91648. /**
  91649. * Reset all animations to initial state
  91650. * @returns the animation group
  91651. */
  91652. reset(): AnimationGroup;
  91653. /**
  91654. * Restart animations from key 0
  91655. * @returns the animation group
  91656. */
  91657. restart(): AnimationGroup;
  91658. /**
  91659. * Stop all animations
  91660. * @returns the animation group
  91661. */
  91662. stop(): AnimationGroup;
  91663. /**
  91664. * Set animation weight for all animatables
  91665. * @param weight defines the weight to use
  91666. * @return the animationGroup
  91667. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91668. */
  91669. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91670. /**
  91671. * Synchronize and normalize all animatables with a source animatable
  91672. * @param root defines the root animatable to synchronize with
  91673. * @return the animationGroup
  91674. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91675. */
  91676. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91677. /**
  91678. * Goes to a specific frame in this animation group
  91679. * @param frame the frame number to go to
  91680. * @return the animationGroup
  91681. */
  91682. goToFrame(frame: number): AnimationGroup;
  91683. /**
  91684. * Dispose all associated resources
  91685. */
  91686. dispose(): void;
  91687. private _checkAnimationGroupEnded;
  91688. /**
  91689. * Clone the current animation group and returns a copy
  91690. * @param newName defines the name of the new group
  91691. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91692. * @returns the new aniamtion group
  91693. */
  91694. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91695. /**
  91696. * Returns a new AnimationGroup object parsed from the source provided.
  91697. * @param parsedAnimationGroup defines the source
  91698. * @param scene defines the scene that will receive the animationGroup
  91699. * @returns a new AnimationGroup
  91700. */
  91701. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91702. /**
  91703. * Returns the string "AnimationGroup"
  91704. * @returns "AnimationGroup"
  91705. */
  91706. getClassName(): string;
  91707. /**
  91708. * Creates a detailled string about the object
  91709. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91710. * @returns a string representing the object
  91711. */
  91712. toString(fullDetails?: boolean): string;
  91713. }
  91714. }
  91715. declare module BABYLON {
  91716. /**
  91717. * Define an interface for all classes that will hold resources
  91718. */
  91719. export interface IDisposable {
  91720. /**
  91721. * Releases all held resources
  91722. */
  91723. dispose(): void;
  91724. }
  91725. /** Interface defining initialization parameters for Scene class */
  91726. export interface SceneOptions {
  91727. /**
  91728. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91729. * It will improve performance when the number of geometries becomes important.
  91730. */
  91731. useGeometryUniqueIdsMap?: boolean;
  91732. /**
  91733. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91734. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91735. */
  91736. useMaterialMeshMap?: boolean;
  91737. /**
  91738. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91739. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91740. */
  91741. useClonedMeshhMap?: boolean;
  91742. }
  91743. /**
  91744. * Represents a scene to be rendered by the engine.
  91745. * @see http://doc.babylonjs.com/features/scene
  91746. */
  91747. export class Scene extends AbstractScene implements IAnimatable {
  91748. private static _uniqueIdCounter;
  91749. /** The fog is deactivated */
  91750. static readonly FOGMODE_NONE: number;
  91751. /** The fog density is following an exponential function */
  91752. static readonly FOGMODE_EXP: number;
  91753. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91754. static readonly FOGMODE_EXP2: number;
  91755. /** The fog density is following a linear function. */
  91756. static readonly FOGMODE_LINEAR: number;
  91757. /**
  91758. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91759. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91760. */
  91761. static MinDeltaTime: number;
  91762. /**
  91763. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91765. */
  91766. static MaxDeltaTime: number;
  91767. /**
  91768. * Factory used to create the default material.
  91769. * @param name The name of the material to create
  91770. * @param scene The scene to create the material for
  91771. * @returns The default material
  91772. */
  91773. static DefaultMaterialFactory(scene: Scene): Material;
  91774. /**
  91775. * Factory used to create the a collision coordinator.
  91776. * @returns The collision coordinator
  91777. */
  91778. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91779. /** @hidden */
  91780. _inputManager: InputManager;
  91781. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91782. cameraToUseForPointers: Nullable<Camera>;
  91783. /** @hidden */
  91784. readonly _isScene: boolean;
  91785. /**
  91786. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91787. */
  91788. autoClear: boolean;
  91789. /**
  91790. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91791. */
  91792. autoClearDepthAndStencil: boolean;
  91793. /**
  91794. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91795. */
  91796. clearColor: Color4;
  91797. /**
  91798. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91799. */
  91800. ambientColor: Color3;
  91801. /**
  91802. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91803. * It should only be one of the following (if not the default embedded one):
  91804. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91805. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91806. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91807. * The material properties need to be setup according to the type of texture in use.
  91808. */
  91809. environmentBRDFTexture: BaseTexture;
  91810. /** @hidden */
  91811. protected _environmentTexture: Nullable<BaseTexture>;
  91812. /**
  91813. * Texture used in all pbr material as the reflection texture.
  91814. * As in the majority of the scene they are the same (exception for multi room and so on),
  91815. * this is easier to reference from here than from all the materials.
  91816. */
  91817. /**
  91818. * Texture used in all pbr material as the reflection texture.
  91819. * As in the majority of the scene they are the same (exception for multi room and so on),
  91820. * this is easier to set here than in all the materials.
  91821. */
  91822. environmentTexture: Nullable<BaseTexture>;
  91823. /** @hidden */
  91824. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91825. /**
  91826. * Default image processing configuration used either in the rendering
  91827. * Forward main pass or through the imageProcessingPostProcess if present.
  91828. * As in the majority of the scene they are the same (exception for multi camera),
  91829. * this is easier to reference from here than from all the materials and post process.
  91830. *
  91831. * No setter as we it is a shared configuration, you can set the values instead.
  91832. */
  91833. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91834. private _forceWireframe;
  91835. /**
  91836. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91837. */
  91838. forceWireframe: boolean;
  91839. private _forcePointsCloud;
  91840. /**
  91841. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91842. */
  91843. forcePointsCloud: boolean;
  91844. /**
  91845. * Gets or sets the active clipplane 1
  91846. */
  91847. clipPlane: Nullable<Plane>;
  91848. /**
  91849. * Gets or sets the active clipplane 2
  91850. */
  91851. clipPlane2: Nullable<Plane>;
  91852. /**
  91853. * Gets or sets the active clipplane 3
  91854. */
  91855. clipPlane3: Nullable<Plane>;
  91856. /**
  91857. * Gets or sets the active clipplane 4
  91858. */
  91859. clipPlane4: Nullable<Plane>;
  91860. /**
  91861. * Gets or sets a boolean indicating if animations are enabled
  91862. */
  91863. animationsEnabled: boolean;
  91864. private _animationPropertiesOverride;
  91865. /**
  91866. * Gets or sets the animation properties override
  91867. */
  91868. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91869. /**
  91870. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91871. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91872. */
  91873. useConstantAnimationDeltaTime: boolean;
  91874. /**
  91875. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91876. * Please note that it requires to run a ray cast through the scene on every frame
  91877. */
  91878. constantlyUpdateMeshUnderPointer: boolean;
  91879. /**
  91880. * Defines the HTML cursor to use when hovering over interactive elements
  91881. */
  91882. hoverCursor: string;
  91883. /**
  91884. * Defines the HTML default cursor to use (empty by default)
  91885. */
  91886. defaultCursor: string;
  91887. /**
  91888. * This is used to call preventDefault() on pointer down
  91889. * in order to block unwanted artifacts like system double clicks
  91890. */
  91891. preventDefaultOnPointerDown: boolean;
  91892. /**
  91893. * This is used to call preventDefault() on pointer up
  91894. * in order to block unwanted artifacts like system double clicks
  91895. */
  91896. preventDefaultOnPointerUp: boolean;
  91897. /**
  91898. * Gets or sets user defined metadata
  91899. */
  91900. metadata: any;
  91901. /**
  91902. * For internal use only. Please do not use.
  91903. */
  91904. reservedDataStore: any;
  91905. /**
  91906. * Gets the name of the plugin used to load this scene (null by default)
  91907. */
  91908. loadingPluginName: string;
  91909. /**
  91910. * Use this array to add regular expressions used to disable offline support for specific urls
  91911. */
  91912. disableOfflineSupportExceptionRules: RegExp[];
  91913. /**
  91914. * An event triggered when the scene is disposed.
  91915. */
  91916. onDisposeObservable: Observable<Scene>;
  91917. private _onDisposeObserver;
  91918. /** Sets a function to be executed when this scene is disposed. */
  91919. onDispose: () => void;
  91920. /**
  91921. * An event triggered before rendering the scene (right after animations and physics)
  91922. */
  91923. onBeforeRenderObservable: Observable<Scene>;
  91924. private _onBeforeRenderObserver;
  91925. /** Sets a function to be executed before rendering this scene */
  91926. beforeRender: Nullable<() => void>;
  91927. /**
  91928. * An event triggered after rendering the scene
  91929. */
  91930. onAfterRenderObservable: Observable<Scene>;
  91931. private _onAfterRenderObserver;
  91932. /** Sets a function to be executed after rendering this scene */
  91933. afterRender: Nullable<() => void>;
  91934. /**
  91935. * An event triggered before animating the scene
  91936. */
  91937. onBeforeAnimationsObservable: Observable<Scene>;
  91938. /**
  91939. * An event triggered after animations processing
  91940. */
  91941. onAfterAnimationsObservable: Observable<Scene>;
  91942. /**
  91943. * An event triggered before draw calls are ready to be sent
  91944. */
  91945. onBeforeDrawPhaseObservable: Observable<Scene>;
  91946. /**
  91947. * An event triggered after draw calls have been sent
  91948. */
  91949. onAfterDrawPhaseObservable: Observable<Scene>;
  91950. /**
  91951. * An event triggered when the scene is ready
  91952. */
  91953. onReadyObservable: Observable<Scene>;
  91954. /**
  91955. * An event triggered before rendering a camera
  91956. */
  91957. onBeforeCameraRenderObservable: Observable<Camera>;
  91958. private _onBeforeCameraRenderObserver;
  91959. /** Sets a function to be executed before rendering a camera*/
  91960. beforeCameraRender: () => void;
  91961. /**
  91962. * An event triggered after rendering a camera
  91963. */
  91964. onAfterCameraRenderObservable: Observable<Camera>;
  91965. private _onAfterCameraRenderObserver;
  91966. /** Sets a function to be executed after rendering a camera*/
  91967. afterCameraRender: () => void;
  91968. /**
  91969. * An event triggered when active meshes evaluation is about to start
  91970. */
  91971. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91972. /**
  91973. * An event triggered when active meshes evaluation is done
  91974. */
  91975. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91976. /**
  91977. * An event triggered when particles rendering is about to start
  91978. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91979. */
  91980. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91981. /**
  91982. * An event triggered when particles rendering is done
  91983. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91984. */
  91985. onAfterParticlesRenderingObservable: Observable<Scene>;
  91986. /**
  91987. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91988. */
  91989. onDataLoadedObservable: Observable<Scene>;
  91990. /**
  91991. * An event triggered when a camera is created
  91992. */
  91993. onNewCameraAddedObservable: Observable<Camera>;
  91994. /**
  91995. * An event triggered when a camera is removed
  91996. */
  91997. onCameraRemovedObservable: Observable<Camera>;
  91998. /**
  91999. * An event triggered when a light is created
  92000. */
  92001. onNewLightAddedObservable: Observable<Light>;
  92002. /**
  92003. * An event triggered when a light is removed
  92004. */
  92005. onLightRemovedObservable: Observable<Light>;
  92006. /**
  92007. * An event triggered when a geometry is created
  92008. */
  92009. onNewGeometryAddedObservable: Observable<Geometry>;
  92010. /**
  92011. * An event triggered when a geometry is removed
  92012. */
  92013. onGeometryRemovedObservable: Observable<Geometry>;
  92014. /**
  92015. * An event triggered when a transform node is created
  92016. */
  92017. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92018. /**
  92019. * An event triggered when a transform node is removed
  92020. */
  92021. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92022. /**
  92023. * An event triggered when a mesh is created
  92024. */
  92025. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92026. /**
  92027. * An event triggered when a mesh is removed
  92028. */
  92029. onMeshRemovedObservable: Observable<AbstractMesh>;
  92030. /**
  92031. * An event triggered when a skeleton is created
  92032. */
  92033. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92034. /**
  92035. * An event triggered when a skeleton is removed
  92036. */
  92037. onSkeletonRemovedObservable: Observable<Skeleton>;
  92038. /**
  92039. * An event triggered when a material is created
  92040. */
  92041. onNewMaterialAddedObservable: Observable<Material>;
  92042. /**
  92043. * An event triggered when a material is removed
  92044. */
  92045. onMaterialRemovedObservable: Observable<Material>;
  92046. /**
  92047. * An event triggered when a texture is created
  92048. */
  92049. onNewTextureAddedObservable: Observable<BaseTexture>;
  92050. /**
  92051. * An event triggered when a texture is removed
  92052. */
  92053. onTextureRemovedObservable: Observable<BaseTexture>;
  92054. /**
  92055. * An event triggered when render targets are about to be rendered
  92056. * Can happen multiple times per frame.
  92057. */
  92058. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92059. /**
  92060. * An event triggered when render targets were rendered.
  92061. * Can happen multiple times per frame.
  92062. */
  92063. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92064. /**
  92065. * An event triggered before calculating deterministic simulation step
  92066. */
  92067. onBeforeStepObservable: Observable<Scene>;
  92068. /**
  92069. * An event triggered after calculating deterministic simulation step
  92070. */
  92071. onAfterStepObservable: Observable<Scene>;
  92072. /**
  92073. * An event triggered when the activeCamera property is updated
  92074. */
  92075. onActiveCameraChanged: Observable<Scene>;
  92076. /**
  92077. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92078. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92079. * 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)
  92080. */
  92081. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92082. /**
  92083. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92084. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92085. * 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)
  92086. */
  92087. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92088. /**
  92089. * This Observable will when a mesh has been imported into the scene.
  92090. */
  92091. onMeshImportedObservable: Observable<AbstractMesh>;
  92092. /**
  92093. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92094. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92095. */
  92096. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92097. /** @hidden */
  92098. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92099. /**
  92100. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92101. */
  92102. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92103. /**
  92104. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92105. */
  92106. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92107. /**
  92108. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92109. */
  92110. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92111. /** Callback called when a pointer move is detected */
  92112. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92113. /** Callback called when a pointer down is detected */
  92114. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92115. /** Callback called when a pointer up is detected */
  92116. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92117. /** Callback called when a pointer pick is detected */
  92118. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92119. /**
  92120. * 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).
  92121. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92122. */
  92123. onPrePointerObservable: Observable<PointerInfoPre>;
  92124. /**
  92125. * Observable event triggered each time an input event is received from the rendering canvas
  92126. */
  92127. onPointerObservable: Observable<PointerInfo>;
  92128. /**
  92129. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92130. */
  92131. readonly unTranslatedPointer: Vector2;
  92132. /**
  92133. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92134. */
  92135. static DragMovementThreshold: number;
  92136. /**
  92137. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92138. */
  92139. static LongPressDelay: number;
  92140. /**
  92141. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92142. */
  92143. static DoubleClickDelay: number;
  92144. /** If you need to check double click without raising a single click at first click, enable this flag */
  92145. static ExclusiveDoubleClickMode: boolean;
  92146. /** @hidden */
  92147. _mirroredCameraPosition: Nullable<Vector3>;
  92148. /**
  92149. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92150. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92151. */
  92152. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92153. /**
  92154. * Observable event triggered each time an keyboard event is received from the hosting window
  92155. */
  92156. onKeyboardObservable: Observable<KeyboardInfo>;
  92157. private _useRightHandedSystem;
  92158. /**
  92159. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92160. */
  92161. useRightHandedSystem: boolean;
  92162. private _timeAccumulator;
  92163. private _currentStepId;
  92164. private _currentInternalStep;
  92165. /**
  92166. * Sets the step Id used by deterministic lock step
  92167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92168. * @param newStepId defines the step Id
  92169. */
  92170. setStepId(newStepId: number): void;
  92171. /**
  92172. * Gets the step Id used by deterministic lock step
  92173. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92174. * @returns the step Id
  92175. */
  92176. getStepId(): number;
  92177. /**
  92178. * Gets the internal step used by deterministic lock step
  92179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92180. * @returns the internal step
  92181. */
  92182. getInternalStep(): number;
  92183. private _fogEnabled;
  92184. /**
  92185. * Gets or sets a boolean indicating if fog is enabled on this scene
  92186. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92187. * (Default is true)
  92188. */
  92189. fogEnabled: boolean;
  92190. private _fogMode;
  92191. /**
  92192. * Gets or sets the fog mode to use
  92193. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92194. * | mode | value |
  92195. * | --- | --- |
  92196. * | FOGMODE_NONE | 0 |
  92197. * | FOGMODE_EXP | 1 |
  92198. * | FOGMODE_EXP2 | 2 |
  92199. * | FOGMODE_LINEAR | 3 |
  92200. */
  92201. fogMode: number;
  92202. /**
  92203. * Gets or sets the fog color to use
  92204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92205. * (Default is Color3(0.2, 0.2, 0.3))
  92206. */
  92207. fogColor: Color3;
  92208. /**
  92209. * Gets or sets the fog density to use
  92210. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92211. * (Default is 0.1)
  92212. */
  92213. fogDensity: number;
  92214. /**
  92215. * Gets or sets the fog start distance to use
  92216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92217. * (Default is 0)
  92218. */
  92219. fogStart: number;
  92220. /**
  92221. * Gets or sets the fog end distance to use
  92222. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92223. * (Default is 1000)
  92224. */
  92225. fogEnd: number;
  92226. private _shadowsEnabled;
  92227. /**
  92228. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92229. */
  92230. shadowsEnabled: boolean;
  92231. private _lightsEnabled;
  92232. /**
  92233. * Gets or sets a boolean indicating if lights are enabled on this scene
  92234. */
  92235. lightsEnabled: boolean;
  92236. /** All of the active cameras added to this scene. */
  92237. activeCameras: Camera[];
  92238. /** @hidden */
  92239. _activeCamera: Nullable<Camera>;
  92240. /** Gets or sets the current active camera */
  92241. activeCamera: Nullable<Camera>;
  92242. private _defaultMaterial;
  92243. /** The default material used on meshes when no material is affected */
  92244. /** The default material used on meshes when no material is affected */
  92245. defaultMaterial: Material;
  92246. private _texturesEnabled;
  92247. /**
  92248. * Gets or sets a boolean indicating if textures are enabled on this scene
  92249. */
  92250. texturesEnabled: boolean;
  92251. /**
  92252. * Gets or sets a boolean indicating if particles are enabled on this scene
  92253. */
  92254. particlesEnabled: boolean;
  92255. /**
  92256. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92257. */
  92258. spritesEnabled: boolean;
  92259. private _skeletonsEnabled;
  92260. /**
  92261. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92262. */
  92263. skeletonsEnabled: boolean;
  92264. /**
  92265. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92266. */
  92267. lensFlaresEnabled: boolean;
  92268. /**
  92269. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92271. */
  92272. collisionsEnabled: boolean;
  92273. private _collisionCoordinator;
  92274. /** @hidden */
  92275. readonly collisionCoordinator: ICollisionCoordinator;
  92276. /**
  92277. * Defines the gravity applied to this scene (used only for collisions)
  92278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92279. */
  92280. gravity: Vector3;
  92281. /**
  92282. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92283. */
  92284. postProcessesEnabled: boolean;
  92285. /**
  92286. * The list of postprocesses added to the scene
  92287. */
  92288. postProcesses: PostProcess[];
  92289. /**
  92290. * Gets the current postprocess manager
  92291. */
  92292. postProcessManager: PostProcessManager;
  92293. /**
  92294. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92295. */
  92296. renderTargetsEnabled: boolean;
  92297. /**
  92298. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92299. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92300. */
  92301. dumpNextRenderTargets: boolean;
  92302. /**
  92303. * The list of user defined render targets added to the scene
  92304. */
  92305. customRenderTargets: RenderTargetTexture[];
  92306. /**
  92307. * Defines if texture loading must be delayed
  92308. * If true, textures will only be loaded when they need to be rendered
  92309. */
  92310. useDelayedTextureLoading: boolean;
  92311. /**
  92312. * Gets the list of meshes imported to the scene through SceneLoader
  92313. */
  92314. importedMeshesFiles: String[];
  92315. /**
  92316. * Gets or sets a boolean indicating if probes are enabled on this scene
  92317. */
  92318. probesEnabled: boolean;
  92319. /**
  92320. * Gets or sets the current offline provider to use to store scene data
  92321. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92322. */
  92323. offlineProvider: IOfflineProvider;
  92324. /**
  92325. * Gets or sets the action manager associated with the scene
  92326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92327. */
  92328. actionManager: AbstractActionManager;
  92329. private _meshesForIntersections;
  92330. /**
  92331. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92332. */
  92333. proceduralTexturesEnabled: boolean;
  92334. private _engine;
  92335. private _totalVertices;
  92336. /** @hidden */
  92337. _activeIndices: PerfCounter;
  92338. /** @hidden */
  92339. _activeParticles: PerfCounter;
  92340. /** @hidden */
  92341. _activeBones: PerfCounter;
  92342. private _animationRatio;
  92343. /** @hidden */
  92344. _animationTimeLast: number;
  92345. /** @hidden */
  92346. _animationTime: number;
  92347. /**
  92348. * Gets or sets a general scale for animation speed
  92349. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92350. */
  92351. animationTimeScale: number;
  92352. /** @hidden */
  92353. _cachedMaterial: Nullable<Material>;
  92354. /** @hidden */
  92355. _cachedEffect: Nullable<Effect>;
  92356. /** @hidden */
  92357. _cachedVisibility: Nullable<number>;
  92358. private _renderId;
  92359. private _frameId;
  92360. private _executeWhenReadyTimeoutId;
  92361. private _intermediateRendering;
  92362. private _viewUpdateFlag;
  92363. private _projectionUpdateFlag;
  92364. /** @hidden */
  92365. _toBeDisposed: Nullable<IDisposable>[];
  92366. private _activeRequests;
  92367. /** @hidden */
  92368. _pendingData: any[];
  92369. private _isDisposed;
  92370. /**
  92371. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92372. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92373. */
  92374. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92375. private _activeMeshes;
  92376. private _processedMaterials;
  92377. private _renderTargets;
  92378. /** @hidden */
  92379. _activeParticleSystems: SmartArray<IParticleSystem>;
  92380. private _activeSkeletons;
  92381. private _softwareSkinnedMeshes;
  92382. private _renderingManager;
  92383. /** @hidden */
  92384. _activeAnimatables: Animatable[];
  92385. private _transformMatrix;
  92386. private _sceneUbo;
  92387. /** @hidden */
  92388. _viewMatrix: Matrix;
  92389. private _projectionMatrix;
  92390. /** @hidden */
  92391. _forcedViewPosition: Nullable<Vector3>;
  92392. /** @hidden */
  92393. _frustumPlanes: Plane[];
  92394. /**
  92395. * Gets the list of frustum planes (built from the active camera)
  92396. */
  92397. readonly frustumPlanes: Plane[];
  92398. /**
  92399. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92400. * This is useful if there are more lights that the maximum simulteanous authorized
  92401. */
  92402. requireLightSorting: boolean;
  92403. /** @hidden */
  92404. readonly useMaterialMeshMap: boolean;
  92405. /** @hidden */
  92406. readonly useClonedMeshhMap: boolean;
  92407. private _externalData;
  92408. private _uid;
  92409. /**
  92410. * @hidden
  92411. * Backing store of defined scene components.
  92412. */
  92413. _components: ISceneComponent[];
  92414. /**
  92415. * @hidden
  92416. * Backing store of defined scene components.
  92417. */
  92418. _serializableComponents: ISceneSerializableComponent[];
  92419. /**
  92420. * List of components to register on the next registration step.
  92421. */
  92422. private _transientComponents;
  92423. /**
  92424. * Registers the transient components if needed.
  92425. */
  92426. private _registerTransientComponents;
  92427. /**
  92428. * @hidden
  92429. * Add a component to the scene.
  92430. * Note that the ccomponent could be registered on th next frame if this is called after
  92431. * the register component stage.
  92432. * @param component Defines the component to add to the scene
  92433. */
  92434. _addComponent(component: ISceneComponent): void;
  92435. /**
  92436. * @hidden
  92437. * Gets a component from the scene.
  92438. * @param name defines the name of the component to retrieve
  92439. * @returns the component or null if not present
  92440. */
  92441. _getComponent(name: string): Nullable<ISceneComponent>;
  92442. /**
  92443. * @hidden
  92444. * Defines the actions happening before camera updates.
  92445. */
  92446. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92447. /**
  92448. * @hidden
  92449. * Defines the actions happening before clear the canvas.
  92450. */
  92451. _beforeClearStage: Stage<SimpleStageAction>;
  92452. /**
  92453. * @hidden
  92454. * Defines the actions when collecting render targets for the frame.
  92455. */
  92456. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92457. /**
  92458. * @hidden
  92459. * Defines the actions happening for one camera in the frame.
  92460. */
  92461. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92462. /**
  92463. * @hidden
  92464. * Defines the actions happening during the per mesh ready checks.
  92465. */
  92466. _isReadyForMeshStage: Stage<MeshStageAction>;
  92467. /**
  92468. * @hidden
  92469. * Defines the actions happening before evaluate active mesh checks.
  92470. */
  92471. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92472. /**
  92473. * @hidden
  92474. * Defines the actions happening during the evaluate sub mesh checks.
  92475. */
  92476. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92477. /**
  92478. * @hidden
  92479. * Defines the actions happening during the active mesh stage.
  92480. */
  92481. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92482. /**
  92483. * @hidden
  92484. * Defines the actions happening during the per camera render target step.
  92485. */
  92486. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92487. /**
  92488. * @hidden
  92489. * Defines the actions happening just before the active camera is drawing.
  92490. */
  92491. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92492. /**
  92493. * @hidden
  92494. * Defines the actions happening just before a render target is drawing.
  92495. */
  92496. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92497. /**
  92498. * @hidden
  92499. * Defines the actions happening just before a rendering group is drawing.
  92500. */
  92501. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92502. /**
  92503. * @hidden
  92504. * Defines the actions happening just before a mesh is drawing.
  92505. */
  92506. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92507. /**
  92508. * @hidden
  92509. * Defines the actions happening just after a mesh has been drawn.
  92510. */
  92511. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92512. /**
  92513. * @hidden
  92514. * Defines the actions happening just after a rendering group has been drawn.
  92515. */
  92516. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92517. /**
  92518. * @hidden
  92519. * Defines the actions happening just after the active camera has been drawn.
  92520. */
  92521. _afterCameraDrawStage: Stage<CameraStageAction>;
  92522. /**
  92523. * @hidden
  92524. * Defines the actions happening just after a render target has been drawn.
  92525. */
  92526. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92527. /**
  92528. * @hidden
  92529. * Defines the actions happening just after rendering all cameras and computing intersections.
  92530. */
  92531. _afterRenderStage: Stage<SimpleStageAction>;
  92532. /**
  92533. * @hidden
  92534. * Defines the actions happening when a pointer move event happens.
  92535. */
  92536. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92537. /**
  92538. * @hidden
  92539. * Defines the actions happening when a pointer down event happens.
  92540. */
  92541. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92542. /**
  92543. * @hidden
  92544. * Defines the actions happening when a pointer up event happens.
  92545. */
  92546. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92547. /**
  92548. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92549. */
  92550. private geometriesByUniqueId;
  92551. /**
  92552. * Creates a new Scene
  92553. * @param engine defines the engine to use to render this scene
  92554. * @param options defines the scene options
  92555. */
  92556. constructor(engine: Engine, options?: SceneOptions);
  92557. /**
  92558. * Gets a string idenfifying the name of the class
  92559. * @returns "Scene" string
  92560. */
  92561. getClassName(): string;
  92562. private _defaultMeshCandidates;
  92563. /**
  92564. * @hidden
  92565. */
  92566. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92567. private _defaultSubMeshCandidates;
  92568. /**
  92569. * @hidden
  92570. */
  92571. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92572. /**
  92573. * Sets the default candidate providers for the scene.
  92574. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92575. * and getCollidingSubMeshCandidates to their default function
  92576. */
  92577. setDefaultCandidateProviders(): void;
  92578. /**
  92579. * Gets the mesh that is currently under the pointer
  92580. */
  92581. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92582. /**
  92583. * Gets or sets the current on-screen X position of the pointer
  92584. */
  92585. pointerX: number;
  92586. /**
  92587. * Gets or sets the current on-screen Y position of the pointer
  92588. */
  92589. pointerY: number;
  92590. /**
  92591. * Gets the cached material (ie. the latest rendered one)
  92592. * @returns the cached material
  92593. */
  92594. getCachedMaterial(): Nullable<Material>;
  92595. /**
  92596. * Gets the cached effect (ie. the latest rendered one)
  92597. * @returns the cached effect
  92598. */
  92599. getCachedEffect(): Nullable<Effect>;
  92600. /**
  92601. * Gets the cached visibility state (ie. the latest rendered one)
  92602. * @returns the cached visibility state
  92603. */
  92604. getCachedVisibility(): Nullable<number>;
  92605. /**
  92606. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92607. * @param material defines the current material
  92608. * @param effect defines the current effect
  92609. * @param visibility defines the current visibility state
  92610. * @returns true if one parameter is not cached
  92611. */
  92612. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92613. /**
  92614. * Gets the engine associated with the scene
  92615. * @returns an Engine
  92616. */
  92617. getEngine(): Engine;
  92618. /**
  92619. * Gets the total number of vertices rendered per frame
  92620. * @returns the total number of vertices rendered per frame
  92621. */
  92622. getTotalVertices(): number;
  92623. /**
  92624. * Gets the performance counter for total vertices
  92625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92626. */
  92627. readonly totalVerticesPerfCounter: PerfCounter;
  92628. /**
  92629. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92630. * @returns the total number of active indices rendered per frame
  92631. */
  92632. getActiveIndices(): number;
  92633. /**
  92634. * Gets the performance counter for active indices
  92635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92636. */
  92637. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92638. /**
  92639. * Gets the total number of active particles rendered per frame
  92640. * @returns the total number of active particles rendered per frame
  92641. */
  92642. getActiveParticles(): number;
  92643. /**
  92644. * Gets the performance counter for active particles
  92645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92646. */
  92647. readonly activeParticlesPerfCounter: PerfCounter;
  92648. /**
  92649. * Gets the total number of active bones rendered per frame
  92650. * @returns the total number of active bones rendered per frame
  92651. */
  92652. getActiveBones(): number;
  92653. /**
  92654. * Gets the performance counter for active bones
  92655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92656. */
  92657. readonly activeBonesPerfCounter: PerfCounter;
  92658. /**
  92659. * Gets the array of active meshes
  92660. * @returns an array of AbstractMesh
  92661. */
  92662. getActiveMeshes(): SmartArray<AbstractMesh>;
  92663. /**
  92664. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92665. * @returns a number
  92666. */
  92667. getAnimationRatio(): number;
  92668. /**
  92669. * Gets an unique Id for the current render phase
  92670. * @returns a number
  92671. */
  92672. getRenderId(): number;
  92673. /**
  92674. * Gets an unique Id for the current frame
  92675. * @returns a number
  92676. */
  92677. getFrameId(): number;
  92678. /** Call this function if you want to manually increment the render Id*/
  92679. incrementRenderId(): void;
  92680. private _createUbo;
  92681. /**
  92682. * Use this method to simulate a pointer move on a mesh
  92683. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92684. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92685. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92686. * @returns the current scene
  92687. */
  92688. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92689. /**
  92690. * Use this method to simulate a pointer down on a mesh
  92691. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92692. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92693. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92694. * @returns the current scene
  92695. */
  92696. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92697. /**
  92698. * Use this method to simulate a pointer up on a mesh
  92699. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92700. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92701. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92702. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92703. * @returns the current scene
  92704. */
  92705. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92706. /**
  92707. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92708. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92709. * @returns true if the pointer was captured
  92710. */
  92711. isPointerCaptured(pointerId?: number): boolean;
  92712. /**
  92713. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92714. * @param attachUp defines if you want to attach events to pointerup
  92715. * @param attachDown defines if you want to attach events to pointerdown
  92716. * @param attachMove defines if you want to attach events to pointermove
  92717. */
  92718. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92719. /** Detaches all event handlers*/
  92720. detachControl(): void;
  92721. /**
  92722. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92723. * Delay loaded resources are not taking in account
  92724. * @return true if all required resources are ready
  92725. */
  92726. isReady(): boolean;
  92727. /** Resets all cached information relative to material (including effect and visibility) */
  92728. resetCachedMaterial(): void;
  92729. /**
  92730. * Registers a function to be called before every frame render
  92731. * @param func defines the function to register
  92732. */
  92733. registerBeforeRender(func: () => void): void;
  92734. /**
  92735. * Unregisters a function called before every frame render
  92736. * @param func defines the function to unregister
  92737. */
  92738. unregisterBeforeRender(func: () => void): void;
  92739. /**
  92740. * Registers a function to be called after every frame render
  92741. * @param func defines the function to register
  92742. */
  92743. registerAfterRender(func: () => void): void;
  92744. /**
  92745. * Unregisters a function called after every frame render
  92746. * @param func defines the function to unregister
  92747. */
  92748. unregisterAfterRender(func: () => void): void;
  92749. private _executeOnceBeforeRender;
  92750. /**
  92751. * The provided function will run before render once and will be disposed afterwards.
  92752. * A timeout delay can be provided so that the function will be executed in N ms.
  92753. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92754. * @param func The function to be executed.
  92755. * @param timeout optional delay in ms
  92756. */
  92757. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92758. /** @hidden */
  92759. _addPendingData(data: any): void;
  92760. /** @hidden */
  92761. _removePendingData(data: any): void;
  92762. /**
  92763. * Returns the number of items waiting to be loaded
  92764. * @returns the number of items waiting to be loaded
  92765. */
  92766. getWaitingItemsCount(): number;
  92767. /**
  92768. * Returns a boolean indicating if the scene is still loading data
  92769. */
  92770. readonly isLoading: boolean;
  92771. /**
  92772. * Registers a function to be executed when the scene is ready
  92773. * @param {Function} func - the function to be executed
  92774. */
  92775. executeWhenReady(func: () => void): void;
  92776. /**
  92777. * Returns a promise that resolves when the scene is ready
  92778. * @returns A promise that resolves when the scene is ready
  92779. */
  92780. whenReadyAsync(): Promise<void>;
  92781. /** @hidden */
  92782. _checkIsReady(): void;
  92783. /**
  92784. * Gets all animatable attached to the scene
  92785. */
  92786. readonly animatables: Animatable[];
  92787. /**
  92788. * Resets the last animation time frame.
  92789. * Useful to override when animations start running when loading a scene for the first time.
  92790. */
  92791. resetLastAnimationTimeFrame(): void;
  92792. /**
  92793. * Gets the current view matrix
  92794. * @returns a Matrix
  92795. */
  92796. getViewMatrix(): Matrix;
  92797. /**
  92798. * Gets the current projection matrix
  92799. * @returns a Matrix
  92800. */
  92801. getProjectionMatrix(): Matrix;
  92802. /**
  92803. * Gets the current transform matrix
  92804. * @returns a Matrix made of View * Projection
  92805. */
  92806. getTransformMatrix(): Matrix;
  92807. /**
  92808. * Sets the current transform matrix
  92809. * @param viewL defines the View matrix to use
  92810. * @param projectionL defines the Projection matrix to use
  92811. * @param viewR defines the right View matrix to use (if provided)
  92812. * @param projectionR defines the right Projection matrix to use (if provided)
  92813. */
  92814. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92815. /**
  92816. * Gets the uniform buffer used to store scene data
  92817. * @returns a UniformBuffer
  92818. */
  92819. getSceneUniformBuffer(): UniformBuffer;
  92820. /**
  92821. * Gets an unique (relatively to the current scene) Id
  92822. * @returns an unique number for the scene
  92823. */
  92824. getUniqueId(): number;
  92825. /**
  92826. * Add a mesh to the list of scene's meshes
  92827. * @param newMesh defines the mesh to add
  92828. * @param recursive if all child meshes should also be added to the scene
  92829. */
  92830. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92831. /**
  92832. * Remove a mesh for the list of scene's meshes
  92833. * @param toRemove defines the mesh to remove
  92834. * @param recursive if all child meshes should also be removed from the scene
  92835. * @returns the index where the mesh was in the mesh list
  92836. */
  92837. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92838. /**
  92839. * Add a transform node to the list of scene's transform nodes
  92840. * @param newTransformNode defines the transform node to add
  92841. */
  92842. addTransformNode(newTransformNode: TransformNode): void;
  92843. /**
  92844. * Remove a transform node for the list of scene's transform nodes
  92845. * @param toRemove defines the transform node to remove
  92846. * @returns the index where the transform node was in the transform node list
  92847. */
  92848. removeTransformNode(toRemove: TransformNode): number;
  92849. /**
  92850. * Remove a skeleton for the list of scene's skeletons
  92851. * @param toRemove defines the skeleton to remove
  92852. * @returns the index where the skeleton was in the skeleton list
  92853. */
  92854. removeSkeleton(toRemove: Skeleton): number;
  92855. /**
  92856. * Remove a morph target for the list of scene's morph targets
  92857. * @param toRemove defines the morph target to remove
  92858. * @returns the index where the morph target was in the morph target list
  92859. */
  92860. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92861. /**
  92862. * Remove a light for the list of scene's lights
  92863. * @param toRemove defines the light to remove
  92864. * @returns the index where the light was in the light list
  92865. */
  92866. removeLight(toRemove: Light): number;
  92867. /**
  92868. * Remove a camera for the list of scene's cameras
  92869. * @param toRemove defines the camera to remove
  92870. * @returns the index where the camera was in the camera list
  92871. */
  92872. removeCamera(toRemove: Camera): number;
  92873. /**
  92874. * Remove a particle system for the list of scene's particle systems
  92875. * @param toRemove defines the particle system to remove
  92876. * @returns the index where the particle system was in the particle system list
  92877. */
  92878. removeParticleSystem(toRemove: IParticleSystem): number;
  92879. /**
  92880. * Remove a animation for the list of scene's animations
  92881. * @param toRemove defines the animation to remove
  92882. * @returns the index where the animation was in the animation list
  92883. */
  92884. removeAnimation(toRemove: Animation): number;
  92885. /**
  92886. * Removes the given animation group from this scene.
  92887. * @param toRemove The animation group to remove
  92888. * @returns The index of the removed animation group
  92889. */
  92890. removeAnimationGroup(toRemove: AnimationGroup): number;
  92891. /**
  92892. * Removes the given multi-material from this scene.
  92893. * @param toRemove The multi-material to remove
  92894. * @returns The index of the removed multi-material
  92895. */
  92896. removeMultiMaterial(toRemove: MultiMaterial): number;
  92897. /**
  92898. * Removes the given material from this scene.
  92899. * @param toRemove The material to remove
  92900. * @returns The index of the removed material
  92901. */
  92902. removeMaterial(toRemove: Material): number;
  92903. /**
  92904. * Removes the given action manager from this scene.
  92905. * @param toRemove The action manager to remove
  92906. * @returns The index of the removed action manager
  92907. */
  92908. removeActionManager(toRemove: AbstractActionManager): number;
  92909. /**
  92910. * Removes the given texture from this scene.
  92911. * @param toRemove The texture to remove
  92912. * @returns The index of the removed texture
  92913. */
  92914. removeTexture(toRemove: BaseTexture): number;
  92915. /**
  92916. * Adds the given light to this scene
  92917. * @param newLight The light to add
  92918. */
  92919. addLight(newLight: Light): void;
  92920. /**
  92921. * Sorts the list list based on light priorities
  92922. */
  92923. sortLightsByPriority(): void;
  92924. /**
  92925. * Adds the given camera to this scene
  92926. * @param newCamera The camera to add
  92927. */
  92928. addCamera(newCamera: Camera): void;
  92929. /**
  92930. * Adds the given skeleton to this scene
  92931. * @param newSkeleton The skeleton to add
  92932. */
  92933. addSkeleton(newSkeleton: Skeleton): void;
  92934. /**
  92935. * Adds the given particle system to this scene
  92936. * @param newParticleSystem The particle system to add
  92937. */
  92938. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92939. /**
  92940. * Adds the given animation to this scene
  92941. * @param newAnimation The animation to add
  92942. */
  92943. addAnimation(newAnimation: Animation): void;
  92944. /**
  92945. * Adds the given animation group to this scene.
  92946. * @param newAnimationGroup The animation group to add
  92947. */
  92948. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92949. /**
  92950. * Adds the given multi-material to this scene
  92951. * @param newMultiMaterial The multi-material to add
  92952. */
  92953. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92954. /**
  92955. * Adds the given material to this scene
  92956. * @param newMaterial The material to add
  92957. */
  92958. addMaterial(newMaterial: Material): void;
  92959. /**
  92960. * Adds the given morph target to this scene
  92961. * @param newMorphTargetManager The morph target to add
  92962. */
  92963. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92964. /**
  92965. * Adds the given geometry to this scene
  92966. * @param newGeometry The geometry to add
  92967. */
  92968. addGeometry(newGeometry: Geometry): void;
  92969. /**
  92970. * Adds the given action manager to this scene
  92971. * @param newActionManager The action manager to add
  92972. */
  92973. addActionManager(newActionManager: AbstractActionManager): void;
  92974. /**
  92975. * Adds the given texture to this scene.
  92976. * @param newTexture The texture to add
  92977. */
  92978. addTexture(newTexture: BaseTexture): void;
  92979. /**
  92980. * Switch active camera
  92981. * @param newCamera defines the new active camera
  92982. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92983. */
  92984. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92985. /**
  92986. * sets the active camera of the scene using its ID
  92987. * @param id defines the camera's ID
  92988. * @return the new active camera or null if none found.
  92989. */
  92990. setActiveCameraByID(id: string): Nullable<Camera>;
  92991. /**
  92992. * sets the active camera of the scene using its name
  92993. * @param name defines the camera's name
  92994. * @returns the new active camera or null if none found.
  92995. */
  92996. setActiveCameraByName(name: string): Nullable<Camera>;
  92997. /**
  92998. * get an animation group using its name
  92999. * @param name defines the material's name
  93000. * @return the animation group or null if none found.
  93001. */
  93002. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93003. /**
  93004. * Get a material using its unique id
  93005. * @param uniqueId defines the material's unique id
  93006. * @return the material or null if none found.
  93007. */
  93008. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93009. /**
  93010. * get a material using its id
  93011. * @param id defines the material's ID
  93012. * @return the material or null if none found.
  93013. */
  93014. getMaterialByID(id: string): Nullable<Material>;
  93015. /**
  93016. * Gets a material using its name
  93017. * @param name defines the material's name
  93018. * @return the material or null if none found.
  93019. */
  93020. getMaterialByName(name: string): Nullable<Material>;
  93021. /**
  93022. * Gets a camera using its id
  93023. * @param id defines the id to look for
  93024. * @returns the camera or null if not found
  93025. */
  93026. getCameraByID(id: string): Nullable<Camera>;
  93027. /**
  93028. * Gets a camera using its unique id
  93029. * @param uniqueId defines the unique id to look for
  93030. * @returns the camera or null if not found
  93031. */
  93032. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93033. /**
  93034. * Gets a camera using its name
  93035. * @param name defines the camera's name
  93036. * @return the camera or null if none found.
  93037. */
  93038. getCameraByName(name: string): Nullable<Camera>;
  93039. /**
  93040. * Gets a bone using its id
  93041. * @param id defines the bone's id
  93042. * @return the bone or null if not found
  93043. */
  93044. getBoneByID(id: string): Nullable<Bone>;
  93045. /**
  93046. * Gets a bone using its id
  93047. * @param name defines the bone's name
  93048. * @return the bone or null if not found
  93049. */
  93050. getBoneByName(name: string): Nullable<Bone>;
  93051. /**
  93052. * Gets a light node using its name
  93053. * @param name defines the the light's name
  93054. * @return the light or null if none found.
  93055. */
  93056. getLightByName(name: string): Nullable<Light>;
  93057. /**
  93058. * Gets a light node using its id
  93059. * @param id defines the light's id
  93060. * @return the light or null if none found.
  93061. */
  93062. getLightByID(id: string): Nullable<Light>;
  93063. /**
  93064. * Gets a light node using its scene-generated unique ID
  93065. * @param uniqueId defines the light's unique id
  93066. * @return the light or null if none found.
  93067. */
  93068. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93069. /**
  93070. * Gets a particle system by id
  93071. * @param id defines the particle system id
  93072. * @return the corresponding system or null if none found
  93073. */
  93074. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93075. /**
  93076. * Gets a geometry using its ID
  93077. * @param id defines the geometry's id
  93078. * @return the geometry or null if none found.
  93079. */
  93080. getGeometryByID(id: string): Nullable<Geometry>;
  93081. private _getGeometryByUniqueID;
  93082. /**
  93083. * Add a new geometry to this scene
  93084. * @param geometry defines the geometry to be added to the scene.
  93085. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93086. * @return a boolean defining if the geometry was added or not
  93087. */
  93088. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93089. /**
  93090. * Removes an existing geometry
  93091. * @param geometry defines the geometry to be removed from the scene
  93092. * @return a boolean defining if the geometry was removed or not
  93093. */
  93094. removeGeometry(geometry: Geometry): boolean;
  93095. /**
  93096. * Gets the list of geometries attached to the scene
  93097. * @returns an array of Geometry
  93098. */
  93099. getGeometries(): Geometry[];
  93100. /**
  93101. * Gets the first added mesh found of a given ID
  93102. * @param id defines the id to search for
  93103. * @return the mesh found or null if not found at all
  93104. */
  93105. getMeshByID(id: string): Nullable<AbstractMesh>;
  93106. /**
  93107. * Gets a list of meshes using their id
  93108. * @param id defines the id to search for
  93109. * @returns a list of meshes
  93110. */
  93111. getMeshesByID(id: string): Array<AbstractMesh>;
  93112. /**
  93113. * Gets the first added transform node found of a given ID
  93114. * @param id defines the id to search for
  93115. * @return the found transform node or null if not found at all.
  93116. */
  93117. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93118. /**
  93119. * Gets a transform node with its auto-generated unique id
  93120. * @param uniqueId efines the unique id to search for
  93121. * @return the found transform node or null if not found at all.
  93122. */
  93123. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93124. /**
  93125. * Gets a list of transform nodes using their id
  93126. * @param id defines the id to search for
  93127. * @returns a list of transform nodes
  93128. */
  93129. getTransformNodesByID(id: string): Array<TransformNode>;
  93130. /**
  93131. * Gets a mesh with its auto-generated unique id
  93132. * @param uniqueId defines the unique id to search for
  93133. * @return the found mesh or null if not found at all.
  93134. */
  93135. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93136. /**
  93137. * Gets a the last added mesh using a given id
  93138. * @param id defines the id to search for
  93139. * @return the found mesh or null if not found at all.
  93140. */
  93141. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93142. /**
  93143. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93144. * @param id defines the id to search for
  93145. * @return the found node or null if not found at all
  93146. */
  93147. getLastEntryByID(id: string): Nullable<Node>;
  93148. /**
  93149. * Gets a node (Mesh, Camera, Light) using a given id
  93150. * @param id defines the id to search for
  93151. * @return the found node or null if not found at all
  93152. */
  93153. getNodeByID(id: string): Nullable<Node>;
  93154. /**
  93155. * Gets a node (Mesh, Camera, Light) using a given name
  93156. * @param name defines the name to search for
  93157. * @return the found node or null if not found at all.
  93158. */
  93159. getNodeByName(name: string): Nullable<Node>;
  93160. /**
  93161. * Gets a mesh using a given name
  93162. * @param name defines the name to search for
  93163. * @return the found mesh or null if not found at all.
  93164. */
  93165. getMeshByName(name: string): Nullable<AbstractMesh>;
  93166. /**
  93167. * Gets a transform node using a given name
  93168. * @param name defines the name to search for
  93169. * @return the found transform node or null if not found at all.
  93170. */
  93171. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93172. /**
  93173. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93174. * @param id defines the id to search for
  93175. * @return the found skeleton or null if not found at all.
  93176. */
  93177. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93178. /**
  93179. * Gets a skeleton using a given auto generated unique id
  93180. * @param uniqueId defines the unique id to search for
  93181. * @return the found skeleton or null if not found at all.
  93182. */
  93183. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93184. /**
  93185. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93186. * @param id defines the id to search for
  93187. * @return the found skeleton or null if not found at all.
  93188. */
  93189. getSkeletonById(id: string): Nullable<Skeleton>;
  93190. /**
  93191. * Gets a skeleton using a given name
  93192. * @param name defines the name to search for
  93193. * @return the found skeleton or null if not found at all.
  93194. */
  93195. getSkeletonByName(name: string): Nullable<Skeleton>;
  93196. /**
  93197. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93198. * @param id defines the id to search for
  93199. * @return the found morph target manager or null if not found at all.
  93200. */
  93201. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93202. /**
  93203. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93204. * @param id defines the id to search for
  93205. * @return the found morph target or null if not found at all.
  93206. */
  93207. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93208. /**
  93209. * Gets a boolean indicating if the given mesh is active
  93210. * @param mesh defines the mesh to look for
  93211. * @returns true if the mesh is in the active list
  93212. */
  93213. isActiveMesh(mesh: AbstractMesh): boolean;
  93214. /**
  93215. * Return a unique id as a string which can serve as an identifier for the scene
  93216. */
  93217. readonly uid: string;
  93218. /**
  93219. * Add an externaly attached data from its key.
  93220. * This method call will fail and return false, if such key already exists.
  93221. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93222. * @param key the unique key that identifies the data
  93223. * @param data the data object to associate to the key for this Engine instance
  93224. * @return true if no such key were already present and the data was added successfully, false otherwise
  93225. */
  93226. addExternalData<T>(key: string, data: T): boolean;
  93227. /**
  93228. * Get an externaly attached data from its key
  93229. * @param key the unique key that identifies the data
  93230. * @return the associated data, if present (can be null), or undefined if not present
  93231. */
  93232. getExternalData<T>(key: string): Nullable<T>;
  93233. /**
  93234. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93235. * @param key the unique key that identifies the data
  93236. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93237. * @return the associated data, can be null if the factory returned null.
  93238. */
  93239. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93240. /**
  93241. * Remove an externaly attached data from the Engine instance
  93242. * @param key the unique key that identifies the data
  93243. * @return true if the data was successfully removed, false if it doesn't exist
  93244. */
  93245. removeExternalData(key: string): boolean;
  93246. private _evaluateSubMesh;
  93247. /**
  93248. * Clear the processed materials smart array preventing retention point in material dispose.
  93249. */
  93250. freeProcessedMaterials(): void;
  93251. private _preventFreeActiveMeshesAndRenderingGroups;
  93252. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93253. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93254. * when disposing several meshes in a row or a hierarchy of meshes.
  93255. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93256. */
  93257. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93258. /**
  93259. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93260. */
  93261. freeActiveMeshes(): void;
  93262. /**
  93263. * Clear the info related to rendering groups preventing retention points during dispose.
  93264. */
  93265. freeRenderingGroups(): void;
  93266. /** @hidden */
  93267. _isInIntermediateRendering(): boolean;
  93268. /**
  93269. * Lambda returning the list of potentially active meshes.
  93270. */
  93271. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93272. /**
  93273. * Lambda returning the list of potentially active sub meshes.
  93274. */
  93275. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93276. /**
  93277. * Lambda returning the list of potentially intersecting sub meshes.
  93278. */
  93279. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93280. /**
  93281. * Lambda returning the list of potentially colliding sub meshes.
  93282. */
  93283. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93284. private _activeMeshesFrozen;
  93285. /**
  93286. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93287. * @returns the current scene
  93288. */
  93289. freezeActiveMeshes(): Scene;
  93290. /**
  93291. * Use this function to restart evaluating active meshes on every frame
  93292. * @returns the current scene
  93293. */
  93294. unfreezeActiveMeshes(): Scene;
  93295. private _evaluateActiveMeshes;
  93296. private _activeMesh;
  93297. /**
  93298. * Update the transform matrix to update from the current active camera
  93299. * @param force defines a boolean used to force the update even if cache is up to date
  93300. */
  93301. updateTransformMatrix(force?: boolean): void;
  93302. private _bindFrameBuffer;
  93303. /** @hidden */
  93304. _allowPostProcessClearColor: boolean;
  93305. /** @hidden */
  93306. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93307. private _processSubCameras;
  93308. private _checkIntersections;
  93309. /** @hidden */
  93310. _advancePhysicsEngineStep(step: number): void;
  93311. /**
  93312. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93313. */
  93314. getDeterministicFrameTime: () => number;
  93315. /** @hidden */
  93316. _animate(): void;
  93317. /** Execute all animations (for a frame) */
  93318. animate(): void;
  93319. /**
  93320. * Render the scene
  93321. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93322. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93323. */
  93324. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93325. /**
  93326. * Freeze all materials
  93327. * A frozen material will not be updatable but should be faster to render
  93328. */
  93329. freezeMaterials(): void;
  93330. /**
  93331. * Unfreeze all materials
  93332. * A frozen material will not be updatable but should be faster to render
  93333. */
  93334. unfreezeMaterials(): void;
  93335. /**
  93336. * Releases all held ressources
  93337. */
  93338. dispose(): void;
  93339. /**
  93340. * Gets if the scene is already disposed
  93341. */
  93342. readonly isDisposed: boolean;
  93343. /**
  93344. * Call this function to reduce memory footprint of the scene.
  93345. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93346. */
  93347. clearCachedVertexData(): void;
  93348. /**
  93349. * This function will remove the local cached buffer data from texture.
  93350. * It will save memory but will prevent the texture from being rebuilt
  93351. */
  93352. cleanCachedTextureBuffer(): void;
  93353. /**
  93354. * Get the world extend vectors with an optional filter
  93355. *
  93356. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93357. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93358. */
  93359. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93360. min: Vector3;
  93361. max: Vector3;
  93362. };
  93363. /**
  93364. * Creates a ray that can be used to pick in the scene
  93365. * @param x defines the x coordinate of the origin (on-screen)
  93366. * @param y defines the y coordinate of the origin (on-screen)
  93367. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93368. * @param camera defines the camera to use for the picking
  93369. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93370. * @returns a Ray
  93371. */
  93372. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93373. /**
  93374. * Creates a ray that can be used to pick in the scene
  93375. * @param x defines the x coordinate of the origin (on-screen)
  93376. * @param y defines the y coordinate of the origin (on-screen)
  93377. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93378. * @param result defines the ray where to store the picking ray
  93379. * @param camera defines the camera to use for the picking
  93380. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93381. * @returns the current scene
  93382. */
  93383. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93384. /**
  93385. * Creates a ray that can be used to pick in the scene
  93386. * @param x defines the x coordinate of the origin (on-screen)
  93387. * @param y defines the y coordinate of the origin (on-screen)
  93388. * @param camera defines the camera to use for the picking
  93389. * @returns a Ray
  93390. */
  93391. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93392. /**
  93393. * Creates a ray that can be used to pick in the scene
  93394. * @param x defines the x coordinate of the origin (on-screen)
  93395. * @param y defines the y coordinate of the origin (on-screen)
  93396. * @param result defines the ray where to store the picking ray
  93397. * @param camera defines the camera to use for the picking
  93398. * @returns the current scene
  93399. */
  93400. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93401. /** Launch a ray to try to pick a mesh in the scene
  93402. * @param x position on screen
  93403. * @param y position on screen
  93404. * @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
  93405. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93406. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93407. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93408. * @returns a PickingInfo
  93409. */
  93410. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93411. /** Use the given ray to pick a mesh in the scene
  93412. * @param ray The ray to use to pick meshes
  93413. * @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
  93414. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93415. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93416. * @returns a PickingInfo
  93417. */
  93418. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93419. /**
  93420. * Launch a ray to try to pick a mesh in the scene
  93421. * @param x X position on screen
  93422. * @param y Y position on screen
  93423. * @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
  93424. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93425. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93426. * @returns an array of PickingInfo
  93427. */
  93428. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93429. /**
  93430. * Launch a ray to try to pick a mesh in the scene
  93431. * @param ray Ray to use
  93432. * @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
  93433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93434. * @returns an array of PickingInfo
  93435. */
  93436. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93437. /**
  93438. * Force the value of meshUnderPointer
  93439. * @param mesh defines the mesh to use
  93440. */
  93441. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93442. /**
  93443. * Gets the mesh under the pointer
  93444. * @returns a Mesh or null if no mesh is under the pointer
  93445. */
  93446. getPointerOverMesh(): Nullable<AbstractMesh>;
  93447. /** @hidden */
  93448. _rebuildGeometries(): void;
  93449. /** @hidden */
  93450. _rebuildTextures(): void;
  93451. private _getByTags;
  93452. /**
  93453. * Get a list of meshes by tags
  93454. * @param tagsQuery defines the tags query to use
  93455. * @param forEach defines a predicate used to filter results
  93456. * @returns an array of Mesh
  93457. */
  93458. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93459. /**
  93460. * Get a list of cameras by tags
  93461. * @param tagsQuery defines the tags query to use
  93462. * @param forEach defines a predicate used to filter results
  93463. * @returns an array of Camera
  93464. */
  93465. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93466. /**
  93467. * Get a list of lights by tags
  93468. * @param tagsQuery defines the tags query to use
  93469. * @param forEach defines a predicate used to filter results
  93470. * @returns an array of Light
  93471. */
  93472. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93473. /**
  93474. * Get a list of materials by tags
  93475. * @param tagsQuery defines the tags query to use
  93476. * @param forEach defines a predicate used to filter results
  93477. * @returns an array of Material
  93478. */
  93479. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93480. /**
  93481. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93482. * This allowed control for front to back rendering or reversly depending of the special needs.
  93483. *
  93484. * @param renderingGroupId The rendering group id corresponding to its index
  93485. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93486. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93487. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93488. */
  93489. 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;
  93490. /**
  93491. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93492. *
  93493. * @param renderingGroupId The rendering group id corresponding to its index
  93494. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93495. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93496. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93497. */
  93498. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93499. /**
  93500. * Gets the current auto clear configuration for one rendering group of the rendering
  93501. * manager.
  93502. * @param index the rendering group index to get the information for
  93503. * @returns The auto clear setup for the requested rendering group
  93504. */
  93505. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93506. private _blockMaterialDirtyMechanism;
  93507. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93508. blockMaterialDirtyMechanism: boolean;
  93509. /**
  93510. * Will flag all materials as dirty to trigger new shader compilation
  93511. * @param flag defines the flag used to specify which material part must be marked as dirty
  93512. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93513. */
  93514. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93515. /** @hidden */
  93516. _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;
  93517. /** @hidden */
  93518. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93519. }
  93520. }
  93521. declare module BABYLON {
  93522. /**
  93523. * Set of assets to keep when moving a scene into an asset container.
  93524. */
  93525. export class KeepAssets extends AbstractScene {
  93526. }
  93527. /**
  93528. * Container with a set of assets that can be added or removed from a scene.
  93529. */
  93530. export class AssetContainer extends AbstractScene {
  93531. /**
  93532. * The scene the AssetContainer belongs to.
  93533. */
  93534. scene: Scene;
  93535. /**
  93536. * Instantiates an AssetContainer.
  93537. * @param scene The scene the AssetContainer belongs to.
  93538. */
  93539. constructor(scene: Scene);
  93540. /**
  93541. * Adds all the assets from the container to the scene.
  93542. */
  93543. addAllToScene(): void;
  93544. /**
  93545. * Removes all the assets in the container from the scene
  93546. */
  93547. removeAllFromScene(): void;
  93548. /**
  93549. * Disposes all the assets in the container
  93550. */
  93551. dispose(): void;
  93552. private _moveAssets;
  93553. /**
  93554. * Removes all the assets contained in the scene and adds them to the container.
  93555. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93556. */
  93557. moveAllFromScene(keepAssets?: KeepAssets): void;
  93558. /**
  93559. * 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.
  93560. * @returns the root mesh
  93561. */
  93562. createRootMesh(): Mesh;
  93563. }
  93564. }
  93565. declare module BABYLON {
  93566. /**
  93567. * Defines how the parser contract is defined.
  93568. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93569. */
  93570. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93571. /**
  93572. * Defines how the individual parser contract is defined.
  93573. * These parser can parse an individual asset
  93574. */
  93575. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93576. /**
  93577. * Base class of the scene acting as a container for the different elements composing a scene.
  93578. * This class is dynamically extended by the different components of the scene increasing
  93579. * flexibility and reducing coupling
  93580. */
  93581. export abstract class AbstractScene {
  93582. /**
  93583. * Stores the list of available parsers in the application.
  93584. */
  93585. private static _BabylonFileParsers;
  93586. /**
  93587. * Stores the list of available individual parsers in the application.
  93588. */
  93589. private static _IndividualBabylonFileParsers;
  93590. /**
  93591. * Adds a parser in the list of available ones
  93592. * @param name Defines the name of the parser
  93593. * @param parser Defines the parser to add
  93594. */
  93595. static AddParser(name: string, parser: BabylonFileParser): void;
  93596. /**
  93597. * Gets a general parser from the list of avaialble ones
  93598. * @param name Defines the name of the parser
  93599. * @returns the requested parser or null
  93600. */
  93601. static GetParser(name: string): Nullable<BabylonFileParser>;
  93602. /**
  93603. * Adds n individual parser in the list of available ones
  93604. * @param name Defines the name of the parser
  93605. * @param parser Defines the parser to add
  93606. */
  93607. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93608. /**
  93609. * Gets an individual parser from the list of avaialble ones
  93610. * @param name Defines the name of the parser
  93611. * @returns the requested parser or null
  93612. */
  93613. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93614. /**
  93615. * Parser json data and populate both a scene and its associated container object
  93616. * @param jsonData Defines the data to parse
  93617. * @param scene Defines the scene to parse the data for
  93618. * @param container Defines the container attached to the parsing sequence
  93619. * @param rootUrl Defines the root url of the data
  93620. */
  93621. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93622. /**
  93623. * Gets the list of root nodes (ie. nodes with no parent)
  93624. */
  93625. rootNodes: Node[];
  93626. /** All of the cameras added to this scene
  93627. * @see http://doc.babylonjs.com/babylon101/cameras
  93628. */
  93629. cameras: Camera[];
  93630. /**
  93631. * All of the lights added to this scene
  93632. * @see http://doc.babylonjs.com/babylon101/lights
  93633. */
  93634. lights: Light[];
  93635. /**
  93636. * All of the (abstract) meshes added to this scene
  93637. */
  93638. meshes: AbstractMesh[];
  93639. /**
  93640. * The list of skeletons added to the scene
  93641. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93642. */
  93643. skeletons: Skeleton[];
  93644. /**
  93645. * All of the particle systems added to this scene
  93646. * @see http://doc.babylonjs.com/babylon101/particles
  93647. */
  93648. particleSystems: IParticleSystem[];
  93649. /**
  93650. * Gets a list of Animations associated with the scene
  93651. */
  93652. animations: Animation[];
  93653. /**
  93654. * All of the animation groups added to this scene
  93655. * @see http://doc.babylonjs.com/how_to/group
  93656. */
  93657. animationGroups: AnimationGroup[];
  93658. /**
  93659. * All of the multi-materials added to this scene
  93660. * @see http://doc.babylonjs.com/how_to/multi_materials
  93661. */
  93662. multiMaterials: MultiMaterial[];
  93663. /**
  93664. * All of the materials added to this scene
  93665. * In the context of a Scene, it is not supposed to be modified manually.
  93666. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93667. * Note also that the order of the Material wihin the array is not significant and might change.
  93668. * @see http://doc.babylonjs.com/babylon101/materials
  93669. */
  93670. materials: Material[];
  93671. /**
  93672. * The list of morph target managers added to the scene
  93673. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93674. */
  93675. morphTargetManagers: MorphTargetManager[];
  93676. /**
  93677. * The list of geometries used in the scene.
  93678. */
  93679. geometries: Geometry[];
  93680. /**
  93681. * All of the tranform nodes added to this scene
  93682. * In the context of a Scene, it is not supposed to be modified manually.
  93683. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93684. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93685. * @see http://doc.babylonjs.com/how_to/transformnode
  93686. */
  93687. transformNodes: TransformNode[];
  93688. /**
  93689. * ActionManagers available on the scene.
  93690. */
  93691. actionManagers: AbstractActionManager[];
  93692. /**
  93693. * Textures to keep.
  93694. */
  93695. textures: BaseTexture[];
  93696. /**
  93697. * Environment texture for the scene
  93698. */
  93699. environmentTexture: Nullable<BaseTexture>;
  93700. }
  93701. }
  93702. declare module BABYLON {
  93703. /**
  93704. * Defines a sound that can be played in the application.
  93705. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93707. */
  93708. export class Sound {
  93709. /**
  93710. * The name of the sound in the scene.
  93711. */
  93712. name: string;
  93713. /**
  93714. * Does the sound autoplay once loaded.
  93715. */
  93716. autoplay: boolean;
  93717. /**
  93718. * Does the sound loop after it finishes playing once.
  93719. */
  93720. loop: boolean;
  93721. /**
  93722. * Does the sound use a custom attenuation curve to simulate the falloff
  93723. * happening when the source gets further away from the camera.
  93724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93725. */
  93726. useCustomAttenuation: boolean;
  93727. /**
  93728. * The sound track id this sound belongs to.
  93729. */
  93730. soundTrackId: number;
  93731. /**
  93732. * Is this sound currently played.
  93733. */
  93734. isPlaying: boolean;
  93735. /**
  93736. * Is this sound currently paused.
  93737. */
  93738. isPaused: boolean;
  93739. /**
  93740. * Does this sound enables spatial sound.
  93741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93742. */
  93743. spatialSound: boolean;
  93744. /**
  93745. * Define the reference distance the sound should be heard perfectly.
  93746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93747. */
  93748. refDistance: number;
  93749. /**
  93750. * Define the roll off factor of spatial sounds.
  93751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93752. */
  93753. rolloffFactor: number;
  93754. /**
  93755. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93757. */
  93758. maxDistance: number;
  93759. /**
  93760. * Define the distance attenuation model the sound will follow.
  93761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93762. */
  93763. distanceModel: string;
  93764. /**
  93765. * @hidden
  93766. * Back Compat
  93767. **/
  93768. onended: () => any;
  93769. /**
  93770. * Observable event when the current playing sound finishes.
  93771. */
  93772. onEndedObservable: Observable<Sound>;
  93773. private _panningModel;
  93774. private _playbackRate;
  93775. private _streaming;
  93776. private _startTime;
  93777. private _startOffset;
  93778. private _position;
  93779. /** @hidden */
  93780. _positionInEmitterSpace: boolean;
  93781. private _localDirection;
  93782. private _volume;
  93783. private _isReadyToPlay;
  93784. private _isDirectional;
  93785. private _readyToPlayCallback;
  93786. private _audioBuffer;
  93787. private _soundSource;
  93788. private _streamingSource;
  93789. private _soundPanner;
  93790. private _soundGain;
  93791. private _inputAudioNode;
  93792. private _outputAudioNode;
  93793. private _coneInnerAngle;
  93794. private _coneOuterAngle;
  93795. private _coneOuterGain;
  93796. private _scene;
  93797. private _connectedTransformNode;
  93798. private _customAttenuationFunction;
  93799. private _registerFunc;
  93800. private _isOutputConnected;
  93801. private _htmlAudioElement;
  93802. private _urlType;
  93803. /** @hidden */
  93804. static _SceneComponentInitialization: (scene: Scene) => void;
  93805. /**
  93806. * Create a sound and attach it to a scene
  93807. * @param name Name of your sound
  93808. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93809. * @param scene defines the scene the sound belongs to
  93810. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93811. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93812. */
  93813. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93814. /**
  93815. * Release the sound and its associated resources
  93816. */
  93817. dispose(): void;
  93818. /**
  93819. * Gets if the sounds is ready to be played or not.
  93820. * @returns true if ready, otherwise false
  93821. */
  93822. isReady(): boolean;
  93823. private _soundLoaded;
  93824. /**
  93825. * Sets the data of the sound from an audiobuffer
  93826. * @param audioBuffer The audioBuffer containing the data
  93827. */
  93828. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93829. /**
  93830. * Updates the current sounds options such as maxdistance, loop...
  93831. * @param options A JSON object containing values named as the object properties
  93832. */
  93833. updateOptions(options: any): void;
  93834. private _createSpatialParameters;
  93835. private _updateSpatialParameters;
  93836. /**
  93837. * Switch the panning model to HRTF:
  93838. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93840. */
  93841. switchPanningModelToHRTF(): void;
  93842. /**
  93843. * Switch the panning model to Equal Power:
  93844. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93846. */
  93847. switchPanningModelToEqualPower(): void;
  93848. private _switchPanningModel;
  93849. /**
  93850. * Connect this sound to a sound track audio node like gain...
  93851. * @param soundTrackAudioNode the sound track audio node to connect to
  93852. */
  93853. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93854. /**
  93855. * Transform this sound into a directional source
  93856. * @param coneInnerAngle Size of the inner cone in degree
  93857. * @param coneOuterAngle Size of the outer cone in degree
  93858. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93859. */
  93860. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93861. /**
  93862. * Gets or sets the inner angle for the directional cone.
  93863. */
  93864. /**
  93865. * Gets or sets the inner angle for the directional cone.
  93866. */
  93867. directionalConeInnerAngle: number;
  93868. /**
  93869. * Gets or sets the outer angle for the directional cone.
  93870. */
  93871. /**
  93872. * Gets or sets the outer angle for the directional cone.
  93873. */
  93874. directionalConeOuterAngle: number;
  93875. /**
  93876. * Sets the position of the emitter if spatial sound is enabled
  93877. * @param newPosition Defines the new posisiton
  93878. */
  93879. setPosition(newPosition: Vector3): void;
  93880. /**
  93881. * Sets the local direction of the emitter if spatial sound is enabled
  93882. * @param newLocalDirection Defines the new local direction
  93883. */
  93884. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93885. private _updateDirection;
  93886. /** @hidden */
  93887. updateDistanceFromListener(): void;
  93888. /**
  93889. * Sets a new custom attenuation function for the sound.
  93890. * @param callback Defines the function used for the attenuation
  93891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93892. */
  93893. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93894. /**
  93895. * Play the sound
  93896. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93897. * @param offset (optional) Start the sound setting it at a specific time
  93898. */
  93899. play(time?: number, offset?: number): void;
  93900. private _onended;
  93901. /**
  93902. * Stop the sound
  93903. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93904. */
  93905. stop(time?: number): void;
  93906. /**
  93907. * Put the sound in pause
  93908. */
  93909. pause(): void;
  93910. /**
  93911. * Sets a dedicated volume for this sounds
  93912. * @param newVolume Define the new volume of the sound
  93913. * @param time Define in how long the sound should be at this value
  93914. */
  93915. setVolume(newVolume: number, time?: number): void;
  93916. /**
  93917. * Set the sound play back rate
  93918. * @param newPlaybackRate Define the playback rate the sound should be played at
  93919. */
  93920. setPlaybackRate(newPlaybackRate: number): void;
  93921. /**
  93922. * Gets the volume of the sound.
  93923. * @returns the volume of the sound
  93924. */
  93925. getVolume(): number;
  93926. /**
  93927. * Attach the sound to a dedicated mesh
  93928. * @param transformNode The transform node to connect the sound with
  93929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93930. */
  93931. attachToMesh(transformNode: TransformNode): void;
  93932. /**
  93933. * Detach the sound from the previously attached mesh
  93934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93935. */
  93936. detachFromMesh(): void;
  93937. private _onRegisterAfterWorldMatrixUpdate;
  93938. /**
  93939. * Clone the current sound in the scene.
  93940. * @returns the new sound clone
  93941. */
  93942. clone(): Nullable<Sound>;
  93943. /**
  93944. * Gets the current underlying audio buffer containing the data
  93945. * @returns the audio buffer
  93946. */
  93947. getAudioBuffer(): Nullable<AudioBuffer>;
  93948. /**
  93949. * Serializes the Sound in a JSON representation
  93950. * @returns the JSON representation of the sound
  93951. */
  93952. serialize(): any;
  93953. /**
  93954. * Parse a JSON representation of a sound to innstantiate in a given scene
  93955. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93956. * @param scene Define the scene the new parsed sound should be created in
  93957. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93958. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93959. * @returns the newly parsed sound
  93960. */
  93961. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93962. }
  93963. }
  93964. declare module BABYLON {
  93965. /**
  93966. * This defines an action helpful to play a defined sound on a triggered action.
  93967. */
  93968. export class PlaySoundAction extends Action {
  93969. private _sound;
  93970. /**
  93971. * Instantiate the action
  93972. * @param triggerOptions defines the trigger options
  93973. * @param sound defines the sound to play
  93974. * @param condition defines the trigger related conditions
  93975. */
  93976. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93977. /** @hidden */
  93978. _prepare(): void;
  93979. /**
  93980. * Execute the action and play the sound.
  93981. */
  93982. execute(): void;
  93983. /**
  93984. * Serializes the actions and its related information.
  93985. * @param parent defines the object to serialize in
  93986. * @returns the serialized object
  93987. */
  93988. serialize(parent: any): any;
  93989. }
  93990. /**
  93991. * This defines an action helpful to stop a defined sound on a triggered action.
  93992. */
  93993. export class StopSoundAction extends Action {
  93994. private _sound;
  93995. /**
  93996. * Instantiate the action
  93997. * @param triggerOptions defines the trigger options
  93998. * @param sound defines the sound to stop
  93999. * @param condition defines the trigger related conditions
  94000. */
  94001. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94002. /** @hidden */
  94003. _prepare(): void;
  94004. /**
  94005. * Execute the action and stop the sound.
  94006. */
  94007. execute(): void;
  94008. /**
  94009. * Serializes the actions and its related information.
  94010. * @param parent defines the object to serialize in
  94011. * @returns the serialized object
  94012. */
  94013. serialize(parent: any): any;
  94014. }
  94015. }
  94016. declare module BABYLON {
  94017. /**
  94018. * This defines an action responsible to change the value of a property
  94019. * by interpolating between its current value and the newly set one once triggered.
  94020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94021. */
  94022. export class InterpolateValueAction extends Action {
  94023. /**
  94024. * Defines the path of the property where the value should be interpolated
  94025. */
  94026. propertyPath: string;
  94027. /**
  94028. * Defines the target value at the end of the interpolation.
  94029. */
  94030. value: any;
  94031. /**
  94032. * Defines the time it will take for the property to interpolate to the value.
  94033. */
  94034. duration: number;
  94035. /**
  94036. * Defines if the other scene animations should be stopped when the action has been triggered
  94037. */
  94038. stopOtherAnimations?: boolean;
  94039. /**
  94040. * Defines a callback raised once the interpolation animation has been done.
  94041. */
  94042. onInterpolationDone?: () => void;
  94043. /**
  94044. * Observable triggered once the interpolation animation has been done.
  94045. */
  94046. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94047. private _target;
  94048. private _effectiveTarget;
  94049. private _property;
  94050. /**
  94051. * Instantiate the action
  94052. * @param triggerOptions defines the trigger options
  94053. * @param target defines the object containing the value to interpolate
  94054. * @param propertyPath defines the path to the property in the target object
  94055. * @param value defines the target value at the end of the interpolation
  94056. * @param duration deines the time it will take for the property to interpolate to the value.
  94057. * @param condition defines the trigger related conditions
  94058. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94059. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94060. */
  94061. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94062. /** @hidden */
  94063. _prepare(): void;
  94064. /**
  94065. * Execute the action starts the value interpolation.
  94066. */
  94067. execute(): void;
  94068. /**
  94069. * Serializes the actions and its related information.
  94070. * @param parent defines the object to serialize in
  94071. * @returns the serialized object
  94072. */
  94073. serialize(parent: any): any;
  94074. }
  94075. }
  94076. declare module BABYLON {
  94077. /**
  94078. * Options allowed during the creation of a sound track.
  94079. */
  94080. export interface ISoundTrackOptions {
  94081. /**
  94082. * The volume the sound track should take during creation
  94083. */
  94084. volume?: number;
  94085. /**
  94086. * Define if the sound track is the main sound track of the scene
  94087. */
  94088. mainTrack?: boolean;
  94089. }
  94090. /**
  94091. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94092. * It will be also used in a future release to apply effects on a specific track.
  94093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94094. */
  94095. export class SoundTrack {
  94096. /**
  94097. * The unique identifier of the sound track in the scene.
  94098. */
  94099. id: number;
  94100. /**
  94101. * The list of sounds included in the sound track.
  94102. */
  94103. soundCollection: Array<Sound>;
  94104. private _outputAudioNode;
  94105. private _scene;
  94106. private _isMainTrack;
  94107. private _connectedAnalyser;
  94108. private _options;
  94109. private _isInitialized;
  94110. /**
  94111. * Creates a new sound track.
  94112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94113. * @param scene Define the scene the sound track belongs to
  94114. * @param options
  94115. */
  94116. constructor(scene: Scene, options?: ISoundTrackOptions);
  94117. private _initializeSoundTrackAudioGraph;
  94118. /**
  94119. * Release the sound track and its associated resources
  94120. */
  94121. dispose(): void;
  94122. /**
  94123. * Adds a sound to this sound track
  94124. * @param sound define the cound to add
  94125. * @ignoreNaming
  94126. */
  94127. AddSound(sound: Sound): void;
  94128. /**
  94129. * Removes a sound to this sound track
  94130. * @param sound define the cound to remove
  94131. * @ignoreNaming
  94132. */
  94133. RemoveSound(sound: Sound): void;
  94134. /**
  94135. * Set a global volume for the full sound track.
  94136. * @param newVolume Define the new volume of the sound track
  94137. */
  94138. setVolume(newVolume: number): void;
  94139. /**
  94140. * Switch the panning model to HRTF:
  94141. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94143. */
  94144. switchPanningModelToHRTF(): void;
  94145. /**
  94146. * Switch the panning model to Equal Power:
  94147. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94149. */
  94150. switchPanningModelToEqualPower(): void;
  94151. /**
  94152. * Connect the sound track to an audio analyser allowing some amazing
  94153. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94155. * @param analyser The analyser to connect to the engine
  94156. */
  94157. connectToAnalyser(analyser: Analyser): void;
  94158. }
  94159. }
  94160. declare module BABYLON {
  94161. interface AbstractScene {
  94162. /**
  94163. * The list of sounds used in the scene.
  94164. */
  94165. sounds: Nullable<Array<Sound>>;
  94166. }
  94167. interface Scene {
  94168. /**
  94169. * @hidden
  94170. * Backing field
  94171. */
  94172. _mainSoundTrack: SoundTrack;
  94173. /**
  94174. * The main sound track played by the scene.
  94175. * It cotains your primary collection of sounds.
  94176. */
  94177. mainSoundTrack: SoundTrack;
  94178. /**
  94179. * The list of sound tracks added to the scene
  94180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94181. */
  94182. soundTracks: Nullable<Array<SoundTrack>>;
  94183. /**
  94184. * Gets a sound using a given name
  94185. * @param name defines the name to search for
  94186. * @return the found sound or null if not found at all.
  94187. */
  94188. getSoundByName(name: string): Nullable<Sound>;
  94189. /**
  94190. * Gets or sets if audio support is enabled
  94191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94192. */
  94193. audioEnabled: boolean;
  94194. /**
  94195. * Gets or sets if audio will be output to headphones
  94196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94197. */
  94198. headphone: boolean;
  94199. }
  94200. /**
  94201. * Defines the sound scene component responsible to manage any sounds
  94202. * in a given scene.
  94203. */
  94204. export class AudioSceneComponent implements ISceneSerializableComponent {
  94205. /**
  94206. * The component name helpfull to identify the component in the list of scene components.
  94207. */
  94208. readonly name: string;
  94209. /**
  94210. * The scene the component belongs to.
  94211. */
  94212. scene: Scene;
  94213. private _audioEnabled;
  94214. /**
  94215. * Gets whether audio is enabled or not.
  94216. * Please use related enable/disable method to switch state.
  94217. */
  94218. readonly audioEnabled: boolean;
  94219. private _headphone;
  94220. /**
  94221. * Gets whether audio is outputing to headphone or not.
  94222. * Please use the according Switch methods to change output.
  94223. */
  94224. readonly headphone: boolean;
  94225. /**
  94226. * Creates a new instance of the component for the given scene
  94227. * @param scene Defines the scene to register the component in
  94228. */
  94229. constructor(scene: Scene);
  94230. /**
  94231. * Registers the component in a given scene
  94232. */
  94233. register(): void;
  94234. /**
  94235. * Rebuilds the elements related to this component in case of
  94236. * context lost for instance.
  94237. */
  94238. rebuild(): void;
  94239. /**
  94240. * Serializes the component data to the specified json object
  94241. * @param serializationObject The object to serialize to
  94242. */
  94243. serialize(serializationObject: any): void;
  94244. /**
  94245. * Adds all the element from the container to the scene
  94246. * @param container the container holding the elements
  94247. */
  94248. addFromContainer(container: AbstractScene): void;
  94249. /**
  94250. * Removes all the elements in the container from the scene
  94251. * @param container contains the elements to remove
  94252. * @param dispose if the removed element should be disposed (default: false)
  94253. */
  94254. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94255. /**
  94256. * Disposes the component and the associated ressources.
  94257. */
  94258. dispose(): void;
  94259. /**
  94260. * Disables audio in the associated scene.
  94261. */
  94262. disableAudio(): void;
  94263. /**
  94264. * Enables audio in the associated scene.
  94265. */
  94266. enableAudio(): void;
  94267. /**
  94268. * Switch audio to headphone output.
  94269. */
  94270. switchAudioModeForHeadphones(): void;
  94271. /**
  94272. * Switch audio to normal speakers.
  94273. */
  94274. switchAudioModeForNormalSpeakers(): void;
  94275. private _afterRender;
  94276. }
  94277. }
  94278. declare module BABYLON {
  94279. /**
  94280. * Wraps one or more Sound objects and selects one with random weight for playback.
  94281. */
  94282. export class WeightedSound {
  94283. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94284. loop: boolean;
  94285. private _coneInnerAngle;
  94286. private _coneOuterAngle;
  94287. private _volume;
  94288. /** A Sound is currently playing. */
  94289. isPlaying: boolean;
  94290. /** A Sound is currently paused. */
  94291. isPaused: boolean;
  94292. private _sounds;
  94293. private _weights;
  94294. private _currentIndex?;
  94295. /**
  94296. * Creates a new WeightedSound from the list of sounds given.
  94297. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94298. * @param sounds Array of Sounds that will be selected from.
  94299. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94300. */
  94301. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94302. /**
  94303. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94304. */
  94305. /**
  94306. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94307. */
  94308. directionalConeInnerAngle: number;
  94309. /**
  94310. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94311. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94312. */
  94313. /**
  94314. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94315. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94316. */
  94317. directionalConeOuterAngle: number;
  94318. /**
  94319. * Playback volume.
  94320. */
  94321. /**
  94322. * Playback volume.
  94323. */
  94324. volume: number;
  94325. private _onended;
  94326. /**
  94327. * Suspend playback
  94328. */
  94329. pause(): void;
  94330. /**
  94331. * Stop playback
  94332. */
  94333. stop(): void;
  94334. /**
  94335. * Start playback.
  94336. * @param startOffset Position the clip head at a specific time in seconds.
  94337. */
  94338. play(startOffset?: number): void;
  94339. }
  94340. }
  94341. declare module BABYLON {
  94342. /**
  94343. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94345. */
  94346. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94347. /**
  94348. * Gets the name of the behavior.
  94349. */
  94350. readonly name: string;
  94351. /**
  94352. * The easing function used by animations
  94353. */
  94354. static EasingFunction: BackEase;
  94355. /**
  94356. * The easing mode used by animations
  94357. */
  94358. static EasingMode: number;
  94359. /**
  94360. * The duration of the animation, in milliseconds
  94361. */
  94362. transitionDuration: number;
  94363. /**
  94364. * Length of the distance animated by the transition when lower radius is reached
  94365. */
  94366. lowerRadiusTransitionRange: number;
  94367. /**
  94368. * Length of the distance animated by the transition when upper radius is reached
  94369. */
  94370. upperRadiusTransitionRange: number;
  94371. private _autoTransitionRange;
  94372. /**
  94373. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94374. */
  94375. /**
  94376. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94377. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94378. */
  94379. autoTransitionRange: boolean;
  94380. private _attachedCamera;
  94381. private _onAfterCheckInputsObserver;
  94382. private _onMeshTargetChangedObserver;
  94383. /**
  94384. * Initializes the behavior.
  94385. */
  94386. init(): void;
  94387. /**
  94388. * Attaches the behavior to its arc rotate camera.
  94389. * @param camera Defines the camera to attach the behavior to
  94390. */
  94391. attach(camera: ArcRotateCamera): void;
  94392. /**
  94393. * Detaches the behavior from its current arc rotate camera.
  94394. */
  94395. detach(): void;
  94396. private _radiusIsAnimating;
  94397. private _radiusBounceTransition;
  94398. private _animatables;
  94399. private _cachedWheelPrecision;
  94400. /**
  94401. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94402. * @param radiusLimit The limit to check against.
  94403. * @return Bool to indicate if at limit.
  94404. */
  94405. private _isRadiusAtLimit;
  94406. /**
  94407. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94408. * @param radiusDelta The delta by which to animate to. Can be negative.
  94409. */
  94410. private _applyBoundRadiusAnimation;
  94411. /**
  94412. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94413. */
  94414. protected _clearAnimationLocks(): void;
  94415. /**
  94416. * Stops and removes all animations that have been applied to the camera
  94417. */
  94418. stopAllAnimations(): void;
  94419. }
  94420. }
  94421. declare module BABYLON {
  94422. /**
  94423. * 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.
  94424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94425. */
  94426. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94427. /**
  94428. * Gets the name of the behavior.
  94429. */
  94430. readonly name: string;
  94431. private _mode;
  94432. private _radiusScale;
  94433. private _positionScale;
  94434. private _defaultElevation;
  94435. private _elevationReturnTime;
  94436. private _elevationReturnWaitTime;
  94437. private _zoomStopsAnimation;
  94438. private _framingTime;
  94439. /**
  94440. * The easing function used by animations
  94441. */
  94442. static EasingFunction: ExponentialEase;
  94443. /**
  94444. * The easing mode used by animations
  94445. */
  94446. static EasingMode: number;
  94447. /**
  94448. * Sets the current mode used by the behavior
  94449. */
  94450. /**
  94451. * Gets current mode used by the behavior.
  94452. */
  94453. mode: number;
  94454. /**
  94455. * Sets the scale applied to the radius (1 by default)
  94456. */
  94457. /**
  94458. * Gets the scale applied to the radius
  94459. */
  94460. radiusScale: number;
  94461. /**
  94462. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94463. */
  94464. /**
  94465. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94466. */
  94467. positionScale: number;
  94468. /**
  94469. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94470. * behaviour is triggered, in radians.
  94471. */
  94472. /**
  94473. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94474. * behaviour is triggered, in radians.
  94475. */
  94476. defaultElevation: number;
  94477. /**
  94478. * Sets the time (in milliseconds) taken to return to the default beta position.
  94479. * Negative value indicates camera should not return to default.
  94480. */
  94481. /**
  94482. * Gets the time (in milliseconds) taken to return to the default beta position.
  94483. * Negative value indicates camera should not return to default.
  94484. */
  94485. elevationReturnTime: number;
  94486. /**
  94487. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94488. */
  94489. /**
  94490. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94491. */
  94492. elevationReturnWaitTime: number;
  94493. /**
  94494. * Sets the flag that indicates if user zooming should stop animation.
  94495. */
  94496. /**
  94497. * Gets the flag that indicates if user zooming should stop animation.
  94498. */
  94499. zoomStopsAnimation: boolean;
  94500. /**
  94501. * Sets the transition time when framing the mesh, in milliseconds
  94502. */
  94503. /**
  94504. * Gets the transition time when framing the mesh, in milliseconds
  94505. */
  94506. framingTime: number;
  94507. /**
  94508. * Define if the behavior should automatically change the configured
  94509. * camera limits and sensibilities.
  94510. */
  94511. autoCorrectCameraLimitsAndSensibility: boolean;
  94512. private _onPrePointerObservableObserver;
  94513. private _onAfterCheckInputsObserver;
  94514. private _onMeshTargetChangedObserver;
  94515. private _attachedCamera;
  94516. private _isPointerDown;
  94517. private _lastInteractionTime;
  94518. /**
  94519. * Initializes the behavior.
  94520. */
  94521. init(): void;
  94522. /**
  94523. * Attaches the behavior to its arc rotate camera.
  94524. * @param camera Defines the camera to attach the behavior to
  94525. */
  94526. attach(camera: ArcRotateCamera): void;
  94527. /**
  94528. * Detaches the behavior from its current arc rotate camera.
  94529. */
  94530. detach(): void;
  94531. private _animatables;
  94532. private _betaIsAnimating;
  94533. private _betaTransition;
  94534. private _radiusTransition;
  94535. private _vectorTransition;
  94536. /**
  94537. * Targets the given mesh and updates zoom level accordingly.
  94538. * @param mesh The mesh to target.
  94539. * @param radius Optional. If a cached radius position already exists, overrides default.
  94540. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94541. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94542. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94543. */
  94544. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94545. /**
  94546. * Targets the given mesh with its children and updates zoom level accordingly.
  94547. * @param mesh The mesh to target.
  94548. * @param radius Optional. If a cached radius position already exists, overrides default.
  94549. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94550. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94551. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94552. */
  94553. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94554. /**
  94555. * Targets the given meshes with their children and updates zoom level accordingly.
  94556. * @param meshes The mesh to target.
  94557. * @param radius Optional. If a cached radius position already exists, overrides default.
  94558. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94559. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94560. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94561. */
  94562. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94563. /**
  94564. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94565. * @param minimumWorld Determines the smaller position of the bounding box extend
  94566. * @param maximumWorld Determines the bigger position of the bounding box extend
  94567. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94568. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94569. */
  94570. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94571. /**
  94572. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94573. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94574. * frustum width.
  94575. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94576. * to fully enclose the mesh in the viewing frustum.
  94577. */
  94578. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94579. /**
  94580. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94581. * is automatically returned to its default position (expected to be above ground plane).
  94582. */
  94583. private _maintainCameraAboveGround;
  94584. /**
  94585. * Returns the frustum slope based on the canvas ratio and camera FOV
  94586. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94587. */
  94588. private _getFrustumSlope;
  94589. /**
  94590. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94591. */
  94592. private _clearAnimationLocks;
  94593. /**
  94594. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94595. */
  94596. private _applyUserInteraction;
  94597. /**
  94598. * Stops and removes all animations that have been applied to the camera
  94599. */
  94600. stopAllAnimations(): void;
  94601. /**
  94602. * Gets a value indicating if the user is moving the camera
  94603. */
  94604. readonly isUserIsMoving: boolean;
  94605. /**
  94606. * The camera can move all the way towards the mesh.
  94607. */
  94608. static IgnoreBoundsSizeMode: number;
  94609. /**
  94610. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94611. */
  94612. static FitFrustumSidesMode: number;
  94613. }
  94614. }
  94615. declare module BABYLON {
  94616. /**
  94617. * Base class for Camera Pointer Inputs.
  94618. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94619. * for example usage.
  94620. */
  94621. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94622. /**
  94623. * Defines the camera the input is attached to.
  94624. */
  94625. abstract camera: Camera;
  94626. /**
  94627. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94628. */
  94629. protected _altKey: boolean;
  94630. protected _ctrlKey: boolean;
  94631. protected _metaKey: boolean;
  94632. protected _shiftKey: boolean;
  94633. /**
  94634. * Which mouse buttons were pressed at time of last mouse event.
  94635. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94636. */
  94637. protected _buttonsPressed: number;
  94638. /**
  94639. * Defines the buttons associated with the input to handle camera move.
  94640. */
  94641. buttons: number[];
  94642. /**
  94643. * Attach the input controls to a specific dom element to get the input from.
  94644. * @param element Defines the element the controls should be listened from
  94645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94646. */
  94647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94648. /**
  94649. * Detach the current controls from the specified dom element.
  94650. * @param element Defines the element to stop listening the inputs from
  94651. */
  94652. detachControl(element: Nullable<HTMLElement>): void;
  94653. /**
  94654. * Gets the class name of the current input.
  94655. * @returns the class name
  94656. */
  94657. getClassName(): string;
  94658. /**
  94659. * Get the friendly name associated with the input class.
  94660. * @returns the input friendly name
  94661. */
  94662. getSimpleName(): string;
  94663. /**
  94664. * Called on pointer POINTERDOUBLETAP event.
  94665. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94666. */
  94667. protected onDoubleTap(type: string): void;
  94668. /**
  94669. * Called on pointer POINTERMOVE event if only a single touch is active.
  94670. * Override this method to provide functionality.
  94671. */
  94672. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94673. /**
  94674. * Called on pointer POINTERMOVE event if multiple touches are active.
  94675. * Override this method to provide functionality.
  94676. */
  94677. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94678. /**
  94679. * Called on JS contextmenu event.
  94680. * Override this method to provide functionality.
  94681. */
  94682. protected onContextMenu(evt: PointerEvent): void;
  94683. /**
  94684. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94685. * press.
  94686. * Override this method to provide functionality.
  94687. */
  94688. protected onButtonDown(evt: PointerEvent): void;
  94689. /**
  94690. * Called each time a new POINTERUP event occurs. Ie, for each button
  94691. * release.
  94692. * Override this method to provide functionality.
  94693. */
  94694. protected onButtonUp(evt: PointerEvent): void;
  94695. /**
  94696. * Called when window becomes inactive.
  94697. * Override this method to provide functionality.
  94698. */
  94699. protected onLostFocus(): void;
  94700. private _pointerInput;
  94701. private _observer;
  94702. private _onLostFocus;
  94703. private pointA;
  94704. private pointB;
  94705. }
  94706. }
  94707. declare module BABYLON {
  94708. /**
  94709. * Manage the pointers inputs to control an arc rotate camera.
  94710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94711. */
  94712. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94713. /**
  94714. * Defines the camera the input is attached to.
  94715. */
  94716. camera: ArcRotateCamera;
  94717. /**
  94718. * Gets the class name of the current input.
  94719. * @returns the class name
  94720. */
  94721. getClassName(): string;
  94722. /**
  94723. * Defines the buttons associated with the input to handle camera move.
  94724. */
  94725. buttons: number[];
  94726. /**
  94727. * Defines the pointer angular sensibility along the X axis or how fast is
  94728. * the camera rotating.
  94729. */
  94730. angularSensibilityX: number;
  94731. /**
  94732. * Defines the pointer angular sensibility along the Y axis or how fast is
  94733. * the camera rotating.
  94734. */
  94735. angularSensibilityY: number;
  94736. /**
  94737. * Defines the pointer pinch precision or how fast is the camera zooming.
  94738. */
  94739. pinchPrecision: number;
  94740. /**
  94741. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94742. * from 0.
  94743. * It defines the percentage of current camera.radius to use as delta when
  94744. * pinch zoom is used.
  94745. */
  94746. pinchDeltaPercentage: number;
  94747. /**
  94748. * Defines the pointer panning sensibility or how fast is the camera moving.
  94749. */
  94750. panningSensibility: number;
  94751. /**
  94752. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94753. */
  94754. multiTouchPanning: boolean;
  94755. /**
  94756. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94757. * zoom (pinch) through multitouch.
  94758. */
  94759. multiTouchPanAndZoom: boolean;
  94760. /**
  94761. * Revers pinch action direction.
  94762. */
  94763. pinchInwards: boolean;
  94764. private _isPanClick;
  94765. private _twoFingerActivityCount;
  94766. private _isPinching;
  94767. /**
  94768. * Called on pointer POINTERMOVE event if only a single touch is active.
  94769. */
  94770. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94771. /**
  94772. * Called on pointer POINTERDOUBLETAP event.
  94773. */
  94774. protected onDoubleTap(type: string): void;
  94775. /**
  94776. * Called on pointer POINTERMOVE event if multiple touches are active.
  94777. */
  94778. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94779. /**
  94780. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94781. * press.
  94782. */
  94783. protected onButtonDown(evt: PointerEvent): void;
  94784. /**
  94785. * Called each time a new POINTERUP event occurs. Ie, for each button
  94786. * release.
  94787. */
  94788. protected onButtonUp(evt: PointerEvent): void;
  94789. /**
  94790. * Called when window becomes inactive.
  94791. */
  94792. protected onLostFocus(): void;
  94793. }
  94794. }
  94795. declare module BABYLON {
  94796. /**
  94797. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94799. */
  94800. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94801. /**
  94802. * Defines the camera the input is attached to.
  94803. */
  94804. camera: ArcRotateCamera;
  94805. /**
  94806. * Defines the list of key codes associated with the up action (increase alpha)
  94807. */
  94808. keysUp: number[];
  94809. /**
  94810. * Defines the list of key codes associated with the down action (decrease alpha)
  94811. */
  94812. keysDown: number[];
  94813. /**
  94814. * Defines the list of key codes associated with the left action (increase beta)
  94815. */
  94816. keysLeft: number[];
  94817. /**
  94818. * Defines the list of key codes associated with the right action (decrease beta)
  94819. */
  94820. keysRight: number[];
  94821. /**
  94822. * Defines the list of key codes associated with the reset action.
  94823. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94824. */
  94825. keysReset: number[];
  94826. /**
  94827. * Defines the panning sensibility of the inputs.
  94828. * (How fast is the camera paning)
  94829. */
  94830. panningSensibility: number;
  94831. /**
  94832. * Defines the zooming sensibility of the inputs.
  94833. * (How fast is the camera zooming)
  94834. */
  94835. zoomingSensibility: number;
  94836. /**
  94837. * Defines wether maintaining the alt key down switch the movement mode from
  94838. * orientation to zoom.
  94839. */
  94840. useAltToZoom: boolean;
  94841. /**
  94842. * Rotation speed of the camera
  94843. */
  94844. angularSpeed: number;
  94845. private _keys;
  94846. private _ctrlPressed;
  94847. private _altPressed;
  94848. private _onCanvasBlurObserver;
  94849. private _onKeyboardObserver;
  94850. private _engine;
  94851. private _scene;
  94852. /**
  94853. * Attach the input controls to a specific dom element to get the input from.
  94854. * @param element Defines the element the controls should be listened from
  94855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94856. */
  94857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94858. /**
  94859. * Detach the current controls from the specified dom element.
  94860. * @param element Defines the element to stop listening the inputs from
  94861. */
  94862. detachControl(element: Nullable<HTMLElement>): void;
  94863. /**
  94864. * Update the current camera state depending on the inputs that have been used this frame.
  94865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94866. */
  94867. checkInputs(): void;
  94868. /**
  94869. * Gets the class name of the current intput.
  94870. * @returns the class name
  94871. */
  94872. getClassName(): string;
  94873. /**
  94874. * Get the friendly name associated with the input class.
  94875. * @returns the input friendly name
  94876. */
  94877. getSimpleName(): string;
  94878. }
  94879. }
  94880. declare module BABYLON {
  94881. /**
  94882. * Manage the mouse wheel inputs to control an arc rotate camera.
  94883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94884. */
  94885. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94886. /**
  94887. * Defines the camera the input is attached to.
  94888. */
  94889. camera: ArcRotateCamera;
  94890. /**
  94891. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94892. */
  94893. wheelPrecision: number;
  94894. /**
  94895. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94896. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94897. */
  94898. wheelDeltaPercentage: number;
  94899. private _wheel;
  94900. private _observer;
  94901. /**
  94902. * Attach the input controls to a specific dom element to get the input from.
  94903. * @param element Defines the element the controls should be listened from
  94904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94905. */
  94906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94907. /**
  94908. * Detach the current controls from the specified dom element.
  94909. * @param element Defines the element to stop listening the inputs from
  94910. */
  94911. detachControl(element: Nullable<HTMLElement>): void;
  94912. /**
  94913. * Gets the class name of the current intput.
  94914. * @returns the class name
  94915. */
  94916. getClassName(): string;
  94917. /**
  94918. * Get the friendly name associated with the input class.
  94919. * @returns the input friendly name
  94920. */
  94921. getSimpleName(): string;
  94922. }
  94923. }
  94924. declare module BABYLON {
  94925. /**
  94926. * Default Inputs manager for the ArcRotateCamera.
  94927. * It groups all the default supported inputs for ease of use.
  94928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94929. */
  94930. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94931. /**
  94932. * Instantiates a new ArcRotateCameraInputsManager.
  94933. * @param camera Defines the camera the inputs belong to
  94934. */
  94935. constructor(camera: ArcRotateCamera);
  94936. /**
  94937. * Add mouse wheel input support to the input manager.
  94938. * @returns the current input manager
  94939. */
  94940. addMouseWheel(): ArcRotateCameraInputsManager;
  94941. /**
  94942. * Add pointers input support to the input manager.
  94943. * @returns the current input manager
  94944. */
  94945. addPointers(): ArcRotateCameraInputsManager;
  94946. /**
  94947. * Add keyboard input support to the input manager.
  94948. * @returns the current input manager
  94949. */
  94950. addKeyboard(): ArcRotateCameraInputsManager;
  94951. }
  94952. }
  94953. declare module BABYLON {
  94954. /**
  94955. * This represents an orbital type of camera.
  94956. *
  94957. * 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.
  94958. * 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.
  94959. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94960. */
  94961. export class ArcRotateCamera extends TargetCamera {
  94962. /**
  94963. * Defines the rotation angle of the camera along the longitudinal axis.
  94964. */
  94965. alpha: number;
  94966. /**
  94967. * Defines the rotation angle of the camera along the latitudinal axis.
  94968. */
  94969. beta: number;
  94970. /**
  94971. * Defines the radius of the camera from it s target point.
  94972. */
  94973. radius: number;
  94974. protected _target: Vector3;
  94975. protected _targetHost: Nullable<AbstractMesh>;
  94976. /**
  94977. * Defines the target point of the camera.
  94978. * The camera looks towards it form the radius distance.
  94979. */
  94980. target: Vector3;
  94981. /**
  94982. * Define the current local position of the camera in the scene
  94983. */
  94984. position: Vector3;
  94985. protected _upVector: Vector3;
  94986. protected _upToYMatrix: Matrix;
  94987. protected _YToUpMatrix: Matrix;
  94988. /**
  94989. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94990. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94991. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94992. */
  94993. upVector: Vector3;
  94994. /**
  94995. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94996. */
  94997. setMatUp(): void;
  94998. /**
  94999. * Current inertia value on the longitudinal axis.
  95000. * The bigger this number the longer it will take for the camera to stop.
  95001. */
  95002. inertialAlphaOffset: number;
  95003. /**
  95004. * Current inertia value on the latitudinal axis.
  95005. * The bigger this number the longer it will take for the camera to stop.
  95006. */
  95007. inertialBetaOffset: number;
  95008. /**
  95009. * Current inertia value on the radius axis.
  95010. * The bigger this number the longer it will take for the camera to stop.
  95011. */
  95012. inertialRadiusOffset: number;
  95013. /**
  95014. * Minimum allowed angle on the longitudinal axis.
  95015. * This can help limiting how the Camera is able to move in the scene.
  95016. */
  95017. lowerAlphaLimit: Nullable<number>;
  95018. /**
  95019. * Maximum allowed angle on the longitudinal axis.
  95020. * This can help limiting how the Camera is able to move in the scene.
  95021. */
  95022. upperAlphaLimit: Nullable<number>;
  95023. /**
  95024. * Minimum allowed angle on the latitudinal axis.
  95025. * This can help limiting how the Camera is able to move in the scene.
  95026. */
  95027. lowerBetaLimit: number;
  95028. /**
  95029. * Maximum allowed angle on the latitudinal axis.
  95030. * This can help limiting how the Camera is able to move in the scene.
  95031. */
  95032. upperBetaLimit: number;
  95033. /**
  95034. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95035. * This can help limiting how the Camera is able to move in the scene.
  95036. */
  95037. lowerRadiusLimit: Nullable<number>;
  95038. /**
  95039. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95040. * This can help limiting how the Camera is able to move in the scene.
  95041. */
  95042. upperRadiusLimit: Nullable<number>;
  95043. /**
  95044. * Defines the current inertia value used during panning of the camera along the X axis.
  95045. */
  95046. inertialPanningX: number;
  95047. /**
  95048. * Defines the current inertia value used during panning of the camera along the Y axis.
  95049. */
  95050. inertialPanningY: number;
  95051. /**
  95052. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95053. * Basically if your fingers moves away from more than this distance you will be considered
  95054. * in pinch mode.
  95055. */
  95056. pinchToPanMaxDistance: number;
  95057. /**
  95058. * Defines the maximum distance the camera can pan.
  95059. * This could help keeping the cammera always in your scene.
  95060. */
  95061. panningDistanceLimit: Nullable<number>;
  95062. /**
  95063. * Defines the target of the camera before paning.
  95064. */
  95065. panningOriginTarget: Vector3;
  95066. /**
  95067. * Defines the value of the inertia used during panning.
  95068. * 0 would mean stop inertia and one would mean no decelleration at all.
  95069. */
  95070. panningInertia: number;
  95071. /**
  95072. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95073. */
  95074. angularSensibilityX: number;
  95075. /**
  95076. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95077. */
  95078. angularSensibilityY: number;
  95079. /**
  95080. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95081. */
  95082. pinchPrecision: number;
  95083. /**
  95084. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95085. * It will be used instead of pinchDeltaPrecision if different from 0.
  95086. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95087. */
  95088. pinchDeltaPercentage: number;
  95089. /**
  95090. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95091. */
  95092. panningSensibility: number;
  95093. /**
  95094. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95095. */
  95096. keysUp: number[];
  95097. /**
  95098. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95099. */
  95100. keysDown: number[];
  95101. /**
  95102. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95103. */
  95104. keysLeft: number[];
  95105. /**
  95106. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95107. */
  95108. keysRight: number[];
  95109. /**
  95110. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95111. */
  95112. wheelPrecision: number;
  95113. /**
  95114. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95115. * It will be used instead of pinchDeltaPrecision if different from 0.
  95116. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95117. */
  95118. wheelDeltaPercentage: number;
  95119. /**
  95120. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95121. */
  95122. zoomOnFactor: number;
  95123. /**
  95124. * Defines a screen offset for the camera position.
  95125. */
  95126. targetScreenOffset: Vector2;
  95127. /**
  95128. * Allows the camera to be completely reversed.
  95129. * If false the camera can not arrive upside down.
  95130. */
  95131. allowUpsideDown: boolean;
  95132. /**
  95133. * Define if double tap/click is used to restore the previously saved state of the camera.
  95134. */
  95135. useInputToRestoreState: boolean;
  95136. /** @hidden */
  95137. _viewMatrix: Matrix;
  95138. /** @hidden */
  95139. _useCtrlForPanning: boolean;
  95140. /** @hidden */
  95141. _panningMouseButton: number;
  95142. /**
  95143. * Defines the input associated to the camera.
  95144. */
  95145. inputs: ArcRotateCameraInputsManager;
  95146. /** @hidden */
  95147. _reset: () => void;
  95148. /**
  95149. * Defines the allowed panning axis.
  95150. */
  95151. panningAxis: Vector3;
  95152. protected _localDirection: Vector3;
  95153. protected _transformedDirection: Vector3;
  95154. private _bouncingBehavior;
  95155. /**
  95156. * Gets the bouncing behavior of the camera if it has been enabled.
  95157. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95158. */
  95159. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95160. /**
  95161. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95163. */
  95164. useBouncingBehavior: boolean;
  95165. private _framingBehavior;
  95166. /**
  95167. * Gets the framing behavior of the camera if it has been enabled.
  95168. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95169. */
  95170. readonly framingBehavior: Nullable<FramingBehavior>;
  95171. /**
  95172. * Defines if the framing behavior of the camera is enabled on the camera.
  95173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95174. */
  95175. useFramingBehavior: boolean;
  95176. private _autoRotationBehavior;
  95177. /**
  95178. * Gets the auto rotation behavior of the camera if it has been enabled.
  95179. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95180. */
  95181. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95182. /**
  95183. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95185. */
  95186. useAutoRotationBehavior: boolean;
  95187. /**
  95188. * Observable triggered when the mesh target has been changed on the camera.
  95189. */
  95190. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95191. /**
  95192. * Event raised when the camera is colliding with a mesh.
  95193. */
  95194. onCollide: (collidedMesh: AbstractMesh) => void;
  95195. /**
  95196. * Defines whether the camera should check collision with the objects oh the scene.
  95197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95198. */
  95199. checkCollisions: boolean;
  95200. /**
  95201. * Defines the collision radius of the camera.
  95202. * This simulates a sphere around the camera.
  95203. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95204. */
  95205. collisionRadius: Vector3;
  95206. protected _collider: Collider;
  95207. protected _previousPosition: Vector3;
  95208. protected _collisionVelocity: Vector3;
  95209. protected _newPosition: Vector3;
  95210. protected _previousAlpha: number;
  95211. protected _previousBeta: number;
  95212. protected _previousRadius: number;
  95213. protected _collisionTriggered: boolean;
  95214. protected _targetBoundingCenter: Nullable<Vector3>;
  95215. private _computationVector;
  95216. /**
  95217. * Instantiates a new ArcRotateCamera in a given scene
  95218. * @param name Defines the name of the camera
  95219. * @param alpha Defines the camera rotation along the logitudinal axis
  95220. * @param beta Defines the camera rotation along the latitudinal axis
  95221. * @param radius Defines the camera distance from its target
  95222. * @param target Defines the camera target
  95223. * @param scene Defines the scene the camera belongs to
  95224. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95225. */
  95226. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95227. /** @hidden */
  95228. _initCache(): void;
  95229. /** @hidden */
  95230. _updateCache(ignoreParentClass?: boolean): void;
  95231. protected _getTargetPosition(): Vector3;
  95232. private _storedAlpha;
  95233. private _storedBeta;
  95234. private _storedRadius;
  95235. private _storedTarget;
  95236. /**
  95237. * Stores the current state of the camera (alpha, beta, radius and target)
  95238. * @returns the camera itself
  95239. */
  95240. storeState(): Camera;
  95241. /**
  95242. * @hidden
  95243. * Restored camera state. You must call storeState() first
  95244. */
  95245. _restoreStateValues(): boolean;
  95246. /** @hidden */
  95247. _isSynchronizedViewMatrix(): boolean;
  95248. /**
  95249. * Attached controls to the current camera.
  95250. * @param element Defines the element the controls should be listened from
  95251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95252. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95253. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95254. */
  95255. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95256. /**
  95257. * Detach the current controls from the camera.
  95258. * The camera will stop reacting to inputs.
  95259. * @param element Defines the element to stop listening the inputs from
  95260. */
  95261. detachControl(element: HTMLElement): void;
  95262. /** @hidden */
  95263. _checkInputs(): void;
  95264. protected _checkLimits(): void;
  95265. /**
  95266. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95267. */
  95268. rebuildAnglesAndRadius(): void;
  95269. /**
  95270. * Use a position to define the current camera related information like aplha, beta and radius
  95271. * @param position Defines the position to set the camera at
  95272. */
  95273. setPosition(position: Vector3): void;
  95274. /**
  95275. * Defines the target the camera should look at.
  95276. * This will automatically adapt alpha beta and radius to fit within the new target.
  95277. * @param target Defines the new target as a Vector or a mesh
  95278. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95279. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95280. */
  95281. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95282. /** @hidden */
  95283. _getViewMatrix(): Matrix;
  95284. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95285. /**
  95286. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95287. * @param meshes Defines the mesh to zoom on
  95288. * @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)
  95289. */
  95290. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95291. /**
  95292. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95293. * The target will be changed but the radius
  95294. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95295. * @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)
  95296. */
  95297. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95298. min: Vector3;
  95299. max: Vector3;
  95300. distance: number;
  95301. }, doNotUpdateMaxZ?: boolean): void;
  95302. /**
  95303. * @override
  95304. * Override Camera.createRigCamera
  95305. */
  95306. createRigCamera(name: string, cameraIndex: number): Camera;
  95307. /**
  95308. * @hidden
  95309. * @override
  95310. * Override Camera._updateRigCameras
  95311. */
  95312. _updateRigCameras(): void;
  95313. /**
  95314. * Destroy the camera and release the current resources hold by it.
  95315. */
  95316. dispose(): void;
  95317. /**
  95318. * Gets the current object class name.
  95319. * @return the class name
  95320. */
  95321. getClassName(): string;
  95322. }
  95323. }
  95324. declare module BABYLON {
  95325. /**
  95326. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95327. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95328. */
  95329. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95330. /**
  95331. * Gets the name of the behavior.
  95332. */
  95333. readonly name: string;
  95334. private _zoomStopsAnimation;
  95335. private _idleRotationSpeed;
  95336. private _idleRotationWaitTime;
  95337. private _idleRotationSpinupTime;
  95338. /**
  95339. * Sets the flag that indicates if user zooming should stop animation.
  95340. */
  95341. /**
  95342. * Gets the flag that indicates if user zooming should stop animation.
  95343. */
  95344. zoomStopsAnimation: boolean;
  95345. /**
  95346. * Sets the default speed at which the camera rotates around the model.
  95347. */
  95348. /**
  95349. * Gets the default speed at which the camera rotates around the model.
  95350. */
  95351. idleRotationSpeed: number;
  95352. /**
  95353. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95354. */
  95355. /**
  95356. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95357. */
  95358. idleRotationWaitTime: number;
  95359. /**
  95360. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95361. */
  95362. /**
  95363. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95364. */
  95365. idleRotationSpinupTime: number;
  95366. /**
  95367. * Gets a value indicating if the camera is currently rotating because of this behavior
  95368. */
  95369. readonly rotationInProgress: boolean;
  95370. private _onPrePointerObservableObserver;
  95371. private _onAfterCheckInputsObserver;
  95372. private _attachedCamera;
  95373. private _isPointerDown;
  95374. private _lastFrameTime;
  95375. private _lastInteractionTime;
  95376. private _cameraRotationSpeed;
  95377. /**
  95378. * Initializes the behavior.
  95379. */
  95380. init(): void;
  95381. /**
  95382. * Attaches the behavior to its arc rotate camera.
  95383. * @param camera Defines the camera to attach the behavior to
  95384. */
  95385. attach(camera: ArcRotateCamera): void;
  95386. /**
  95387. * Detaches the behavior from its current arc rotate camera.
  95388. */
  95389. detach(): void;
  95390. /**
  95391. * Returns true if user is scrolling.
  95392. * @return true if user is scrolling.
  95393. */
  95394. private _userIsZooming;
  95395. private _lastFrameRadius;
  95396. private _shouldAnimationStopForInteraction;
  95397. /**
  95398. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95399. */
  95400. private _applyUserInteraction;
  95401. private _userIsMoving;
  95402. }
  95403. }
  95404. declare module BABYLON {
  95405. /**
  95406. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95407. */
  95408. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95409. private ui;
  95410. /**
  95411. * The name of the behavior
  95412. */
  95413. name: string;
  95414. /**
  95415. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95416. */
  95417. distanceAwayFromFace: number;
  95418. /**
  95419. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95420. */
  95421. distanceAwayFromBottomOfFace: number;
  95422. private _faceVectors;
  95423. private _target;
  95424. private _scene;
  95425. private _onRenderObserver;
  95426. private _tmpMatrix;
  95427. private _tmpVector;
  95428. /**
  95429. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95430. * @param ui The transform node that should be attched to the mesh
  95431. */
  95432. constructor(ui: TransformNode);
  95433. /**
  95434. * Initializes the behavior
  95435. */
  95436. init(): void;
  95437. private _closestFace;
  95438. private _zeroVector;
  95439. private _lookAtTmpMatrix;
  95440. private _lookAtToRef;
  95441. /**
  95442. * Attaches the AttachToBoxBehavior to the passed in mesh
  95443. * @param target The mesh that the specified node will be attached to
  95444. */
  95445. attach(target: Mesh): void;
  95446. /**
  95447. * Detaches the behavior from the mesh
  95448. */
  95449. detach(): void;
  95450. }
  95451. }
  95452. declare module BABYLON {
  95453. /**
  95454. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95455. */
  95456. export class FadeInOutBehavior implements Behavior<Mesh> {
  95457. /**
  95458. * Time in milliseconds to delay before fading in (Default: 0)
  95459. */
  95460. delay: number;
  95461. /**
  95462. * Time in milliseconds for the mesh to fade in (Default: 300)
  95463. */
  95464. fadeInTime: number;
  95465. private _millisecondsPerFrame;
  95466. private _hovered;
  95467. private _hoverValue;
  95468. private _ownerNode;
  95469. /**
  95470. * Instatiates the FadeInOutBehavior
  95471. */
  95472. constructor();
  95473. /**
  95474. * The name of the behavior
  95475. */
  95476. readonly name: string;
  95477. /**
  95478. * Initializes the behavior
  95479. */
  95480. init(): void;
  95481. /**
  95482. * Attaches the fade behavior on the passed in mesh
  95483. * @param ownerNode The mesh that will be faded in/out once attached
  95484. */
  95485. attach(ownerNode: Mesh): void;
  95486. /**
  95487. * Detaches the behavior from the mesh
  95488. */
  95489. detach(): void;
  95490. /**
  95491. * Triggers the mesh to begin fading in or out
  95492. * @param value if the object should fade in or out (true to fade in)
  95493. */
  95494. fadeIn(value: boolean): void;
  95495. private _update;
  95496. private _setAllVisibility;
  95497. }
  95498. }
  95499. declare module BABYLON {
  95500. /**
  95501. * Class containing a set of static utilities functions for managing Pivots
  95502. * @hidden
  95503. */
  95504. export class PivotTools {
  95505. private static _PivotCached;
  95506. private static _OldPivotPoint;
  95507. private static _PivotTranslation;
  95508. private static _PivotTmpVector;
  95509. /** @hidden */
  95510. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95511. /** @hidden */
  95512. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95513. }
  95514. }
  95515. declare module BABYLON {
  95516. /**
  95517. * Class containing static functions to help procedurally build meshes
  95518. */
  95519. export class PlaneBuilder {
  95520. /**
  95521. * Creates a plane mesh
  95522. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95523. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95524. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95528. * @param name defines the name of the mesh
  95529. * @param options defines the options used to create the mesh
  95530. * @param scene defines the hosting scene
  95531. * @returns the plane mesh
  95532. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95533. */
  95534. static CreatePlane(name: string, options: {
  95535. size?: number;
  95536. width?: number;
  95537. height?: number;
  95538. sideOrientation?: number;
  95539. frontUVs?: Vector4;
  95540. backUVs?: Vector4;
  95541. updatable?: boolean;
  95542. sourcePlane?: Plane;
  95543. }, scene?: Nullable<Scene>): Mesh;
  95544. }
  95545. }
  95546. declare module BABYLON {
  95547. /**
  95548. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95549. */
  95550. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95551. private static _AnyMouseID;
  95552. private _attachedNode;
  95553. private _dragPlane;
  95554. private _scene;
  95555. private _pointerObserver;
  95556. private _beforeRenderObserver;
  95557. private static _planeScene;
  95558. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95559. /**
  95560. * 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)
  95561. */
  95562. maxDragAngle: number;
  95563. /**
  95564. * @hidden
  95565. */
  95566. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95567. /**
  95568. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95569. */
  95570. currentDraggingPointerID: number;
  95571. /**
  95572. * The last position where the pointer hit the drag plane in world space
  95573. */
  95574. lastDragPosition: Vector3;
  95575. /**
  95576. * If the behavior is currently in a dragging state
  95577. */
  95578. dragging: boolean;
  95579. /**
  95580. * 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)
  95581. */
  95582. dragDeltaRatio: number;
  95583. /**
  95584. * If the drag plane orientation should be updated during the dragging (Default: true)
  95585. */
  95586. updateDragPlane: boolean;
  95587. private _debugMode;
  95588. private _moving;
  95589. /**
  95590. * Fires each time the attached mesh is dragged with the pointer
  95591. * * delta between last drag position and current drag position in world space
  95592. * * dragDistance along the drag axis
  95593. * * dragPlaneNormal normal of the current drag plane used during the drag
  95594. * * dragPlanePoint in world space where the drag intersects the drag plane
  95595. */
  95596. onDragObservable: Observable<{
  95597. delta: Vector3;
  95598. dragPlanePoint: Vector3;
  95599. dragPlaneNormal: Vector3;
  95600. dragDistance: number;
  95601. pointerId: number;
  95602. }>;
  95603. /**
  95604. * Fires each time a drag begins (eg. mouse down on mesh)
  95605. */
  95606. onDragStartObservable: Observable<{
  95607. dragPlanePoint: Vector3;
  95608. pointerId: number;
  95609. }>;
  95610. /**
  95611. * Fires each time a drag ends (eg. mouse release after drag)
  95612. */
  95613. onDragEndObservable: Observable<{
  95614. dragPlanePoint: Vector3;
  95615. pointerId: number;
  95616. }>;
  95617. /**
  95618. * If the attached mesh should be moved when dragged
  95619. */
  95620. moveAttached: boolean;
  95621. /**
  95622. * If the drag behavior will react to drag events (Default: true)
  95623. */
  95624. enabled: boolean;
  95625. /**
  95626. * If camera controls should be detached during the drag
  95627. */
  95628. detachCameraControls: boolean;
  95629. /**
  95630. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95631. */
  95632. useObjectOrienationForDragging: boolean;
  95633. private _options;
  95634. /**
  95635. * Creates a pointer drag behavior that can be attached to a mesh
  95636. * @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)
  95637. */
  95638. constructor(options?: {
  95639. dragAxis?: Vector3;
  95640. dragPlaneNormal?: Vector3;
  95641. });
  95642. /**
  95643. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95644. */
  95645. validateDrag: (targetPosition: Vector3) => boolean;
  95646. /**
  95647. * The name of the behavior
  95648. */
  95649. readonly name: string;
  95650. /**
  95651. * Initializes the behavior
  95652. */
  95653. init(): void;
  95654. private _tmpVector;
  95655. private _alternatePickedPoint;
  95656. private _worldDragAxis;
  95657. private _targetPosition;
  95658. private _attachedElement;
  95659. /**
  95660. * Attaches the drag behavior the passed in mesh
  95661. * @param ownerNode The mesh that will be dragged around once attached
  95662. */
  95663. attach(ownerNode: AbstractMesh): void;
  95664. /**
  95665. * Force relase the drag action by code.
  95666. */
  95667. releaseDrag(): void;
  95668. private _startDragRay;
  95669. private _lastPointerRay;
  95670. /**
  95671. * Simulates the start of a pointer drag event on the behavior
  95672. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95673. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95674. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95675. */
  95676. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95677. private _startDrag;
  95678. private _dragDelta;
  95679. private _moveDrag;
  95680. private _pickWithRayOnDragPlane;
  95681. private _pointA;
  95682. private _pointB;
  95683. private _pointC;
  95684. private _lineA;
  95685. private _lineB;
  95686. private _localAxis;
  95687. private _lookAt;
  95688. private _updateDragPlanePosition;
  95689. /**
  95690. * Detaches the behavior from the mesh
  95691. */
  95692. detach(): void;
  95693. }
  95694. }
  95695. declare module BABYLON {
  95696. /**
  95697. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95698. */
  95699. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95700. private _dragBehaviorA;
  95701. private _dragBehaviorB;
  95702. private _startDistance;
  95703. private _initialScale;
  95704. private _targetScale;
  95705. private _ownerNode;
  95706. private _sceneRenderObserver;
  95707. /**
  95708. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95709. */
  95710. constructor();
  95711. /**
  95712. * The name of the behavior
  95713. */
  95714. readonly name: string;
  95715. /**
  95716. * Initializes the behavior
  95717. */
  95718. init(): void;
  95719. private _getCurrentDistance;
  95720. /**
  95721. * Attaches the scale behavior the passed in mesh
  95722. * @param ownerNode The mesh that will be scaled around once attached
  95723. */
  95724. attach(ownerNode: Mesh): void;
  95725. /**
  95726. * Detaches the behavior from the mesh
  95727. */
  95728. detach(): void;
  95729. }
  95730. }
  95731. declare module BABYLON {
  95732. /**
  95733. * 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
  95734. */
  95735. export class SixDofDragBehavior implements Behavior<Mesh> {
  95736. private static _virtualScene;
  95737. private _ownerNode;
  95738. private _sceneRenderObserver;
  95739. private _scene;
  95740. private _targetPosition;
  95741. private _virtualOriginMesh;
  95742. private _virtualDragMesh;
  95743. private _pointerObserver;
  95744. private _moving;
  95745. private _startingOrientation;
  95746. /**
  95747. * 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)
  95748. */
  95749. private zDragFactor;
  95750. /**
  95751. * If the object should rotate to face the drag origin
  95752. */
  95753. rotateDraggedObject: boolean;
  95754. /**
  95755. * If the behavior is currently in a dragging state
  95756. */
  95757. dragging: boolean;
  95758. /**
  95759. * 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)
  95760. */
  95761. dragDeltaRatio: number;
  95762. /**
  95763. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95764. */
  95765. currentDraggingPointerID: number;
  95766. /**
  95767. * If camera controls should be detached during the drag
  95768. */
  95769. detachCameraControls: boolean;
  95770. /**
  95771. * Fires each time a drag starts
  95772. */
  95773. onDragStartObservable: Observable<{}>;
  95774. /**
  95775. * Fires each time a drag ends (eg. mouse release after drag)
  95776. */
  95777. onDragEndObservable: Observable<{}>;
  95778. /**
  95779. * 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
  95780. */
  95781. constructor();
  95782. /**
  95783. * The name of the behavior
  95784. */
  95785. readonly name: string;
  95786. /**
  95787. * Initializes the behavior
  95788. */
  95789. init(): void;
  95790. /**
  95791. * Attaches the scale behavior the passed in mesh
  95792. * @param ownerNode The mesh that will be scaled around once attached
  95793. */
  95794. attach(ownerNode: Mesh): void;
  95795. /**
  95796. * Detaches the behavior from the mesh
  95797. */
  95798. detach(): void;
  95799. }
  95800. }
  95801. declare module BABYLON {
  95802. /**
  95803. * Class used to apply inverse kinematics to bones
  95804. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95805. */
  95806. export class BoneIKController {
  95807. private static _tmpVecs;
  95808. private static _tmpQuat;
  95809. private static _tmpMats;
  95810. /**
  95811. * Gets or sets the target mesh
  95812. */
  95813. targetMesh: AbstractMesh;
  95814. /** Gets or sets the mesh used as pole */
  95815. poleTargetMesh: AbstractMesh;
  95816. /**
  95817. * Gets or sets the bone used as pole
  95818. */
  95819. poleTargetBone: Nullable<Bone>;
  95820. /**
  95821. * Gets or sets the target position
  95822. */
  95823. targetPosition: Vector3;
  95824. /**
  95825. * Gets or sets the pole target position
  95826. */
  95827. poleTargetPosition: Vector3;
  95828. /**
  95829. * Gets or sets the pole target local offset
  95830. */
  95831. poleTargetLocalOffset: Vector3;
  95832. /**
  95833. * Gets or sets the pole angle
  95834. */
  95835. poleAngle: number;
  95836. /**
  95837. * Gets or sets the mesh associated with the controller
  95838. */
  95839. mesh: AbstractMesh;
  95840. /**
  95841. * 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)
  95842. */
  95843. slerpAmount: number;
  95844. private _bone1Quat;
  95845. private _bone1Mat;
  95846. private _bone2Ang;
  95847. private _bone1;
  95848. private _bone2;
  95849. private _bone1Length;
  95850. private _bone2Length;
  95851. private _maxAngle;
  95852. private _maxReach;
  95853. private _rightHandedSystem;
  95854. private _bendAxis;
  95855. private _slerping;
  95856. private _adjustRoll;
  95857. /**
  95858. * Gets or sets maximum allowed angle
  95859. */
  95860. maxAngle: number;
  95861. /**
  95862. * Creates a new BoneIKController
  95863. * @param mesh defines the mesh to control
  95864. * @param bone defines the bone to control
  95865. * @param options defines options to set up the controller
  95866. */
  95867. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95868. targetMesh?: AbstractMesh;
  95869. poleTargetMesh?: AbstractMesh;
  95870. poleTargetBone?: Bone;
  95871. poleTargetLocalOffset?: Vector3;
  95872. poleAngle?: number;
  95873. bendAxis?: Vector3;
  95874. maxAngle?: number;
  95875. slerpAmount?: number;
  95876. });
  95877. private _setMaxAngle;
  95878. /**
  95879. * Force the controller to update the bones
  95880. */
  95881. update(): void;
  95882. }
  95883. }
  95884. declare module BABYLON {
  95885. /**
  95886. * Class used to make a bone look toward a point in space
  95887. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95888. */
  95889. export class BoneLookController {
  95890. private static _tmpVecs;
  95891. private static _tmpQuat;
  95892. private static _tmpMats;
  95893. /**
  95894. * The target Vector3 that the bone will look at
  95895. */
  95896. target: Vector3;
  95897. /**
  95898. * The mesh that the bone is attached to
  95899. */
  95900. mesh: AbstractMesh;
  95901. /**
  95902. * The bone that will be looking to the target
  95903. */
  95904. bone: Bone;
  95905. /**
  95906. * The up axis of the coordinate system that is used when the bone is rotated
  95907. */
  95908. upAxis: Vector3;
  95909. /**
  95910. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95911. */
  95912. upAxisSpace: Space;
  95913. /**
  95914. * Used to make an adjustment to the yaw of the bone
  95915. */
  95916. adjustYaw: number;
  95917. /**
  95918. * Used to make an adjustment to the pitch of the bone
  95919. */
  95920. adjustPitch: number;
  95921. /**
  95922. * Used to make an adjustment to the roll of the bone
  95923. */
  95924. adjustRoll: number;
  95925. /**
  95926. * 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)
  95927. */
  95928. slerpAmount: number;
  95929. private _minYaw;
  95930. private _maxYaw;
  95931. private _minPitch;
  95932. private _maxPitch;
  95933. private _minYawSin;
  95934. private _minYawCos;
  95935. private _maxYawSin;
  95936. private _maxYawCos;
  95937. private _midYawConstraint;
  95938. private _minPitchTan;
  95939. private _maxPitchTan;
  95940. private _boneQuat;
  95941. private _slerping;
  95942. private _transformYawPitch;
  95943. private _transformYawPitchInv;
  95944. private _firstFrameSkipped;
  95945. private _yawRange;
  95946. private _fowardAxis;
  95947. /**
  95948. * Gets or sets the minimum yaw angle that the bone can look to
  95949. */
  95950. minYaw: number;
  95951. /**
  95952. * Gets or sets the maximum yaw angle that the bone can look to
  95953. */
  95954. maxYaw: number;
  95955. /**
  95956. * Gets or sets the minimum pitch angle that the bone can look to
  95957. */
  95958. minPitch: number;
  95959. /**
  95960. * Gets or sets the maximum pitch angle that the bone can look to
  95961. */
  95962. maxPitch: number;
  95963. /**
  95964. * Create a BoneLookController
  95965. * @param mesh the mesh that the bone belongs to
  95966. * @param bone the bone that will be looking to the target
  95967. * @param target the target Vector3 to look at
  95968. * @param options optional settings:
  95969. * * maxYaw: the maximum angle the bone will yaw to
  95970. * * minYaw: the minimum angle the bone will yaw to
  95971. * * maxPitch: the maximum angle the bone will pitch to
  95972. * * minPitch: the minimum angle the bone will yaw to
  95973. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95974. * * upAxis: the up axis of the coordinate system
  95975. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95976. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95977. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95978. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95979. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95980. * * adjustRoll: used to make an adjustment to the roll of the bone
  95981. **/
  95982. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95983. maxYaw?: number;
  95984. minYaw?: number;
  95985. maxPitch?: number;
  95986. minPitch?: number;
  95987. slerpAmount?: number;
  95988. upAxis?: Vector3;
  95989. upAxisSpace?: Space;
  95990. yawAxis?: Vector3;
  95991. pitchAxis?: Vector3;
  95992. adjustYaw?: number;
  95993. adjustPitch?: number;
  95994. adjustRoll?: number;
  95995. });
  95996. /**
  95997. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95998. */
  95999. update(): void;
  96000. private _getAngleDiff;
  96001. private _getAngleBetween;
  96002. private _isAngleBetween;
  96003. }
  96004. }
  96005. declare module BABYLON {
  96006. /**
  96007. * Manage the gamepad inputs to control an arc rotate camera.
  96008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96009. */
  96010. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96011. /**
  96012. * Defines the camera the input is attached to.
  96013. */
  96014. camera: ArcRotateCamera;
  96015. /**
  96016. * Defines the gamepad the input is gathering event from.
  96017. */
  96018. gamepad: Nullable<Gamepad>;
  96019. /**
  96020. * Defines the gamepad rotation sensiblity.
  96021. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96022. */
  96023. gamepadRotationSensibility: number;
  96024. /**
  96025. * Defines the gamepad move sensiblity.
  96026. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96027. */
  96028. gamepadMoveSensibility: number;
  96029. private _onGamepadConnectedObserver;
  96030. private _onGamepadDisconnectedObserver;
  96031. /**
  96032. * Attach the input controls to a specific dom element to get the input from.
  96033. * @param element Defines the element the controls should be listened from
  96034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96035. */
  96036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96037. /**
  96038. * Detach the current controls from the specified dom element.
  96039. * @param element Defines the element to stop listening the inputs from
  96040. */
  96041. detachControl(element: Nullable<HTMLElement>): void;
  96042. /**
  96043. * Update the current camera state depending on the inputs that have been used this frame.
  96044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96045. */
  96046. checkInputs(): void;
  96047. /**
  96048. * Gets the class name of the current intput.
  96049. * @returns the class name
  96050. */
  96051. getClassName(): string;
  96052. /**
  96053. * Get the friendly name associated with the input class.
  96054. * @returns the input friendly name
  96055. */
  96056. getSimpleName(): string;
  96057. }
  96058. }
  96059. declare module BABYLON {
  96060. interface ArcRotateCameraInputsManager {
  96061. /**
  96062. * Add orientation input support to the input manager.
  96063. * @returns the current input manager
  96064. */
  96065. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96066. }
  96067. /**
  96068. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96070. */
  96071. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96072. /**
  96073. * Defines the camera the input is attached to.
  96074. */
  96075. camera: ArcRotateCamera;
  96076. /**
  96077. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96078. */
  96079. alphaCorrection: number;
  96080. /**
  96081. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96082. */
  96083. gammaCorrection: number;
  96084. private _alpha;
  96085. private _gamma;
  96086. private _dirty;
  96087. private _deviceOrientationHandler;
  96088. /**
  96089. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96090. */
  96091. constructor();
  96092. /**
  96093. * Attach the input controls to a specific dom element to get the input from.
  96094. * @param element Defines the element the controls should be listened from
  96095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96096. */
  96097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96098. /** @hidden */
  96099. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96100. /**
  96101. * Update the current camera state depending on the inputs that have been used this frame.
  96102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96103. */
  96104. checkInputs(): void;
  96105. /**
  96106. * Detach the current controls from the specified dom element.
  96107. * @param element Defines the element to stop listening the inputs from
  96108. */
  96109. detachControl(element: Nullable<HTMLElement>): void;
  96110. /**
  96111. * Gets the class name of the current intput.
  96112. * @returns the class name
  96113. */
  96114. getClassName(): string;
  96115. /**
  96116. * Get the friendly name associated with the input class.
  96117. * @returns the input friendly name
  96118. */
  96119. getSimpleName(): string;
  96120. }
  96121. }
  96122. declare module BABYLON {
  96123. /**
  96124. * Listen to mouse events to control the camera.
  96125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96126. */
  96127. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96128. /**
  96129. * Defines the camera the input is attached to.
  96130. */
  96131. camera: FlyCamera;
  96132. /**
  96133. * Defines if touch is enabled. (Default is true.)
  96134. */
  96135. touchEnabled: boolean;
  96136. /**
  96137. * Defines the buttons associated with the input to handle camera rotation.
  96138. */
  96139. buttons: number[];
  96140. /**
  96141. * Assign buttons for Yaw control.
  96142. */
  96143. buttonsYaw: number[];
  96144. /**
  96145. * Assign buttons for Pitch control.
  96146. */
  96147. buttonsPitch: number[];
  96148. /**
  96149. * Assign buttons for Roll control.
  96150. */
  96151. buttonsRoll: number[];
  96152. /**
  96153. * Detect if any button is being pressed while mouse is moved.
  96154. * -1 = Mouse locked.
  96155. * 0 = Left button.
  96156. * 1 = Middle Button.
  96157. * 2 = Right Button.
  96158. */
  96159. activeButton: number;
  96160. /**
  96161. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96162. * Higher values reduce its sensitivity.
  96163. */
  96164. angularSensibility: number;
  96165. private _mousemoveCallback;
  96166. private _observer;
  96167. private _rollObserver;
  96168. private previousPosition;
  96169. private noPreventDefault;
  96170. private element;
  96171. /**
  96172. * Listen to mouse events to control the camera.
  96173. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96175. */
  96176. constructor(touchEnabled?: boolean);
  96177. /**
  96178. * Attach the mouse control to the HTML DOM element.
  96179. * @param element Defines the element that listens to the input events.
  96180. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96181. */
  96182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96183. /**
  96184. * Detach the current controls from the specified dom element.
  96185. * @param element Defines the element to stop listening the inputs from
  96186. */
  96187. detachControl(element: Nullable<HTMLElement>): void;
  96188. /**
  96189. * Gets the class name of the current input.
  96190. * @returns the class name.
  96191. */
  96192. getClassName(): string;
  96193. /**
  96194. * Get the friendly name associated with the input class.
  96195. * @returns the input's friendly name.
  96196. */
  96197. getSimpleName(): string;
  96198. private _pointerInput;
  96199. private _onMouseMove;
  96200. /**
  96201. * Rotate camera by mouse offset.
  96202. */
  96203. private rotateCamera;
  96204. }
  96205. }
  96206. declare module BABYLON {
  96207. /**
  96208. * Default Inputs manager for the FlyCamera.
  96209. * It groups all the default supported inputs for ease of use.
  96210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96211. */
  96212. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96213. /**
  96214. * Instantiates a new FlyCameraInputsManager.
  96215. * @param camera Defines the camera the inputs belong to.
  96216. */
  96217. constructor(camera: FlyCamera);
  96218. /**
  96219. * Add keyboard input support to the input manager.
  96220. * @returns the new FlyCameraKeyboardMoveInput().
  96221. */
  96222. addKeyboard(): FlyCameraInputsManager;
  96223. /**
  96224. * Add mouse input support to the input manager.
  96225. * @param touchEnabled Enable touch screen support.
  96226. * @returns the new FlyCameraMouseInput().
  96227. */
  96228. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96229. }
  96230. }
  96231. declare module BABYLON {
  96232. /**
  96233. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96234. * such as in a 3D Space Shooter or a Flight Simulator.
  96235. */
  96236. export class FlyCamera extends TargetCamera {
  96237. /**
  96238. * Define the collision ellipsoid of the camera.
  96239. * This is helpful for simulating a camera body, like a player's body.
  96240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96241. */
  96242. ellipsoid: Vector3;
  96243. /**
  96244. * Define an offset for the position of the ellipsoid around the camera.
  96245. * This can be helpful if the camera is attached away from the player's body center,
  96246. * such as at its head.
  96247. */
  96248. ellipsoidOffset: Vector3;
  96249. /**
  96250. * Enable or disable collisions of the camera with the rest of the scene objects.
  96251. */
  96252. checkCollisions: boolean;
  96253. /**
  96254. * Enable or disable gravity on the camera.
  96255. */
  96256. applyGravity: boolean;
  96257. /**
  96258. * Define the current direction the camera is moving to.
  96259. */
  96260. cameraDirection: Vector3;
  96261. /**
  96262. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96263. * This overrides and empties cameraRotation.
  96264. */
  96265. rotationQuaternion: Quaternion;
  96266. /**
  96267. * Track Roll to maintain the wanted Rolling when looking around.
  96268. */
  96269. _trackRoll: number;
  96270. /**
  96271. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96272. */
  96273. rollCorrect: number;
  96274. /**
  96275. * Mimic a banked turn, Rolling the camera when Yawing.
  96276. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96277. */
  96278. bankedTurn: boolean;
  96279. /**
  96280. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96281. */
  96282. bankedTurnLimit: number;
  96283. /**
  96284. * Value of 0 disables the banked Roll.
  96285. * Value of 1 is equal to the Yaw angle in radians.
  96286. */
  96287. bankedTurnMultiplier: number;
  96288. /**
  96289. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96290. */
  96291. inputs: FlyCameraInputsManager;
  96292. /**
  96293. * Gets the input sensibility for mouse input.
  96294. * Higher values reduce sensitivity.
  96295. */
  96296. /**
  96297. * Sets the input sensibility for a mouse input.
  96298. * Higher values reduce sensitivity.
  96299. */
  96300. angularSensibility: number;
  96301. /**
  96302. * Get the keys for camera movement forward.
  96303. */
  96304. /**
  96305. * Set the keys for camera movement forward.
  96306. */
  96307. keysForward: number[];
  96308. /**
  96309. * Get the keys for camera movement backward.
  96310. */
  96311. keysBackward: number[];
  96312. /**
  96313. * Get the keys for camera movement up.
  96314. */
  96315. /**
  96316. * Set the keys for camera movement up.
  96317. */
  96318. keysUp: number[];
  96319. /**
  96320. * Get the keys for camera movement down.
  96321. */
  96322. /**
  96323. * Set the keys for camera movement down.
  96324. */
  96325. keysDown: number[];
  96326. /**
  96327. * Get the keys for camera movement left.
  96328. */
  96329. /**
  96330. * Set the keys for camera movement left.
  96331. */
  96332. keysLeft: number[];
  96333. /**
  96334. * Set the keys for camera movement right.
  96335. */
  96336. /**
  96337. * Set the keys for camera movement right.
  96338. */
  96339. keysRight: number[];
  96340. /**
  96341. * Event raised when the camera collides with a mesh in the scene.
  96342. */
  96343. onCollide: (collidedMesh: AbstractMesh) => void;
  96344. private _collider;
  96345. private _needMoveForGravity;
  96346. private _oldPosition;
  96347. private _diffPosition;
  96348. private _newPosition;
  96349. /** @hidden */
  96350. _localDirection: Vector3;
  96351. /** @hidden */
  96352. _transformedDirection: Vector3;
  96353. /**
  96354. * Instantiates a FlyCamera.
  96355. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96356. * such as in a 3D Space Shooter or a Flight Simulator.
  96357. * @param name Define the name of the camera in the scene.
  96358. * @param position Define the starting position of the camera in the scene.
  96359. * @param scene Define the scene the camera belongs to.
  96360. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96361. */
  96362. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96363. /**
  96364. * Attach a control to the HTML DOM element.
  96365. * @param element Defines the element that listens to the input events.
  96366. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96367. */
  96368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96369. /**
  96370. * Detach a control from the HTML DOM element.
  96371. * The camera will stop reacting to that input.
  96372. * @param element Defines the element that listens to the input events.
  96373. */
  96374. detachControl(element: HTMLElement): void;
  96375. private _collisionMask;
  96376. /**
  96377. * Get the mask that the camera ignores in collision events.
  96378. */
  96379. /**
  96380. * Set the mask that the camera ignores in collision events.
  96381. */
  96382. collisionMask: number;
  96383. /** @hidden */
  96384. _collideWithWorld(displacement: Vector3): void;
  96385. /** @hidden */
  96386. private _onCollisionPositionChange;
  96387. /** @hidden */
  96388. _checkInputs(): void;
  96389. /** @hidden */
  96390. _decideIfNeedsToMove(): boolean;
  96391. /** @hidden */
  96392. _updatePosition(): void;
  96393. /**
  96394. * Restore the Roll to its target value at the rate specified.
  96395. * @param rate - Higher means slower restoring.
  96396. * @hidden
  96397. */
  96398. restoreRoll(rate: number): void;
  96399. /**
  96400. * Destroy the camera and release the current resources held by it.
  96401. */
  96402. dispose(): void;
  96403. /**
  96404. * Get the current object class name.
  96405. * @returns the class name.
  96406. */
  96407. getClassName(): string;
  96408. }
  96409. }
  96410. declare module BABYLON {
  96411. /**
  96412. * Listen to keyboard events to control the camera.
  96413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96414. */
  96415. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96416. /**
  96417. * Defines the camera the input is attached to.
  96418. */
  96419. camera: FlyCamera;
  96420. /**
  96421. * The list of keyboard keys used to control the forward move of the camera.
  96422. */
  96423. keysForward: number[];
  96424. /**
  96425. * The list of keyboard keys used to control the backward move of the camera.
  96426. */
  96427. keysBackward: number[];
  96428. /**
  96429. * The list of keyboard keys used to control the forward move of the camera.
  96430. */
  96431. keysUp: number[];
  96432. /**
  96433. * The list of keyboard keys used to control the backward move of the camera.
  96434. */
  96435. keysDown: number[];
  96436. /**
  96437. * The list of keyboard keys used to control the right strafe move of the camera.
  96438. */
  96439. keysRight: number[];
  96440. /**
  96441. * The list of keyboard keys used to control the left strafe move of the camera.
  96442. */
  96443. keysLeft: number[];
  96444. private _keys;
  96445. private _onCanvasBlurObserver;
  96446. private _onKeyboardObserver;
  96447. private _engine;
  96448. private _scene;
  96449. /**
  96450. * Attach the input controls to a specific dom element to get the input from.
  96451. * @param element Defines the element the controls should be listened from
  96452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96453. */
  96454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96455. /**
  96456. * Detach the current controls from the specified dom element.
  96457. * @param element Defines the element to stop listening the inputs from
  96458. */
  96459. detachControl(element: Nullable<HTMLElement>): void;
  96460. /**
  96461. * Gets the class name of the current intput.
  96462. * @returns the class name
  96463. */
  96464. getClassName(): string;
  96465. /** @hidden */
  96466. _onLostFocus(e: FocusEvent): void;
  96467. /**
  96468. * Get the friendly name associated with the input class.
  96469. * @returns the input friendly name
  96470. */
  96471. getSimpleName(): string;
  96472. /**
  96473. * Update the current camera state depending on the inputs that have been used this frame.
  96474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96475. */
  96476. checkInputs(): void;
  96477. }
  96478. }
  96479. declare module BABYLON {
  96480. /**
  96481. * Manage the mouse wheel inputs to control a follow camera.
  96482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96483. */
  96484. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96485. /**
  96486. * Defines the camera the input is attached to.
  96487. */
  96488. camera: FollowCamera;
  96489. /**
  96490. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96491. */
  96492. axisControlRadius: boolean;
  96493. /**
  96494. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96495. */
  96496. axisControlHeight: boolean;
  96497. /**
  96498. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96499. */
  96500. axisControlRotation: boolean;
  96501. /**
  96502. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96503. * relation to mouseWheel events.
  96504. */
  96505. wheelPrecision: number;
  96506. /**
  96507. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96508. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96509. */
  96510. wheelDeltaPercentage: number;
  96511. private _wheel;
  96512. private _observer;
  96513. /**
  96514. * Attach the input controls to a specific dom element to get the input from.
  96515. * @param element Defines the element the controls should be listened from
  96516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96517. */
  96518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96519. /**
  96520. * Detach the current controls from the specified dom element.
  96521. * @param element Defines the element to stop listening the inputs from
  96522. */
  96523. detachControl(element: Nullable<HTMLElement>): void;
  96524. /**
  96525. * Gets the class name of the current intput.
  96526. * @returns the class name
  96527. */
  96528. getClassName(): string;
  96529. /**
  96530. * Get the friendly name associated with the input class.
  96531. * @returns the input friendly name
  96532. */
  96533. getSimpleName(): string;
  96534. }
  96535. }
  96536. declare module BABYLON {
  96537. /**
  96538. * Manage the pointers inputs to control an follow camera.
  96539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96540. */
  96541. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96542. /**
  96543. * Defines the camera the input is attached to.
  96544. */
  96545. camera: FollowCamera;
  96546. /**
  96547. * Gets the class name of the current input.
  96548. * @returns the class name
  96549. */
  96550. getClassName(): string;
  96551. /**
  96552. * Defines the pointer angular sensibility along the X axis or how fast is
  96553. * the camera rotating.
  96554. * A negative number will reverse the axis direction.
  96555. */
  96556. angularSensibilityX: number;
  96557. /**
  96558. * Defines the pointer angular sensibility along the Y axis or how fast is
  96559. * the camera rotating.
  96560. * A negative number will reverse the axis direction.
  96561. */
  96562. angularSensibilityY: number;
  96563. /**
  96564. * Defines the pointer pinch precision or how fast is the camera zooming.
  96565. * A negative number will reverse the axis direction.
  96566. */
  96567. pinchPrecision: number;
  96568. /**
  96569. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96570. * from 0.
  96571. * It defines the percentage of current camera.radius to use as delta when
  96572. * pinch zoom is used.
  96573. */
  96574. pinchDeltaPercentage: number;
  96575. /**
  96576. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96577. */
  96578. axisXControlRadius: boolean;
  96579. /**
  96580. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96581. */
  96582. axisXControlHeight: boolean;
  96583. /**
  96584. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96585. */
  96586. axisXControlRotation: boolean;
  96587. /**
  96588. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96589. */
  96590. axisYControlRadius: boolean;
  96591. /**
  96592. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96593. */
  96594. axisYControlHeight: boolean;
  96595. /**
  96596. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96597. */
  96598. axisYControlRotation: boolean;
  96599. /**
  96600. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96601. */
  96602. axisPinchControlRadius: boolean;
  96603. /**
  96604. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96605. */
  96606. axisPinchControlHeight: boolean;
  96607. /**
  96608. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96609. */
  96610. axisPinchControlRotation: boolean;
  96611. /**
  96612. * Log error messages if basic misconfiguration has occurred.
  96613. */
  96614. warningEnable: boolean;
  96615. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96616. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96617. private _warningCounter;
  96618. private _warning;
  96619. }
  96620. }
  96621. declare module BABYLON {
  96622. /**
  96623. * Default Inputs manager for the FollowCamera.
  96624. * It groups all the default supported inputs for ease of use.
  96625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96626. */
  96627. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96628. /**
  96629. * Instantiates a new FollowCameraInputsManager.
  96630. * @param camera Defines the camera the inputs belong to
  96631. */
  96632. constructor(camera: FollowCamera);
  96633. /**
  96634. * Add keyboard input support to the input manager.
  96635. * @returns the current input manager
  96636. */
  96637. addKeyboard(): FollowCameraInputsManager;
  96638. /**
  96639. * Add mouse wheel input support to the input manager.
  96640. * @returns the current input manager
  96641. */
  96642. addMouseWheel(): FollowCameraInputsManager;
  96643. /**
  96644. * Add pointers input support to the input manager.
  96645. * @returns the current input manager
  96646. */
  96647. addPointers(): FollowCameraInputsManager;
  96648. /**
  96649. * Add orientation input support to the input manager.
  96650. * @returns the current input manager
  96651. */
  96652. addVRDeviceOrientation(): FollowCameraInputsManager;
  96653. }
  96654. }
  96655. declare module BABYLON {
  96656. /**
  96657. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96658. * an arc rotate version arcFollowCamera are available.
  96659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96660. */
  96661. export class FollowCamera extends TargetCamera {
  96662. /**
  96663. * Distance the follow camera should follow an object at
  96664. */
  96665. radius: number;
  96666. /**
  96667. * Minimum allowed distance of the camera to the axis of rotation
  96668. * (The camera can not get closer).
  96669. * This can help limiting how the Camera is able to move in the scene.
  96670. */
  96671. lowerRadiusLimit: Nullable<number>;
  96672. /**
  96673. * Maximum allowed distance of the camera to the axis of rotation
  96674. * (The camera can not get further).
  96675. * This can help limiting how the Camera is able to move in the scene.
  96676. */
  96677. upperRadiusLimit: Nullable<number>;
  96678. /**
  96679. * Define a rotation offset between the camera and the object it follows
  96680. */
  96681. rotationOffset: number;
  96682. /**
  96683. * Minimum allowed angle to camera position relative to target object.
  96684. * This can help limiting how the Camera is able to move in the scene.
  96685. */
  96686. lowerRotationOffsetLimit: Nullable<number>;
  96687. /**
  96688. * Maximum allowed angle to camera position relative to target object.
  96689. * This can help limiting how the Camera is able to move in the scene.
  96690. */
  96691. upperRotationOffsetLimit: Nullable<number>;
  96692. /**
  96693. * Define a height offset between the camera and the object it follows.
  96694. * It can help following an object from the top (like a car chaing a plane)
  96695. */
  96696. heightOffset: number;
  96697. /**
  96698. * Minimum allowed height of camera position relative to target object.
  96699. * This can help limiting how the Camera is able to move in the scene.
  96700. */
  96701. lowerHeightOffsetLimit: Nullable<number>;
  96702. /**
  96703. * Maximum allowed height of camera position relative to target object.
  96704. * This can help limiting how the Camera is able to move in the scene.
  96705. */
  96706. upperHeightOffsetLimit: Nullable<number>;
  96707. /**
  96708. * Define how fast the camera can accelerate to follow it s target.
  96709. */
  96710. cameraAcceleration: number;
  96711. /**
  96712. * Define the speed limit of the camera following an object.
  96713. */
  96714. maxCameraSpeed: number;
  96715. /**
  96716. * Define the target of the camera.
  96717. */
  96718. lockedTarget: Nullable<AbstractMesh>;
  96719. /**
  96720. * Defines the input associated with the camera.
  96721. */
  96722. inputs: FollowCameraInputsManager;
  96723. /**
  96724. * Instantiates the follow camera.
  96725. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96726. * @param name Define the name of the camera in the scene
  96727. * @param position Define the position of the camera
  96728. * @param scene Define the scene the camera belong to
  96729. * @param lockedTarget Define the target of the camera
  96730. */
  96731. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96732. private _follow;
  96733. /**
  96734. * Attached controls to the current camera.
  96735. * @param element Defines the element the controls should be listened from
  96736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96737. */
  96738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96739. /**
  96740. * Detach the current controls from the camera.
  96741. * The camera will stop reacting to inputs.
  96742. * @param element Defines the element to stop listening the inputs from
  96743. */
  96744. detachControl(element: HTMLElement): void;
  96745. /** @hidden */
  96746. _checkInputs(): void;
  96747. private _checkLimits;
  96748. /**
  96749. * Gets the camera class name.
  96750. * @returns the class name
  96751. */
  96752. getClassName(): string;
  96753. }
  96754. /**
  96755. * Arc Rotate version of the follow camera.
  96756. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96757. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96758. */
  96759. export class ArcFollowCamera extends TargetCamera {
  96760. /** The longitudinal angle of the camera */
  96761. alpha: number;
  96762. /** The latitudinal angle of the camera */
  96763. beta: number;
  96764. /** The radius of the camera from its target */
  96765. radius: number;
  96766. /** Define the camera target (the messh it should follow) */
  96767. target: Nullable<AbstractMesh>;
  96768. private _cartesianCoordinates;
  96769. /**
  96770. * Instantiates a new ArcFollowCamera
  96771. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96772. * @param name Define the name of the camera
  96773. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96774. * @param beta Define the rotation angle of the camera around the elevation axis
  96775. * @param radius Define the radius of the camera from its target point
  96776. * @param target Define the target of the camera
  96777. * @param scene Define the scene the camera belongs to
  96778. */
  96779. constructor(name: string,
  96780. /** The longitudinal angle of the camera */
  96781. alpha: number,
  96782. /** The latitudinal angle of the camera */
  96783. beta: number,
  96784. /** The radius of the camera from its target */
  96785. radius: number,
  96786. /** Define the camera target (the messh it should follow) */
  96787. target: Nullable<AbstractMesh>, scene: Scene);
  96788. private _follow;
  96789. /** @hidden */
  96790. _checkInputs(): void;
  96791. /**
  96792. * Returns the class name of the object.
  96793. * It is mostly used internally for serialization purposes.
  96794. */
  96795. getClassName(): string;
  96796. }
  96797. }
  96798. declare module BABYLON {
  96799. /**
  96800. * Manage the keyboard inputs to control the movement of a follow camera.
  96801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96802. */
  96803. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96804. /**
  96805. * Defines the camera the input is attached to.
  96806. */
  96807. camera: FollowCamera;
  96808. /**
  96809. * Defines the list of key codes associated with the up action (increase heightOffset)
  96810. */
  96811. keysHeightOffsetIncr: number[];
  96812. /**
  96813. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96814. */
  96815. keysHeightOffsetDecr: number[];
  96816. /**
  96817. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96818. */
  96819. keysHeightOffsetModifierAlt: boolean;
  96820. /**
  96821. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96822. */
  96823. keysHeightOffsetModifierCtrl: boolean;
  96824. /**
  96825. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96826. */
  96827. keysHeightOffsetModifierShift: boolean;
  96828. /**
  96829. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96830. */
  96831. keysRotationOffsetIncr: number[];
  96832. /**
  96833. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96834. */
  96835. keysRotationOffsetDecr: number[];
  96836. /**
  96837. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96838. */
  96839. keysRotationOffsetModifierAlt: boolean;
  96840. /**
  96841. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96842. */
  96843. keysRotationOffsetModifierCtrl: boolean;
  96844. /**
  96845. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96846. */
  96847. keysRotationOffsetModifierShift: boolean;
  96848. /**
  96849. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96850. */
  96851. keysRadiusIncr: number[];
  96852. /**
  96853. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96854. */
  96855. keysRadiusDecr: number[];
  96856. /**
  96857. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96858. */
  96859. keysRadiusModifierAlt: boolean;
  96860. /**
  96861. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96862. */
  96863. keysRadiusModifierCtrl: boolean;
  96864. /**
  96865. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96866. */
  96867. keysRadiusModifierShift: boolean;
  96868. /**
  96869. * Defines the rate of change of heightOffset.
  96870. */
  96871. heightSensibility: number;
  96872. /**
  96873. * Defines the rate of change of rotationOffset.
  96874. */
  96875. rotationSensibility: number;
  96876. /**
  96877. * Defines the rate of change of radius.
  96878. */
  96879. radiusSensibility: number;
  96880. private _keys;
  96881. private _ctrlPressed;
  96882. private _altPressed;
  96883. private _shiftPressed;
  96884. private _onCanvasBlurObserver;
  96885. private _onKeyboardObserver;
  96886. private _engine;
  96887. private _scene;
  96888. /**
  96889. * Attach the input controls to a specific dom element to get the input from.
  96890. * @param element Defines the element the controls should be listened from
  96891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96892. */
  96893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96894. /**
  96895. * Detach the current controls from the specified dom element.
  96896. * @param element Defines the element to stop listening the inputs from
  96897. */
  96898. detachControl(element: Nullable<HTMLElement>): void;
  96899. /**
  96900. * Update the current camera state depending on the inputs that have been used this frame.
  96901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96902. */
  96903. checkInputs(): void;
  96904. /**
  96905. * Gets the class name of the current input.
  96906. * @returns the class name
  96907. */
  96908. getClassName(): string;
  96909. /**
  96910. * Get the friendly name associated with the input class.
  96911. * @returns the input friendly name
  96912. */
  96913. getSimpleName(): string;
  96914. /**
  96915. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96916. * allow modification of the heightOffset value.
  96917. */
  96918. private _modifierHeightOffset;
  96919. /**
  96920. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96921. * allow modification of the rotationOffset value.
  96922. */
  96923. private _modifierRotationOffset;
  96924. /**
  96925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96926. * allow modification of the radius value.
  96927. */
  96928. private _modifierRadius;
  96929. }
  96930. }
  96931. declare module BABYLON {
  96932. interface FreeCameraInputsManager {
  96933. /**
  96934. * @hidden
  96935. */
  96936. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96937. /**
  96938. * Add orientation input support to the input manager.
  96939. * @returns the current input manager
  96940. */
  96941. addDeviceOrientation(): FreeCameraInputsManager;
  96942. }
  96943. /**
  96944. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96945. * Screen rotation is taken into account.
  96946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96947. */
  96948. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96949. private _camera;
  96950. private _screenOrientationAngle;
  96951. private _constantTranform;
  96952. private _screenQuaternion;
  96953. private _alpha;
  96954. private _beta;
  96955. private _gamma;
  96956. /**
  96957. * @hidden
  96958. */
  96959. _onDeviceOrientationChangedObservable: Observable<void>;
  96960. /**
  96961. * Instantiates a new input
  96962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96963. */
  96964. constructor();
  96965. /**
  96966. * Define the camera controlled by the input.
  96967. */
  96968. camera: FreeCamera;
  96969. /**
  96970. * Attach the input controls to a specific dom element to get the input from.
  96971. * @param element Defines the element the controls should be listened from
  96972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96973. */
  96974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96975. private _orientationChanged;
  96976. private _deviceOrientation;
  96977. /**
  96978. * Detach the current controls from the specified dom element.
  96979. * @param element Defines the element to stop listening the inputs from
  96980. */
  96981. detachControl(element: Nullable<HTMLElement>): void;
  96982. /**
  96983. * Update the current camera state depending on the inputs that have been used this frame.
  96984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96985. */
  96986. checkInputs(): void;
  96987. /**
  96988. * Gets the class name of the current intput.
  96989. * @returns the class name
  96990. */
  96991. getClassName(): string;
  96992. /**
  96993. * Get the friendly name associated with the input class.
  96994. * @returns the input friendly name
  96995. */
  96996. getSimpleName(): string;
  96997. }
  96998. }
  96999. declare module BABYLON {
  97000. /**
  97001. * Manage the gamepad inputs to control a free camera.
  97002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97003. */
  97004. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97005. /**
  97006. * Define the camera the input is attached to.
  97007. */
  97008. camera: FreeCamera;
  97009. /**
  97010. * Define the Gamepad controlling the input
  97011. */
  97012. gamepad: Nullable<Gamepad>;
  97013. /**
  97014. * Defines the gamepad rotation sensiblity.
  97015. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97016. */
  97017. gamepadAngularSensibility: number;
  97018. /**
  97019. * Defines the gamepad move sensiblity.
  97020. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97021. */
  97022. gamepadMoveSensibility: number;
  97023. private _onGamepadConnectedObserver;
  97024. private _onGamepadDisconnectedObserver;
  97025. private _cameraTransform;
  97026. private _deltaTransform;
  97027. private _vector3;
  97028. private _vector2;
  97029. /**
  97030. * Attach the input controls to a specific dom element to get the input from.
  97031. * @param element Defines the element the controls should be listened from
  97032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97033. */
  97034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97035. /**
  97036. * Detach the current controls from the specified dom element.
  97037. * @param element Defines the element to stop listening the inputs from
  97038. */
  97039. detachControl(element: Nullable<HTMLElement>): void;
  97040. /**
  97041. * Update the current camera state depending on the inputs that have been used this frame.
  97042. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97043. */
  97044. checkInputs(): void;
  97045. /**
  97046. * Gets the class name of the current intput.
  97047. * @returns the class name
  97048. */
  97049. getClassName(): string;
  97050. /**
  97051. * Get the friendly name associated with the input class.
  97052. * @returns the input friendly name
  97053. */
  97054. getSimpleName(): string;
  97055. }
  97056. }
  97057. declare module BABYLON {
  97058. /**
  97059. * Defines the potential axis of a Joystick
  97060. */
  97061. export enum JoystickAxis {
  97062. /** X axis */
  97063. X = 0,
  97064. /** Y axis */
  97065. Y = 1,
  97066. /** Z axis */
  97067. Z = 2
  97068. }
  97069. /**
  97070. * Class used to define virtual joystick (used in touch mode)
  97071. */
  97072. export class VirtualJoystick {
  97073. /**
  97074. * Gets or sets a boolean indicating that left and right values must be inverted
  97075. */
  97076. reverseLeftRight: boolean;
  97077. /**
  97078. * Gets or sets a boolean indicating that up and down values must be inverted
  97079. */
  97080. reverseUpDown: boolean;
  97081. /**
  97082. * Gets the offset value for the position (ie. the change of the position value)
  97083. */
  97084. deltaPosition: Vector3;
  97085. /**
  97086. * Gets a boolean indicating if the virtual joystick was pressed
  97087. */
  97088. pressed: boolean;
  97089. /**
  97090. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97091. */
  97092. static Canvas: Nullable<HTMLCanvasElement>;
  97093. private static _globalJoystickIndex;
  97094. private static vjCanvasContext;
  97095. private static vjCanvasWidth;
  97096. private static vjCanvasHeight;
  97097. private static halfWidth;
  97098. private _action;
  97099. private _axisTargetedByLeftAndRight;
  97100. private _axisTargetedByUpAndDown;
  97101. private _joystickSensibility;
  97102. private _inversedSensibility;
  97103. private _joystickPointerID;
  97104. private _joystickColor;
  97105. private _joystickPointerPos;
  97106. private _joystickPreviousPointerPos;
  97107. private _joystickPointerStartPos;
  97108. private _deltaJoystickVector;
  97109. private _leftJoystick;
  97110. private _touches;
  97111. private _onPointerDownHandlerRef;
  97112. private _onPointerMoveHandlerRef;
  97113. private _onPointerUpHandlerRef;
  97114. private _onResize;
  97115. /**
  97116. * Creates a new virtual joystick
  97117. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97118. */
  97119. constructor(leftJoystick?: boolean);
  97120. /**
  97121. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97122. * @param newJoystickSensibility defines the new sensibility
  97123. */
  97124. setJoystickSensibility(newJoystickSensibility: number): void;
  97125. private _onPointerDown;
  97126. private _onPointerMove;
  97127. private _onPointerUp;
  97128. /**
  97129. * Change the color of the virtual joystick
  97130. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97131. */
  97132. setJoystickColor(newColor: string): void;
  97133. /**
  97134. * Defines a callback to call when the joystick is touched
  97135. * @param action defines the callback
  97136. */
  97137. setActionOnTouch(action: () => any): void;
  97138. /**
  97139. * Defines which axis you'd like to control for left & right
  97140. * @param axis defines the axis to use
  97141. */
  97142. setAxisForLeftRight(axis: JoystickAxis): void;
  97143. /**
  97144. * Defines which axis you'd like to control for up & down
  97145. * @param axis defines the axis to use
  97146. */
  97147. setAxisForUpDown(axis: JoystickAxis): void;
  97148. private _drawVirtualJoystick;
  97149. /**
  97150. * Release internal HTML canvas
  97151. */
  97152. releaseCanvas(): void;
  97153. }
  97154. }
  97155. declare module BABYLON {
  97156. interface FreeCameraInputsManager {
  97157. /**
  97158. * Add virtual joystick input support to the input manager.
  97159. * @returns the current input manager
  97160. */
  97161. addVirtualJoystick(): FreeCameraInputsManager;
  97162. }
  97163. /**
  97164. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97166. */
  97167. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97168. /**
  97169. * Defines the camera the input is attached to.
  97170. */
  97171. camera: FreeCamera;
  97172. private _leftjoystick;
  97173. private _rightjoystick;
  97174. /**
  97175. * Gets the left stick of the virtual joystick.
  97176. * @returns The virtual Joystick
  97177. */
  97178. getLeftJoystick(): VirtualJoystick;
  97179. /**
  97180. * Gets the right stick of the virtual joystick.
  97181. * @returns The virtual Joystick
  97182. */
  97183. getRightJoystick(): VirtualJoystick;
  97184. /**
  97185. * Update the current camera state depending on the inputs that have been used this frame.
  97186. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97187. */
  97188. checkInputs(): void;
  97189. /**
  97190. * Attach the input controls to a specific dom element to get the input from.
  97191. * @param element Defines the element the controls should be listened from
  97192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97193. */
  97194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97195. /**
  97196. * Detach the current controls from the specified dom element.
  97197. * @param element Defines the element to stop listening the inputs from
  97198. */
  97199. detachControl(element: Nullable<HTMLElement>): void;
  97200. /**
  97201. * Gets the class name of the current intput.
  97202. * @returns the class name
  97203. */
  97204. getClassName(): string;
  97205. /**
  97206. * Get the friendly name associated with the input class.
  97207. * @returns the input friendly name
  97208. */
  97209. getSimpleName(): string;
  97210. }
  97211. }
  97212. declare module BABYLON {
  97213. /**
  97214. * This represents a FPS type of camera controlled by touch.
  97215. * This is like a universal camera minus the Gamepad controls.
  97216. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97217. */
  97218. export class TouchCamera extends FreeCamera {
  97219. /**
  97220. * Defines the touch sensibility for rotation.
  97221. * The higher the faster.
  97222. */
  97223. touchAngularSensibility: number;
  97224. /**
  97225. * Defines the touch sensibility for move.
  97226. * The higher the faster.
  97227. */
  97228. touchMoveSensibility: number;
  97229. /**
  97230. * Instantiates a new touch camera.
  97231. * This represents a FPS type of camera controlled by touch.
  97232. * This is like a universal camera minus the Gamepad controls.
  97233. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97234. * @param name Define the name of the camera in the scene
  97235. * @param position Define the start position of the camera in the scene
  97236. * @param scene Define the scene the camera belongs to
  97237. */
  97238. constructor(name: string, position: Vector3, scene: Scene);
  97239. /**
  97240. * Gets the current object class name.
  97241. * @return the class name
  97242. */
  97243. getClassName(): string;
  97244. /** @hidden */
  97245. _setupInputs(): void;
  97246. }
  97247. }
  97248. declare module BABYLON {
  97249. /**
  97250. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97251. * being tilted forward or back and left or right.
  97252. */
  97253. export class DeviceOrientationCamera extends FreeCamera {
  97254. private _initialQuaternion;
  97255. private _quaternionCache;
  97256. private _tmpDragQuaternion;
  97257. /**
  97258. * Creates a new device orientation camera
  97259. * @param name The name of the camera
  97260. * @param position The start position camera
  97261. * @param scene The scene the camera belongs to
  97262. */
  97263. constructor(name: string, position: Vector3, scene: Scene);
  97264. /**
  97265. * @hidden
  97266. * Disabled pointer input on first orientation sensor update (Default: true)
  97267. */
  97268. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97269. private _dragFactor;
  97270. /**
  97271. * Enabled turning on the y axis when the orientation sensor is active
  97272. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97273. */
  97274. enableHorizontalDragging(dragFactor?: number): void;
  97275. /**
  97276. * Gets the current instance class name ("DeviceOrientationCamera").
  97277. * This helps avoiding instanceof at run time.
  97278. * @returns the class name
  97279. */
  97280. getClassName(): string;
  97281. /**
  97282. * @hidden
  97283. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97284. */
  97285. _checkInputs(): void;
  97286. /**
  97287. * Reset the camera to its default orientation on the specified axis only.
  97288. * @param axis The axis to reset
  97289. */
  97290. resetToCurrentRotation(axis?: Axis): void;
  97291. }
  97292. }
  97293. declare module BABYLON {
  97294. /**
  97295. * 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,
  97296. * which still works and will still be found in many Playgrounds.
  97297. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97298. */
  97299. export class UniversalCamera extends TouchCamera {
  97300. /**
  97301. * Defines the gamepad rotation sensiblity.
  97302. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97303. */
  97304. gamepadAngularSensibility: number;
  97305. /**
  97306. * Defines the gamepad move sensiblity.
  97307. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97308. */
  97309. gamepadMoveSensibility: number;
  97310. /**
  97311. * 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,
  97312. * which still works and will still be found in many Playgrounds.
  97313. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97314. * @param name Define the name of the camera in the scene
  97315. * @param position Define the start position of the camera in the scene
  97316. * @param scene Define the scene the camera belongs to
  97317. */
  97318. constructor(name: string, position: Vector3, scene: Scene);
  97319. /**
  97320. * Gets the current object class name.
  97321. * @return the class name
  97322. */
  97323. getClassName(): string;
  97324. }
  97325. }
  97326. declare module BABYLON {
  97327. /**
  97328. * This represents a FPS type of camera. This is only here for back compat purpose.
  97329. * Please use the UniversalCamera instead as both are identical.
  97330. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97331. */
  97332. export class GamepadCamera extends UniversalCamera {
  97333. /**
  97334. * Instantiates a new Gamepad Camera
  97335. * This represents a FPS type of camera. This is only here for back compat purpose.
  97336. * Please use the UniversalCamera instead as both are identical.
  97337. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97338. * @param name Define the name of the camera in the scene
  97339. * @param position Define the start position of the camera in the scene
  97340. * @param scene Define the scene the camera belongs to
  97341. */
  97342. constructor(name: string, position: Vector3, scene: Scene);
  97343. /**
  97344. * Gets the current object class name.
  97345. * @return the class name
  97346. */
  97347. getClassName(): string;
  97348. }
  97349. }
  97350. declare module BABYLON {
  97351. /** @hidden */
  97352. export var passPixelShader: {
  97353. name: string;
  97354. shader: string;
  97355. };
  97356. }
  97357. declare module BABYLON {
  97358. /** @hidden */
  97359. export var passCubePixelShader: {
  97360. name: string;
  97361. shader: string;
  97362. };
  97363. }
  97364. declare module BABYLON {
  97365. /**
  97366. * PassPostProcess which produces an output the same as it's input
  97367. */
  97368. export class PassPostProcess extends PostProcess {
  97369. /**
  97370. * Creates the PassPostProcess
  97371. * @param name The name of the effect.
  97372. * @param options The required width/height ratio to downsize to before computing the render pass.
  97373. * @param camera The camera to apply the render pass to.
  97374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97375. * @param engine The engine which the post process will be applied. (default: current engine)
  97376. * @param reusable If the post process can be reused on the same frame. (default: false)
  97377. * @param textureType The type of texture to be used when performing the post processing.
  97378. * @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)
  97379. */
  97380. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97381. }
  97382. /**
  97383. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97384. */
  97385. export class PassCubePostProcess extends PostProcess {
  97386. private _face;
  97387. /**
  97388. * Gets or sets the cube face to display.
  97389. * * 0 is +X
  97390. * * 1 is -X
  97391. * * 2 is +Y
  97392. * * 3 is -Y
  97393. * * 4 is +Z
  97394. * * 5 is -Z
  97395. */
  97396. face: number;
  97397. /**
  97398. * Creates the PassCubePostProcess
  97399. * @param name The name of the effect.
  97400. * @param options The required width/height ratio to downsize to before computing the render pass.
  97401. * @param camera The camera to apply the render pass to.
  97402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97403. * @param engine The engine which the post process will be applied. (default: current engine)
  97404. * @param reusable If the post process can be reused on the same frame. (default: false)
  97405. * @param textureType The type of texture to be used when performing the post processing.
  97406. * @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)
  97407. */
  97408. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97409. }
  97410. }
  97411. declare module BABYLON {
  97412. /** @hidden */
  97413. export var anaglyphPixelShader: {
  97414. name: string;
  97415. shader: string;
  97416. };
  97417. }
  97418. declare module BABYLON {
  97419. /**
  97420. * Postprocess used to generate anaglyphic rendering
  97421. */
  97422. export class AnaglyphPostProcess extends PostProcess {
  97423. private _passedProcess;
  97424. /**
  97425. * Creates a new AnaglyphPostProcess
  97426. * @param name defines postprocess name
  97427. * @param options defines creation options or target ratio scale
  97428. * @param rigCameras defines cameras using this postprocess
  97429. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97430. * @param engine defines hosting engine
  97431. * @param reusable defines if the postprocess will be reused multiple times per frame
  97432. */
  97433. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97434. }
  97435. }
  97436. declare module BABYLON {
  97437. /**
  97438. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97440. */
  97441. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97442. /**
  97443. * Creates a new AnaglyphArcRotateCamera
  97444. * @param name defines camera name
  97445. * @param alpha defines alpha angle (in radians)
  97446. * @param beta defines beta angle (in radians)
  97447. * @param radius defines radius
  97448. * @param target defines camera target
  97449. * @param interaxialDistance defines distance between each color axis
  97450. * @param scene defines the hosting scene
  97451. */
  97452. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97453. /**
  97454. * Gets camera class name
  97455. * @returns AnaglyphArcRotateCamera
  97456. */
  97457. getClassName(): string;
  97458. }
  97459. }
  97460. declare module BABYLON {
  97461. /**
  97462. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97463. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97464. */
  97465. export class AnaglyphFreeCamera extends FreeCamera {
  97466. /**
  97467. * Creates a new AnaglyphFreeCamera
  97468. * @param name defines camera name
  97469. * @param position defines initial position
  97470. * @param interaxialDistance defines distance between each color axis
  97471. * @param scene defines the hosting scene
  97472. */
  97473. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97474. /**
  97475. * Gets camera class name
  97476. * @returns AnaglyphFreeCamera
  97477. */
  97478. getClassName(): string;
  97479. }
  97480. }
  97481. declare module BABYLON {
  97482. /**
  97483. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97484. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97485. */
  97486. export class AnaglyphGamepadCamera extends GamepadCamera {
  97487. /**
  97488. * Creates a new AnaglyphGamepadCamera
  97489. * @param name defines camera name
  97490. * @param position defines initial position
  97491. * @param interaxialDistance defines distance between each color axis
  97492. * @param scene defines the hosting scene
  97493. */
  97494. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97495. /**
  97496. * Gets camera class name
  97497. * @returns AnaglyphGamepadCamera
  97498. */
  97499. getClassName(): string;
  97500. }
  97501. }
  97502. declare module BABYLON {
  97503. /**
  97504. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97505. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97506. */
  97507. export class AnaglyphUniversalCamera extends UniversalCamera {
  97508. /**
  97509. * Creates a new AnaglyphUniversalCamera
  97510. * @param name defines camera name
  97511. * @param position defines initial position
  97512. * @param interaxialDistance defines distance between each color axis
  97513. * @param scene defines the hosting scene
  97514. */
  97515. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97516. /**
  97517. * Gets camera class name
  97518. * @returns AnaglyphUniversalCamera
  97519. */
  97520. getClassName(): string;
  97521. }
  97522. }
  97523. declare module BABYLON {
  97524. /** @hidden */
  97525. export var stereoscopicInterlacePixelShader: {
  97526. name: string;
  97527. shader: string;
  97528. };
  97529. }
  97530. declare module BABYLON {
  97531. /**
  97532. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97533. */
  97534. export class StereoscopicInterlacePostProcess extends PostProcess {
  97535. private _stepSize;
  97536. private _passedProcess;
  97537. /**
  97538. * Initializes a StereoscopicInterlacePostProcess
  97539. * @param name The name of the effect.
  97540. * @param rigCameras The rig cameras to be appled to the post process
  97541. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97543. * @param engine The engine which the post process will be applied. (default: current engine)
  97544. * @param reusable If the post process can be reused on the same frame. (default: false)
  97545. */
  97546. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97547. }
  97548. }
  97549. declare module BABYLON {
  97550. /**
  97551. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97552. * @see http://doc.babylonjs.com/features/cameras
  97553. */
  97554. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97555. /**
  97556. * Creates a new StereoscopicArcRotateCamera
  97557. * @param name defines camera name
  97558. * @param alpha defines alpha angle (in radians)
  97559. * @param beta defines beta angle (in radians)
  97560. * @param radius defines radius
  97561. * @param target defines camera target
  97562. * @param interaxialDistance defines distance between each color axis
  97563. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97564. * @param scene defines the hosting scene
  97565. */
  97566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97567. /**
  97568. * Gets camera class name
  97569. * @returns StereoscopicArcRotateCamera
  97570. */
  97571. getClassName(): string;
  97572. }
  97573. }
  97574. declare module BABYLON {
  97575. /**
  97576. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97577. * @see http://doc.babylonjs.com/features/cameras
  97578. */
  97579. export class StereoscopicFreeCamera extends FreeCamera {
  97580. /**
  97581. * Creates a new StereoscopicFreeCamera
  97582. * @param name defines camera name
  97583. * @param position defines initial position
  97584. * @param interaxialDistance defines distance between each color axis
  97585. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97586. * @param scene defines the hosting scene
  97587. */
  97588. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97589. /**
  97590. * Gets camera class name
  97591. * @returns StereoscopicFreeCamera
  97592. */
  97593. getClassName(): string;
  97594. }
  97595. }
  97596. declare module BABYLON {
  97597. /**
  97598. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97599. * @see http://doc.babylonjs.com/features/cameras
  97600. */
  97601. export class StereoscopicGamepadCamera extends GamepadCamera {
  97602. /**
  97603. * Creates a new StereoscopicGamepadCamera
  97604. * @param name defines camera name
  97605. * @param position defines initial position
  97606. * @param interaxialDistance defines distance between each color axis
  97607. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97608. * @param scene defines the hosting scene
  97609. */
  97610. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97611. /**
  97612. * Gets camera class name
  97613. * @returns StereoscopicGamepadCamera
  97614. */
  97615. getClassName(): string;
  97616. }
  97617. }
  97618. declare module BABYLON {
  97619. /**
  97620. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97621. * @see http://doc.babylonjs.com/features/cameras
  97622. */
  97623. export class StereoscopicUniversalCamera extends UniversalCamera {
  97624. /**
  97625. * Creates a new StereoscopicUniversalCamera
  97626. * @param name defines camera name
  97627. * @param position defines initial position
  97628. * @param interaxialDistance defines distance between each color axis
  97629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97630. * @param scene defines the hosting scene
  97631. */
  97632. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97633. /**
  97634. * Gets camera class name
  97635. * @returns StereoscopicUniversalCamera
  97636. */
  97637. getClassName(): string;
  97638. }
  97639. }
  97640. declare module BABYLON {
  97641. /**
  97642. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97643. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97644. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97645. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97646. */
  97647. export class VirtualJoysticksCamera extends FreeCamera {
  97648. /**
  97649. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97650. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97651. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97652. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97653. * @param name Define the name of the camera in the scene
  97654. * @param position Define the start position of the camera in the scene
  97655. * @param scene Define the scene the camera belongs to
  97656. */
  97657. constructor(name: string, position: Vector3, scene: Scene);
  97658. /**
  97659. * Gets the current object class name.
  97660. * @return the class name
  97661. */
  97662. getClassName(): string;
  97663. }
  97664. }
  97665. declare module BABYLON {
  97666. /**
  97667. * This represents all the required metrics to create a VR camera.
  97668. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97669. */
  97670. export class VRCameraMetrics {
  97671. /**
  97672. * Define the horizontal resolution off the screen.
  97673. */
  97674. hResolution: number;
  97675. /**
  97676. * Define the vertical resolution off the screen.
  97677. */
  97678. vResolution: number;
  97679. /**
  97680. * Define the horizontal screen size.
  97681. */
  97682. hScreenSize: number;
  97683. /**
  97684. * Define the vertical screen size.
  97685. */
  97686. vScreenSize: number;
  97687. /**
  97688. * Define the vertical screen center position.
  97689. */
  97690. vScreenCenter: number;
  97691. /**
  97692. * Define the distance of the eyes to the screen.
  97693. */
  97694. eyeToScreenDistance: number;
  97695. /**
  97696. * Define the distance between both lenses
  97697. */
  97698. lensSeparationDistance: number;
  97699. /**
  97700. * Define the distance between both viewer's eyes.
  97701. */
  97702. interpupillaryDistance: number;
  97703. /**
  97704. * Define the distortion factor of the VR postprocess.
  97705. * Please, touch with care.
  97706. */
  97707. distortionK: number[];
  97708. /**
  97709. * Define the chromatic aberration correction factors for the VR post process.
  97710. */
  97711. chromaAbCorrection: number[];
  97712. /**
  97713. * Define the scale factor of the post process.
  97714. * The smaller the better but the slower.
  97715. */
  97716. postProcessScaleFactor: number;
  97717. /**
  97718. * Define an offset for the lens center.
  97719. */
  97720. lensCenterOffset: number;
  97721. /**
  97722. * Define if the current vr camera should compensate the distortion of the lense or not.
  97723. */
  97724. compensateDistortion: boolean;
  97725. /**
  97726. * Defines if multiview should be enabled when rendering (Default: false)
  97727. */
  97728. multiviewEnabled: boolean;
  97729. /**
  97730. * Gets the rendering aspect ratio based on the provided resolutions.
  97731. */
  97732. readonly aspectRatio: number;
  97733. /**
  97734. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97735. */
  97736. readonly aspectRatioFov: number;
  97737. /**
  97738. * @hidden
  97739. */
  97740. readonly leftHMatrix: Matrix;
  97741. /**
  97742. * @hidden
  97743. */
  97744. readonly rightHMatrix: Matrix;
  97745. /**
  97746. * @hidden
  97747. */
  97748. readonly leftPreViewMatrix: Matrix;
  97749. /**
  97750. * @hidden
  97751. */
  97752. readonly rightPreViewMatrix: Matrix;
  97753. /**
  97754. * Get the default VRMetrics based on the most generic setup.
  97755. * @returns the default vr metrics
  97756. */
  97757. static GetDefault(): VRCameraMetrics;
  97758. }
  97759. }
  97760. declare module BABYLON {
  97761. /** @hidden */
  97762. export var vrDistortionCorrectionPixelShader: {
  97763. name: string;
  97764. shader: string;
  97765. };
  97766. }
  97767. declare module BABYLON {
  97768. /**
  97769. * VRDistortionCorrectionPostProcess used for mobile VR
  97770. */
  97771. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97772. private _isRightEye;
  97773. private _distortionFactors;
  97774. private _postProcessScaleFactor;
  97775. private _lensCenterOffset;
  97776. private _scaleIn;
  97777. private _scaleFactor;
  97778. private _lensCenter;
  97779. /**
  97780. * Initializes the VRDistortionCorrectionPostProcess
  97781. * @param name The name of the effect.
  97782. * @param camera The camera to apply the render pass to.
  97783. * @param isRightEye If this is for the right eye distortion
  97784. * @param vrMetrics All the required metrics for the VR camera
  97785. */
  97786. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97787. }
  97788. }
  97789. declare module BABYLON {
  97790. /**
  97791. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97792. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97793. */
  97794. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97795. /**
  97796. * Creates a new VRDeviceOrientationArcRotateCamera
  97797. * @param name defines camera name
  97798. * @param alpha defines the camera rotation along the logitudinal axis
  97799. * @param beta defines the camera rotation along the latitudinal axis
  97800. * @param radius defines the camera distance from its target
  97801. * @param target defines the camera target
  97802. * @param scene defines the scene the camera belongs to
  97803. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97804. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97805. */
  97806. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97807. /**
  97808. * Gets camera class name
  97809. * @returns VRDeviceOrientationArcRotateCamera
  97810. */
  97811. getClassName(): string;
  97812. }
  97813. }
  97814. declare module BABYLON {
  97815. /**
  97816. * Camera used to simulate VR rendering (based on FreeCamera)
  97817. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97818. */
  97819. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97820. /**
  97821. * Creates a new VRDeviceOrientationFreeCamera
  97822. * @param name defines camera name
  97823. * @param position defines the start position of the camera
  97824. * @param scene defines the scene the camera belongs to
  97825. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97826. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97827. */
  97828. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97829. /**
  97830. * Gets camera class name
  97831. * @returns VRDeviceOrientationFreeCamera
  97832. */
  97833. getClassName(): string;
  97834. }
  97835. }
  97836. declare module BABYLON {
  97837. /**
  97838. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97839. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97840. */
  97841. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97842. /**
  97843. * Creates a new VRDeviceOrientationGamepadCamera
  97844. * @param name defines camera name
  97845. * @param position defines the start position of the camera
  97846. * @param scene defines the scene the camera belongs to
  97847. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97848. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97849. */
  97850. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97851. /**
  97852. * Gets camera class name
  97853. * @returns VRDeviceOrientationGamepadCamera
  97854. */
  97855. getClassName(): string;
  97856. }
  97857. }
  97858. declare module BABYLON {
  97859. /**
  97860. * Defines supported buttons for XBox360 compatible gamepads
  97861. */
  97862. export enum Xbox360Button {
  97863. /** A */
  97864. A = 0,
  97865. /** B */
  97866. B = 1,
  97867. /** X */
  97868. X = 2,
  97869. /** Y */
  97870. Y = 3,
  97871. /** Start */
  97872. Start = 4,
  97873. /** Back */
  97874. Back = 5,
  97875. /** Left button */
  97876. LB = 6,
  97877. /** Right button */
  97878. RB = 7,
  97879. /** Left stick */
  97880. LeftStick = 8,
  97881. /** Right stick */
  97882. RightStick = 9
  97883. }
  97884. /** Defines values for XBox360 DPad */
  97885. export enum Xbox360Dpad {
  97886. /** Up */
  97887. Up = 0,
  97888. /** Down */
  97889. Down = 1,
  97890. /** Left */
  97891. Left = 2,
  97892. /** Right */
  97893. Right = 3
  97894. }
  97895. /**
  97896. * Defines a XBox360 gamepad
  97897. */
  97898. export class Xbox360Pad extends Gamepad {
  97899. private _leftTrigger;
  97900. private _rightTrigger;
  97901. private _onlefttriggerchanged;
  97902. private _onrighttriggerchanged;
  97903. private _onbuttondown;
  97904. private _onbuttonup;
  97905. private _ondpaddown;
  97906. private _ondpadup;
  97907. /** Observable raised when a button is pressed */
  97908. onButtonDownObservable: Observable<Xbox360Button>;
  97909. /** Observable raised when a button is released */
  97910. onButtonUpObservable: Observable<Xbox360Button>;
  97911. /** Observable raised when a pad is pressed */
  97912. onPadDownObservable: Observable<Xbox360Dpad>;
  97913. /** Observable raised when a pad is released */
  97914. onPadUpObservable: Observable<Xbox360Dpad>;
  97915. private _buttonA;
  97916. private _buttonB;
  97917. private _buttonX;
  97918. private _buttonY;
  97919. private _buttonBack;
  97920. private _buttonStart;
  97921. private _buttonLB;
  97922. private _buttonRB;
  97923. private _buttonLeftStick;
  97924. private _buttonRightStick;
  97925. private _dPadUp;
  97926. private _dPadDown;
  97927. private _dPadLeft;
  97928. private _dPadRight;
  97929. private _isXboxOnePad;
  97930. /**
  97931. * Creates a new XBox360 gamepad object
  97932. * @param id defines the id of this gamepad
  97933. * @param index defines its index
  97934. * @param gamepad defines the internal HTML gamepad object
  97935. * @param xboxOne defines if it is a XBox One gamepad
  97936. */
  97937. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97938. /**
  97939. * Defines the callback to call when left trigger is pressed
  97940. * @param callback defines the callback to use
  97941. */
  97942. onlefttriggerchanged(callback: (value: number) => void): void;
  97943. /**
  97944. * Defines the callback to call when right trigger is pressed
  97945. * @param callback defines the callback to use
  97946. */
  97947. onrighttriggerchanged(callback: (value: number) => void): void;
  97948. /**
  97949. * Gets the left trigger value
  97950. */
  97951. /**
  97952. * Sets the left trigger value
  97953. */
  97954. leftTrigger: number;
  97955. /**
  97956. * Gets the right trigger value
  97957. */
  97958. /**
  97959. * Sets the right trigger value
  97960. */
  97961. rightTrigger: number;
  97962. /**
  97963. * Defines the callback to call when a button is pressed
  97964. * @param callback defines the callback to use
  97965. */
  97966. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97967. /**
  97968. * Defines the callback to call when a button is released
  97969. * @param callback defines the callback to use
  97970. */
  97971. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97972. /**
  97973. * Defines the callback to call when a pad is pressed
  97974. * @param callback defines the callback to use
  97975. */
  97976. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97977. /**
  97978. * Defines the callback to call when a pad is released
  97979. * @param callback defines the callback to use
  97980. */
  97981. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97982. private _setButtonValue;
  97983. private _setDPadValue;
  97984. /**
  97985. * Gets the value of the `A` button
  97986. */
  97987. /**
  97988. * Sets the value of the `A` button
  97989. */
  97990. buttonA: number;
  97991. /**
  97992. * Gets the value of the `B` button
  97993. */
  97994. /**
  97995. * Sets the value of the `B` button
  97996. */
  97997. buttonB: number;
  97998. /**
  97999. * Gets the value of the `X` button
  98000. */
  98001. /**
  98002. * Sets the value of the `X` button
  98003. */
  98004. buttonX: number;
  98005. /**
  98006. * Gets the value of the `Y` button
  98007. */
  98008. /**
  98009. * Sets the value of the `Y` button
  98010. */
  98011. buttonY: number;
  98012. /**
  98013. * Gets the value of the `Start` button
  98014. */
  98015. /**
  98016. * Sets the value of the `Start` button
  98017. */
  98018. buttonStart: number;
  98019. /**
  98020. * Gets the value of the `Back` button
  98021. */
  98022. /**
  98023. * Sets the value of the `Back` button
  98024. */
  98025. buttonBack: number;
  98026. /**
  98027. * Gets the value of the `Left` button
  98028. */
  98029. /**
  98030. * Sets the value of the `Left` button
  98031. */
  98032. buttonLB: number;
  98033. /**
  98034. * Gets the value of the `Right` button
  98035. */
  98036. /**
  98037. * Sets the value of the `Right` button
  98038. */
  98039. buttonRB: number;
  98040. /**
  98041. * Gets the value of the Left joystick
  98042. */
  98043. /**
  98044. * Sets the value of the Left joystick
  98045. */
  98046. buttonLeftStick: number;
  98047. /**
  98048. * Gets the value of the Right joystick
  98049. */
  98050. /**
  98051. * Sets the value of the Right joystick
  98052. */
  98053. buttonRightStick: number;
  98054. /**
  98055. * Gets the value of D-pad up
  98056. */
  98057. /**
  98058. * Sets the value of D-pad up
  98059. */
  98060. dPadUp: number;
  98061. /**
  98062. * Gets the value of D-pad down
  98063. */
  98064. /**
  98065. * Sets the value of D-pad down
  98066. */
  98067. dPadDown: number;
  98068. /**
  98069. * Gets the value of D-pad left
  98070. */
  98071. /**
  98072. * Sets the value of D-pad left
  98073. */
  98074. dPadLeft: number;
  98075. /**
  98076. * Gets the value of D-pad right
  98077. */
  98078. /**
  98079. * Sets the value of D-pad right
  98080. */
  98081. dPadRight: number;
  98082. /**
  98083. * Force the gamepad to synchronize with device values
  98084. */
  98085. update(): void;
  98086. /**
  98087. * Disposes the gamepad
  98088. */
  98089. dispose(): void;
  98090. }
  98091. }
  98092. declare module BABYLON {
  98093. /**
  98094. * Base class of materials working in push mode in babylon JS
  98095. * @hidden
  98096. */
  98097. export class PushMaterial extends Material {
  98098. protected _activeEffect: Effect;
  98099. protected _normalMatrix: Matrix;
  98100. /**
  98101. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98102. * This means that the material can keep using a previous shader while a new one is being compiled.
  98103. * This is mostly used when shader parallel compilation is supported (true by default)
  98104. */
  98105. allowShaderHotSwapping: boolean;
  98106. constructor(name: string, scene: Scene);
  98107. getEffect(): Effect;
  98108. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98109. /**
  98110. * Binds the given world matrix to the active effect
  98111. *
  98112. * @param world the matrix to bind
  98113. */
  98114. bindOnlyWorldMatrix(world: Matrix): void;
  98115. /**
  98116. * Binds the given normal matrix to the active effect
  98117. *
  98118. * @param normalMatrix the matrix to bind
  98119. */
  98120. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98121. bind(world: Matrix, mesh?: Mesh): void;
  98122. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98123. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98124. }
  98125. }
  98126. declare module BABYLON {
  98127. /**
  98128. * This groups all the flags used to control the materials channel.
  98129. */
  98130. export class MaterialFlags {
  98131. private static _DiffuseTextureEnabled;
  98132. /**
  98133. * Are diffuse textures enabled in the application.
  98134. */
  98135. static DiffuseTextureEnabled: boolean;
  98136. private static _AmbientTextureEnabled;
  98137. /**
  98138. * Are ambient textures enabled in the application.
  98139. */
  98140. static AmbientTextureEnabled: boolean;
  98141. private static _OpacityTextureEnabled;
  98142. /**
  98143. * Are opacity textures enabled in the application.
  98144. */
  98145. static OpacityTextureEnabled: boolean;
  98146. private static _ReflectionTextureEnabled;
  98147. /**
  98148. * Are reflection textures enabled in the application.
  98149. */
  98150. static ReflectionTextureEnabled: boolean;
  98151. private static _EmissiveTextureEnabled;
  98152. /**
  98153. * Are emissive textures enabled in the application.
  98154. */
  98155. static EmissiveTextureEnabled: boolean;
  98156. private static _SpecularTextureEnabled;
  98157. /**
  98158. * Are specular textures enabled in the application.
  98159. */
  98160. static SpecularTextureEnabled: boolean;
  98161. private static _BumpTextureEnabled;
  98162. /**
  98163. * Are bump textures enabled in the application.
  98164. */
  98165. static BumpTextureEnabled: boolean;
  98166. private static _LightmapTextureEnabled;
  98167. /**
  98168. * Are lightmap textures enabled in the application.
  98169. */
  98170. static LightmapTextureEnabled: boolean;
  98171. private static _RefractionTextureEnabled;
  98172. /**
  98173. * Are refraction textures enabled in the application.
  98174. */
  98175. static RefractionTextureEnabled: boolean;
  98176. private static _ColorGradingTextureEnabled;
  98177. /**
  98178. * Are color grading textures enabled in the application.
  98179. */
  98180. static ColorGradingTextureEnabled: boolean;
  98181. private static _FresnelEnabled;
  98182. /**
  98183. * Are fresnels enabled in the application.
  98184. */
  98185. static FresnelEnabled: boolean;
  98186. private static _ClearCoatTextureEnabled;
  98187. /**
  98188. * Are clear coat textures enabled in the application.
  98189. */
  98190. static ClearCoatTextureEnabled: boolean;
  98191. private static _ClearCoatBumpTextureEnabled;
  98192. /**
  98193. * Are clear coat bump textures enabled in the application.
  98194. */
  98195. static ClearCoatBumpTextureEnabled: boolean;
  98196. private static _ClearCoatTintTextureEnabled;
  98197. /**
  98198. * Are clear coat tint textures enabled in the application.
  98199. */
  98200. static ClearCoatTintTextureEnabled: boolean;
  98201. private static _SheenTextureEnabled;
  98202. /**
  98203. * Are sheen textures enabled in the application.
  98204. */
  98205. static SheenTextureEnabled: boolean;
  98206. private static _AnisotropicTextureEnabled;
  98207. /**
  98208. * Are anisotropic textures enabled in the application.
  98209. */
  98210. static AnisotropicTextureEnabled: boolean;
  98211. private static _ThicknessTextureEnabled;
  98212. /**
  98213. * Are thickness textures enabled in the application.
  98214. */
  98215. static ThicknessTextureEnabled: boolean;
  98216. }
  98217. }
  98218. declare module BABYLON {
  98219. /** @hidden */
  98220. export var defaultFragmentDeclaration: {
  98221. name: string;
  98222. shader: string;
  98223. };
  98224. }
  98225. declare module BABYLON {
  98226. /** @hidden */
  98227. export var defaultUboDeclaration: {
  98228. name: string;
  98229. shader: string;
  98230. };
  98231. }
  98232. declare module BABYLON {
  98233. /** @hidden */
  98234. export var lightFragmentDeclaration: {
  98235. name: string;
  98236. shader: string;
  98237. };
  98238. }
  98239. declare module BABYLON {
  98240. /** @hidden */
  98241. export var lightUboDeclaration: {
  98242. name: string;
  98243. shader: string;
  98244. };
  98245. }
  98246. declare module BABYLON {
  98247. /** @hidden */
  98248. export var lightsFragmentFunctions: {
  98249. name: string;
  98250. shader: string;
  98251. };
  98252. }
  98253. declare module BABYLON {
  98254. /** @hidden */
  98255. export var shadowsFragmentFunctions: {
  98256. name: string;
  98257. shader: string;
  98258. };
  98259. }
  98260. declare module BABYLON {
  98261. /** @hidden */
  98262. export var fresnelFunction: {
  98263. name: string;
  98264. shader: string;
  98265. };
  98266. }
  98267. declare module BABYLON {
  98268. /** @hidden */
  98269. export var reflectionFunction: {
  98270. name: string;
  98271. shader: string;
  98272. };
  98273. }
  98274. declare module BABYLON {
  98275. /** @hidden */
  98276. export var bumpFragmentFunctions: {
  98277. name: string;
  98278. shader: string;
  98279. };
  98280. }
  98281. declare module BABYLON {
  98282. /** @hidden */
  98283. export var logDepthDeclaration: {
  98284. name: string;
  98285. shader: string;
  98286. };
  98287. }
  98288. declare module BABYLON {
  98289. /** @hidden */
  98290. export var bumpFragment: {
  98291. name: string;
  98292. shader: string;
  98293. };
  98294. }
  98295. declare module BABYLON {
  98296. /** @hidden */
  98297. export var depthPrePass: {
  98298. name: string;
  98299. shader: string;
  98300. };
  98301. }
  98302. declare module BABYLON {
  98303. /** @hidden */
  98304. export var lightFragment: {
  98305. name: string;
  98306. shader: string;
  98307. };
  98308. }
  98309. declare module BABYLON {
  98310. /** @hidden */
  98311. export var logDepthFragment: {
  98312. name: string;
  98313. shader: string;
  98314. };
  98315. }
  98316. declare module BABYLON {
  98317. /** @hidden */
  98318. export var defaultPixelShader: {
  98319. name: string;
  98320. shader: string;
  98321. };
  98322. }
  98323. declare module BABYLON {
  98324. /** @hidden */
  98325. export var defaultVertexDeclaration: {
  98326. name: string;
  98327. shader: string;
  98328. };
  98329. }
  98330. declare module BABYLON {
  98331. /** @hidden */
  98332. export var bumpVertexDeclaration: {
  98333. name: string;
  98334. shader: string;
  98335. };
  98336. }
  98337. declare module BABYLON {
  98338. /** @hidden */
  98339. export var bumpVertex: {
  98340. name: string;
  98341. shader: string;
  98342. };
  98343. }
  98344. declare module BABYLON {
  98345. /** @hidden */
  98346. export var fogVertex: {
  98347. name: string;
  98348. shader: string;
  98349. };
  98350. }
  98351. declare module BABYLON {
  98352. /** @hidden */
  98353. export var shadowsVertex: {
  98354. name: string;
  98355. shader: string;
  98356. };
  98357. }
  98358. declare module BABYLON {
  98359. /** @hidden */
  98360. export var pointCloudVertex: {
  98361. name: string;
  98362. shader: string;
  98363. };
  98364. }
  98365. declare module BABYLON {
  98366. /** @hidden */
  98367. export var logDepthVertex: {
  98368. name: string;
  98369. shader: string;
  98370. };
  98371. }
  98372. declare module BABYLON {
  98373. /** @hidden */
  98374. export var defaultVertexShader: {
  98375. name: string;
  98376. shader: string;
  98377. };
  98378. }
  98379. declare module BABYLON {
  98380. /** @hidden */
  98381. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98382. MAINUV1: boolean;
  98383. MAINUV2: boolean;
  98384. DIFFUSE: boolean;
  98385. DIFFUSEDIRECTUV: number;
  98386. AMBIENT: boolean;
  98387. AMBIENTDIRECTUV: number;
  98388. OPACITY: boolean;
  98389. OPACITYDIRECTUV: number;
  98390. OPACITYRGB: boolean;
  98391. REFLECTION: boolean;
  98392. EMISSIVE: boolean;
  98393. EMISSIVEDIRECTUV: number;
  98394. SPECULAR: boolean;
  98395. SPECULARDIRECTUV: number;
  98396. BUMP: boolean;
  98397. BUMPDIRECTUV: number;
  98398. PARALLAX: boolean;
  98399. PARALLAXOCCLUSION: boolean;
  98400. SPECULAROVERALPHA: boolean;
  98401. CLIPPLANE: boolean;
  98402. CLIPPLANE2: boolean;
  98403. CLIPPLANE3: boolean;
  98404. CLIPPLANE4: boolean;
  98405. ALPHATEST: boolean;
  98406. DEPTHPREPASS: boolean;
  98407. ALPHAFROMDIFFUSE: boolean;
  98408. POINTSIZE: boolean;
  98409. FOG: boolean;
  98410. SPECULARTERM: boolean;
  98411. DIFFUSEFRESNEL: boolean;
  98412. OPACITYFRESNEL: boolean;
  98413. REFLECTIONFRESNEL: boolean;
  98414. REFRACTIONFRESNEL: boolean;
  98415. EMISSIVEFRESNEL: boolean;
  98416. FRESNEL: boolean;
  98417. NORMAL: boolean;
  98418. UV1: boolean;
  98419. UV2: boolean;
  98420. VERTEXCOLOR: boolean;
  98421. VERTEXALPHA: boolean;
  98422. NUM_BONE_INFLUENCERS: number;
  98423. BonesPerMesh: number;
  98424. BONETEXTURE: boolean;
  98425. INSTANCES: boolean;
  98426. GLOSSINESS: boolean;
  98427. ROUGHNESS: boolean;
  98428. EMISSIVEASILLUMINATION: boolean;
  98429. LINKEMISSIVEWITHDIFFUSE: boolean;
  98430. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98431. LIGHTMAP: boolean;
  98432. LIGHTMAPDIRECTUV: number;
  98433. OBJECTSPACE_NORMALMAP: boolean;
  98434. USELIGHTMAPASSHADOWMAP: boolean;
  98435. REFLECTIONMAP_3D: boolean;
  98436. REFLECTIONMAP_SPHERICAL: boolean;
  98437. REFLECTIONMAP_PLANAR: boolean;
  98438. REFLECTIONMAP_CUBIC: boolean;
  98439. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98440. REFLECTIONMAP_PROJECTION: boolean;
  98441. REFLECTIONMAP_SKYBOX: boolean;
  98442. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98443. REFLECTIONMAP_EXPLICIT: boolean;
  98444. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98445. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98446. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98447. INVERTCUBICMAP: boolean;
  98448. LOGARITHMICDEPTH: boolean;
  98449. REFRACTION: boolean;
  98450. REFRACTIONMAP_3D: boolean;
  98451. REFLECTIONOVERALPHA: boolean;
  98452. TWOSIDEDLIGHTING: boolean;
  98453. SHADOWFLOAT: boolean;
  98454. MORPHTARGETS: boolean;
  98455. MORPHTARGETS_NORMAL: boolean;
  98456. MORPHTARGETS_TANGENT: boolean;
  98457. NUM_MORPH_INFLUENCERS: number;
  98458. NONUNIFORMSCALING: boolean;
  98459. PREMULTIPLYALPHA: boolean;
  98460. IMAGEPROCESSING: boolean;
  98461. VIGNETTE: boolean;
  98462. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98463. VIGNETTEBLENDMODEOPAQUE: boolean;
  98464. TONEMAPPING: boolean;
  98465. TONEMAPPING_ACES: boolean;
  98466. CONTRAST: boolean;
  98467. COLORCURVES: boolean;
  98468. COLORGRADING: boolean;
  98469. COLORGRADING3D: boolean;
  98470. SAMPLER3DGREENDEPTH: boolean;
  98471. SAMPLER3DBGRMAP: boolean;
  98472. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98473. MULTIVIEW: boolean;
  98474. /**
  98475. * If the reflection texture on this material is in linear color space
  98476. * @hidden
  98477. */
  98478. IS_REFLECTION_LINEAR: boolean;
  98479. /**
  98480. * If the refraction texture on this material is in linear color space
  98481. * @hidden
  98482. */
  98483. IS_REFRACTION_LINEAR: boolean;
  98484. EXPOSURE: boolean;
  98485. constructor();
  98486. setReflectionMode(modeToEnable: string): void;
  98487. }
  98488. /**
  98489. * This is the default material used in Babylon. It is the best trade off between quality
  98490. * and performances.
  98491. * @see http://doc.babylonjs.com/babylon101/materials
  98492. */
  98493. export class StandardMaterial extends PushMaterial {
  98494. private _diffuseTexture;
  98495. /**
  98496. * The basic texture of the material as viewed under a light.
  98497. */
  98498. diffuseTexture: Nullable<BaseTexture>;
  98499. private _ambientTexture;
  98500. /**
  98501. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98502. */
  98503. ambientTexture: Nullable<BaseTexture>;
  98504. private _opacityTexture;
  98505. /**
  98506. * Define the transparency of the material from a texture.
  98507. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98508. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98509. */
  98510. opacityTexture: Nullable<BaseTexture>;
  98511. private _reflectionTexture;
  98512. /**
  98513. * Define the texture used to display the reflection.
  98514. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98515. */
  98516. reflectionTexture: Nullable<BaseTexture>;
  98517. private _emissiveTexture;
  98518. /**
  98519. * Define texture of the material as if self lit.
  98520. * This will be mixed in the final result even in the absence of light.
  98521. */
  98522. emissiveTexture: Nullable<BaseTexture>;
  98523. private _specularTexture;
  98524. /**
  98525. * Define how the color and intensity of the highlight given by the light in the material.
  98526. */
  98527. specularTexture: Nullable<BaseTexture>;
  98528. private _bumpTexture;
  98529. /**
  98530. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98531. * 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.
  98532. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98533. */
  98534. bumpTexture: Nullable<BaseTexture>;
  98535. private _lightmapTexture;
  98536. /**
  98537. * Complex lighting can be computationally expensive to compute at runtime.
  98538. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98539. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98540. */
  98541. lightmapTexture: Nullable<BaseTexture>;
  98542. private _refractionTexture;
  98543. /**
  98544. * Define the texture used to display the refraction.
  98545. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98546. */
  98547. refractionTexture: Nullable<BaseTexture>;
  98548. /**
  98549. * The color of the material lit by the environmental background lighting.
  98550. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98551. */
  98552. ambientColor: Color3;
  98553. /**
  98554. * The basic color of the material as viewed under a light.
  98555. */
  98556. diffuseColor: Color3;
  98557. /**
  98558. * Define how the color and intensity of the highlight given by the light in the material.
  98559. */
  98560. specularColor: Color3;
  98561. /**
  98562. * Define the color of the material as if self lit.
  98563. * This will be mixed in the final result even in the absence of light.
  98564. */
  98565. emissiveColor: Color3;
  98566. /**
  98567. * Defines how sharp are the highlights in the material.
  98568. * The bigger the value the sharper giving a more glossy feeling to the result.
  98569. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98570. */
  98571. specularPower: number;
  98572. private _useAlphaFromDiffuseTexture;
  98573. /**
  98574. * Does the transparency come from the diffuse texture alpha channel.
  98575. */
  98576. useAlphaFromDiffuseTexture: boolean;
  98577. private _useEmissiveAsIllumination;
  98578. /**
  98579. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98580. */
  98581. useEmissiveAsIllumination: boolean;
  98582. private _linkEmissiveWithDiffuse;
  98583. /**
  98584. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98585. * the emissive level when the final color is close to one.
  98586. */
  98587. linkEmissiveWithDiffuse: boolean;
  98588. private _useSpecularOverAlpha;
  98589. /**
  98590. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98591. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98592. */
  98593. useSpecularOverAlpha: boolean;
  98594. private _useReflectionOverAlpha;
  98595. /**
  98596. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98597. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98598. */
  98599. useReflectionOverAlpha: boolean;
  98600. private _disableLighting;
  98601. /**
  98602. * Does lights from the scene impacts this material.
  98603. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98604. */
  98605. disableLighting: boolean;
  98606. private _useObjectSpaceNormalMap;
  98607. /**
  98608. * Allows using an object space normal map (instead of tangent space).
  98609. */
  98610. useObjectSpaceNormalMap: boolean;
  98611. private _useParallax;
  98612. /**
  98613. * Is parallax enabled or not.
  98614. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98615. */
  98616. useParallax: boolean;
  98617. private _useParallaxOcclusion;
  98618. /**
  98619. * Is parallax occlusion enabled or not.
  98620. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98621. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98622. */
  98623. useParallaxOcclusion: boolean;
  98624. /**
  98625. * 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.
  98626. */
  98627. parallaxScaleBias: number;
  98628. private _roughness;
  98629. /**
  98630. * Helps to define how blurry the reflections should appears in the material.
  98631. */
  98632. roughness: number;
  98633. /**
  98634. * In case of refraction, define the value of the indice of refraction.
  98635. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98636. */
  98637. indexOfRefraction: number;
  98638. /**
  98639. * Invert the refraction texture alongside the y axis.
  98640. * It can be useful with procedural textures or probe for instance.
  98641. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98642. */
  98643. invertRefractionY: boolean;
  98644. /**
  98645. * Defines the alpha limits in alpha test mode.
  98646. */
  98647. alphaCutOff: number;
  98648. private _useLightmapAsShadowmap;
  98649. /**
  98650. * In case of light mapping, define whether the map contains light or shadow informations.
  98651. */
  98652. useLightmapAsShadowmap: boolean;
  98653. private _diffuseFresnelParameters;
  98654. /**
  98655. * Define the diffuse fresnel parameters of the material.
  98656. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98657. */
  98658. diffuseFresnelParameters: FresnelParameters;
  98659. private _opacityFresnelParameters;
  98660. /**
  98661. * Define the opacity fresnel parameters of the material.
  98662. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98663. */
  98664. opacityFresnelParameters: FresnelParameters;
  98665. private _reflectionFresnelParameters;
  98666. /**
  98667. * Define the reflection fresnel parameters of the material.
  98668. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98669. */
  98670. reflectionFresnelParameters: FresnelParameters;
  98671. private _refractionFresnelParameters;
  98672. /**
  98673. * Define the refraction fresnel parameters of the material.
  98674. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98675. */
  98676. refractionFresnelParameters: FresnelParameters;
  98677. private _emissiveFresnelParameters;
  98678. /**
  98679. * Define the emissive fresnel parameters of the material.
  98680. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98681. */
  98682. emissiveFresnelParameters: FresnelParameters;
  98683. private _useReflectionFresnelFromSpecular;
  98684. /**
  98685. * If true automatically deducts the fresnels values from the material specularity.
  98686. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98687. */
  98688. useReflectionFresnelFromSpecular: boolean;
  98689. private _useGlossinessFromSpecularMapAlpha;
  98690. /**
  98691. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98692. */
  98693. useGlossinessFromSpecularMapAlpha: boolean;
  98694. private _maxSimultaneousLights;
  98695. /**
  98696. * Defines the maximum number of lights that can be used in the material
  98697. */
  98698. maxSimultaneousLights: number;
  98699. private _invertNormalMapX;
  98700. /**
  98701. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98702. */
  98703. invertNormalMapX: boolean;
  98704. private _invertNormalMapY;
  98705. /**
  98706. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98707. */
  98708. invertNormalMapY: boolean;
  98709. private _twoSidedLighting;
  98710. /**
  98711. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98712. */
  98713. twoSidedLighting: boolean;
  98714. /**
  98715. * Default configuration related to image processing available in the standard Material.
  98716. */
  98717. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98718. /**
  98719. * Gets the image processing configuration used either in this material.
  98720. */
  98721. /**
  98722. * Sets the Default image processing configuration used either in the this material.
  98723. *
  98724. * If sets to null, the scene one is in use.
  98725. */
  98726. imageProcessingConfiguration: ImageProcessingConfiguration;
  98727. /**
  98728. * Keep track of the image processing observer to allow dispose and replace.
  98729. */
  98730. private _imageProcessingObserver;
  98731. /**
  98732. * Attaches a new image processing configuration to the Standard Material.
  98733. * @param configuration
  98734. */
  98735. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98736. /**
  98737. * Gets wether the color curves effect is enabled.
  98738. */
  98739. /**
  98740. * Sets wether the color curves effect is enabled.
  98741. */
  98742. cameraColorCurvesEnabled: boolean;
  98743. /**
  98744. * Gets wether the color grading effect is enabled.
  98745. */
  98746. /**
  98747. * Gets wether the color grading effect is enabled.
  98748. */
  98749. cameraColorGradingEnabled: boolean;
  98750. /**
  98751. * Gets wether tonemapping is enabled or not.
  98752. */
  98753. /**
  98754. * Sets wether tonemapping is enabled or not
  98755. */
  98756. cameraToneMappingEnabled: boolean;
  98757. /**
  98758. * The camera exposure used on this material.
  98759. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98760. * This corresponds to a photographic exposure.
  98761. */
  98762. /**
  98763. * The camera exposure used on this material.
  98764. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98765. * This corresponds to a photographic exposure.
  98766. */
  98767. cameraExposure: number;
  98768. /**
  98769. * Gets The camera contrast used on this material.
  98770. */
  98771. /**
  98772. * Sets The camera contrast used on this material.
  98773. */
  98774. cameraContrast: number;
  98775. /**
  98776. * Gets the Color Grading 2D Lookup Texture.
  98777. */
  98778. /**
  98779. * Sets the Color Grading 2D Lookup Texture.
  98780. */
  98781. cameraColorGradingTexture: Nullable<BaseTexture>;
  98782. /**
  98783. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98784. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98785. * 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;
  98786. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98787. */
  98788. /**
  98789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98791. * 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;
  98792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98793. */
  98794. cameraColorCurves: Nullable<ColorCurves>;
  98795. /**
  98796. * Custom callback helping to override the default shader used in the material.
  98797. */
  98798. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98799. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98800. protected _worldViewProjectionMatrix: Matrix;
  98801. protected _globalAmbientColor: Color3;
  98802. protected _useLogarithmicDepth: boolean;
  98803. /**
  98804. * Instantiates a new standard material.
  98805. * This is the default material used in Babylon. It is the best trade off between quality
  98806. * and performances.
  98807. * @see http://doc.babylonjs.com/babylon101/materials
  98808. * @param name Define the name of the material in the scene
  98809. * @param scene Define the scene the material belong to
  98810. */
  98811. constructor(name: string, scene: Scene);
  98812. /**
  98813. * Gets a boolean indicating that current material needs to register RTT
  98814. */
  98815. readonly hasRenderTargetTextures: boolean;
  98816. /**
  98817. * Gets the current class name of the material e.g. "StandardMaterial"
  98818. * Mainly use in serialization.
  98819. * @returns the class name
  98820. */
  98821. getClassName(): string;
  98822. /**
  98823. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98824. * You can try switching to logarithmic depth.
  98825. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98826. */
  98827. useLogarithmicDepth: boolean;
  98828. /**
  98829. * Specifies if the material will require alpha blending
  98830. * @returns a boolean specifying if alpha blending is needed
  98831. */
  98832. needAlphaBlending(): boolean;
  98833. /**
  98834. * Specifies if this material should be rendered in alpha test mode
  98835. * @returns a boolean specifying if an alpha test is needed.
  98836. */
  98837. needAlphaTesting(): boolean;
  98838. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98839. /**
  98840. * Get the texture used for alpha test purpose.
  98841. * @returns the diffuse texture in case of the standard material.
  98842. */
  98843. getAlphaTestTexture(): Nullable<BaseTexture>;
  98844. /**
  98845. * Get if the submesh is ready to be used and all its information available.
  98846. * Child classes can use it to update shaders
  98847. * @param mesh defines the mesh to check
  98848. * @param subMesh defines which submesh to check
  98849. * @param useInstances specifies that instances should be used
  98850. * @returns a boolean indicating that the submesh is ready or not
  98851. */
  98852. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98853. /**
  98854. * Builds the material UBO layouts.
  98855. * Used internally during the effect preparation.
  98856. */
  98857. buildUniformLayout(): void;
  98858. /**
  98859. * Unbinds the material from the mesh
  98860. */
  98861. unbind(): void;
  98862. /**
  98863. * Binds the submesh to this material by preparing the effect and shader to draw
  98864. * @param world defines the world transformation matrix
  98865. * @param mesh defines the mesh containing the submesh
  98866. * @param subMesh defines the submesh to bind the material to
  98867. */
  98868. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98869. /**
  98870. * Get the list of animatables in the material.
  98871. * @returns the list of animatables object used in the material
  98872. */
  98873. getAnimatables(): IAnimatable[];
  98874. /**
  98875. * Gets the active textures from the material
  98876. * @returns an array of textures
  98877. */
  98878. getActiveTextures(): BaseTexture[];
  98879. /**
  98880. * Specifies if the material uses a texture
  98881. * @param texture defines the texture to check against the material
  98882. * @returns a boolean specifying if the material uses the texture
  98883. */
  98884. hasTexture(texture: BaseTexture): boolean;
  98885. /**
  98886. * Disposes the material
  98887. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98888. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98889. */
  98890. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98891. /**
  98892. * Makes a duplicate of the material, and gives it a new name
  98893. * @param name defines the new name for the duplicated material
  98894. * @returns the cloned material
  98895. */
  98896. clone(name: string): StandardMaterial;
  98897. /**
  98898. * Serializes this material in a JSON representation
  98899. * @returns the serialized material object
  98900. */
  98901. serialize(): any;
  98902. /**
  98903. * Creates a standard material from parsed material data
  98904. * @param source defines the JSON representation of the material
  98905. * @param scene defines the hosting scene
  98906. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98907. * @returns a new standard material
  98908. */
  98909. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98910. /**
  98911. * Are diffuse textures enabled in the application.
  98912. */
  98913. static DiffuseTextureEnabled: boolean;
  98914. /**
  98915. * Are ambient textures enabled in the application.
  98916. */
  98917. static AmbientTextureEnabled: boolean;
  98918. /**
  98919. * Are opacity textures enabled in the application.
  98920. */
  98921. static OpacityTextureEnabled: boolean;
  98922. /**
  98923. * Are reflection textures enabled in the application.
  98924. */
  98925. static ReflectionTextureEnabled: boolean;
  98926. /**
  98927. * Are emissive textures enabled in the application.
  98928. */
  98929. static EmissiveTextureEnabled: boolean;
  98930. /**
  98931. * Are specular textures enabled in the application.
  98932. */
  98933. static SpecularTextureEnabled: boolean;
  98934. /**
  98935. * Are bump textures enabled in the application.
  98936. */
  98937. static BumpTextureEnabled: boolean;
  98938. /**
  98939. * Are lightmap textures enabled in the application.
  98940. */
  98941. static LightmapTextureEnabled: boolean;
  98942. /**
  98943. * Are refraction textures enabled in the application.
  98944. */
  98945. static RefractionTextureEnabled: boolean;
  98946. /**
  98947. * Are color grading textures enabled in the application.
  98948. */
  98949. static ColorGradingTextureEnabled: boolean;
  98950. /**
  98951. * Are fresnels enabled in the application.
  98952. */
  98953. static FresnelEnabled: boolean;
  98954. }
  98955. }
  98956. declare module BABYLON {
  98957. /**
  98958. * A class extending Texture allowing drawing on a texture
  98959. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98960. */
  98961. export class DynamicTexture extends Texture {
  98962. private _generateMipMaps;
  98963. private _canvas;
  98964. private _context;
  98965. private _engine;
  98966. /**
  98967. * Creates a DynamicTexture
  98968. * @param name defines the name of the texture
  98969. * @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
  98970. * @param scene defines the scene where you want the texture
  98971. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98972. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98973. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98974. */
  98975. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98976. /**
  98977. * Get the current class name of the texture useful for serialization or dynamic coding.
  98978. * @returns "DynamicTexture"
  98979. */
  98980. getClassName(): string;
  98981. /**
  98982. * Gets the current state of canRescale
  98983. */
  98984. readonly canRescale: boolean;
  98985. private _recreate;
  98986. /**
  98987. * Scales the texture
  98988. * @param ratio the scale factor to apply to both width and height
  98989. */
  98990. scale(ratio: number): void;
  98991. /**
  98992. * Resizes the texture
  98993. * @param width the new width
  98994. * @param height the new height
  98995. */
  98996. scaleTo(width: number, height: number): void;
  98997. /**
  98998. * Gets the context of the canvas used by the texture
  98999. * @returns the canvas context of the dynamic texture
  99000. */
  99001. getContext(): CanvasRenderingContext2D;
  99002. /**
  99003. * Clears the texture
  99004. */
  99005. clear(): void;
  99006. /**
  99007. * Updates the texture
  99008. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99009. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99010. */
  99011. update(invertY?: boolean, premulAlpha?: boolean): void;
  99012. /**
  99013. * Draws text onto the texture
  99014. * @param text defines the text to be drawn
  99015. * @param x defines the placement of the text from the left
  99016. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99017. * @param font defines the font to be used with font-style, font-size, font-name
  99018. * @param color defines the color used for the text
  99019. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99020. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99021. * @param update defines whether texture is immediately update (default is true)
  99022. */
  99023. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99024. /**
  99025. * Clones the texture
  99026. * @returns the clone of the texture.
  99027. */
  99028. clone(): DynamicTexture;
  99029. /**
  99030. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99031. * @returns a serialized dynamic texture object
  99032. */
  99033. serialize(): any;
  99034. /** @hidden */
  99035. _rebuild(): void;
  99036. }
  99037. }
  99038. declare module BABYLON {
  99039. /** @hidden */
  99040. export var imageProcessingPixelShader: {
  99041. name: string;
  99042. shader: string;
  99043. };
  99044. }
  99045. declare module BABYLON {
  99046. /**
  99047. * ImageProcessingPostProcess
  99048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99049. */
  99050. export class ImageProcessingPostProcess extends PostProcess {
  99051. /**
  99052. * Default configuration related to image processing available in the PBR Material.
  99053. */
  99054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99055. /**
  99056. * Gets the image processing configuration used either in this material.
  99057. */
  99058. /**
  99059. * Sets the Default image processing configuration used either in the this material.
  99060. *
  99061. * If sets to null, the scene one is in use.
  99062. */
  99063. imageProcessingConfiguration: ImageProcessingConfiguration;
  99064. /**
  99065. * Keep track of the image processing observer to allow dispose and replace.
  99066. */
  99067. private _imageProcessingObserver;
  99068. /**
  99069. * Attaches a new image processing configuration to the PBR Material.
  99070. * @param configuration
  99071. */
  99072. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99073. /**
  99074. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99075. */
  99076. /**
  99077. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99078. */
  99079. colorCurves: Nullable<ColorCurves>;
  99080. /**
  99081. * Gets wether the color curves effect is enabled.
  99082. */
  99083. /**
  99084. * Sets wether the color curves effect is enabled.
  99085. */
  99086. colorCurvesEnabled: boolean;
  99087. /**
  99088. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99089. */
  99090. /**
  99091. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99092. */
  99093. colorGradingTexture: Nullable<BaseTexture>;
  99094. /**
  99095. * Gets wether the color grading effect is enabled.
  99096. */
  99097. /**
  99098. * Gets wether the color grading effect is enabled.
  99099. */
  99100. colorGradingEnabled: boolean;
  99101. /**
  99102. * Gets exposure used in the effect.
  99103. */
  99104. /**
  99105. * Sets exposure used in the effect.
  99106. */
  99107. exposure: number;
  99108. /**
  99109. * Gets wether tonemapping is enabled or not.
  99110. */
  99111. /**
  99112. * Sets wether tonemapping is enabled or not
  99113. */
  99114. toneMappingEnabled: boolean;
  99115. /**
  99116. * Gets the type of tone mapping effect.
  99117. */
  99118. /**
  99119. * Sets the type of tone mapping effect.
  99120. */
  99121. toneMappingType: number;
  99122. /**
  99123. * Gets contrast used in the effect.
  99124. */
  99125. /**
  99126. * Sets contrast used in the effect.
  99127. */
  99128. contrast: number;
  99129. /**
  99130. * Gets Vignette stretch size.
  99131. */
  99132. /**
  99133. * Sets Vignette stretch size.
  99134. */
  99135. vignetteStretch: number;
  99136. /**
  99137. * Gets Vignette centre X Offset.
  99138. */
  99139. /**
  99140. * Sets Vignette centre X Offset.
  99141. */
  99142. vignetteCentreX: number;
  99143. /**
  99144. * Gets Vignette centre Y Offset.
  99145. */
  99146. /**
  99147. * Sets Vignette centre Y Offset.
  99148. */
  99149. vignetteCentreY: number;
  99150. /**
  99151. * Gets Vignette weight or intensity of the vignette effect.
  99152. */
  99153. /**
  99154. * Sets Vignette weight or intensity of the vignette effect.
  99155. */
  99156. vignetteWeight: number;
  99157. /**
  99158. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99159. * if vignetteEnabled is set to true.
  99160. */
  99161. /**
  99162. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99163. * if vignetteEnabled is set to true.
  99164. */
  99165. vignetteColor: Color4;
  99166. /**
  99167. * Gets Camera field of view used by the Vignette effect.
  99168. */
  99169. /**
  99170. * Sets Camera field of view used by the Vignette effect.
  99171. */
  99172. vignetteCameraFov: number;
  99173. /**
  99174. * Gets the vignette blend mode allowing different kind of effect.
  99175. */
  99176. /**
  99177. * Sets the vignette blend mode allowing different kind of effect.
  99178. */
  99179. vignetteBlendMode: number;
  99180. /**
  99181. * Gets wether the vignette effect is enabled.
  99182. */
  99183. /**
  99184. * Sets wether the vignette effect is enabled.
  99185. */
  99186. vignetteEnabled: boolean;
  99187. private _fromLinearSpace;
  99188. /**
  99189. * Gets wether the input of the processing is in Gamma or Linear Space.
  99190. */
  99191. /**
  99192. * Sets wether the input of the processing is in Gamma or Linear Space.
  99193. */
  99194. fromLinearSpace: boolean;
  99195. /**
  99196. * Defines cache preventing GC.
  99197. */
  99198. private _defines;
  99199. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99200. /**
  99201. * "ImageProcessingPostProcess"
  99202. * @returns "ImageProcessingPostProcess"
  99203. */
  99204. getClassName(): string;
  99205. protected _updateParameters(): void;
  99206. dispose(camera?: Camera): void;
  99207. }
  99208. }
  99209. declare module BABYLON {
  99210. /**
  99211. * Class containing static functions to help procedurally build meshes
  99212. */
  99213. export class GroundBuilder {
  99214. /**
  99215. * Creates a ground mesh
  99216. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99217. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99219. * @param name defines the name of the mesh
  99220. * @param options defines the options used to create the mesh
  99221. * @param scene defines the hosting scene
  99222. * @returns the ground mesh
  99223. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99224. */
  99225. static CreateGround(name: string, options: {
  99226. width?: number;
  99227. height?: number;
  99228. subdivisions?: number;
  99229. subdivisionsX?: number;
  99230. subdivisionsY?: number;
  99231. updatable?: boolean;
  99232. }, scene: any): Mesh;
  99233. /**
  99234. * Creates a tiled ground mesh
  99235. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99236. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99237. * * 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
  99238. * * 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
  99239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99240. * @param name defines the name of the mesh
  99241. * @param options defines the options used to create the mesh
  99242. * @param scene defines the hosting scene
  99243. * @returns the tiled ground mesh
  99244. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99245. */
  99246. static CreateTiledGround(name: string, options: {
  99247. xmin: number;
  99248. zmin: number;
  99249. xmax: number;
  99250. zmax: number;
  99251. subdivisions?: {
  99252. w: number;
  99253. h: number;
  99254. };
  99255. precision?: {
  99256. w: number;
  99257. h: number;
  99258. };
  99259. updatable?: boolean;
  99260. }, scene?: Nullable<Scene>): Mesh;
  99261. /**
  99262. * Creates a ground mesh from a height map
  99263. * * The parameter `url` sets the URL of the height map image resource.
  99264. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99265. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99266. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99267. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99268. * * 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.
  99269. * * 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).
  99270. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99272. * @param name defines the name of the mesh
  99273. * @param url defines the url to the height map
  99274. * @param options defines the options used to create the mesh
  99275. * @param scene defines the hosting scene
  99276. * @returns the ground mesh
  99277. * @see https://doc.babylonjs.com/babylon101/height_map
  99278. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99279. */
  99280. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99281. width?: number;
  99282. height?: number;
  99283. subdivisions?: number;
  99284. minHeight?: number;
  99285. maxHeight?: number;
  99286. colorFilter?: Color3;
  99287. alphaFilter?: number;
  99288. updatable?: boolean;
  99289. onReady?: (mesh: GroundMesh) => void;
  99290. }, scene?: Nullable<Scene>): GroundMesh;
  99291. }
  99292. }
  99293. declare module BABYLON {
  99294. /**
  99295. * Class containing static functions to help procedurally build meshes
  99296. */
  99297. export class TorusBuilder {
  99298. /**
  99299. * Creates a torus mesh
  99300. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99301. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99302. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99306. * @param name defines the name of the mesh
  99307. * @param options defines the options used to create the mesh
  99308. * @param scene defines the hosting scene
  99309. * @returns the torus mesh
  99310. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99311. */
  99312. static CreateTorus(name: string, options: {
  99313. diameter?: number;
  99314. thickness?: number;
  99315. tessellation?: number;
  99316. updatable?: boolean;
  99317. sideOrientation?: number;
  99318. frontUVs?: Vector4;
  99319. backUVs?: Vector4;
  99320. }, scene: any): Mesh;
  99321. }
  99322. }
  99323. declare module BABYLON {
  99324. /**
  99325. * Class containing static functions to help procedurally build meshes
  99326. */
  99327. export class CylinderBuilder {
  99328. /**
  99329. * Creates a cylinder or a cone mesh
  99330. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99331. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99332. * * 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.
  99333. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99334. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99335. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99336. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99337. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99338. * * 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).
  99339. * * 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
  99340. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99341. * * 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
  99342. * * 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.
  99343. * * If `enclose` is false, a ring surface is one element.
  99344. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99345. * * 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
  99346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99349. * @param name defines the name of the mesh
  99350. * @param options defines the options used to create the mesh
  99351. * @param scene defines the hosting scene
  99352. * @returns the cylinder mesh
  99353. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99354. */
  99355. static CreateCylinder(name: string, options: {
  99356. height?: number;
  99357. diameterTop?: number;
  99358. diameterBottom?: number;
  99359. diameter?: number;
  99360. tessellation?: number;
  99361. subdivisions?: number;
  99362. arc?: number;
  99363. faceColors?: Color4[];
  99364. faceUV?: Vector4[];
  99365. updatable?: boolean;
  99366. hasRings?: boolean;
  99367. enclose?: boolean;
  99368. sideOrientation?: number;
  99369. frontUVs?: Vector4;
  99370. backUVs?: Vector4;
  99371. }, scene: any): Mesh;
  99372. }
  99373. }
  99374. declare module BABYLON {
  99375. /**
  99376. * Manager for handling gamepads
  99377. */
  99378. export class GamepadManager {
  99379. private _scene?;
  99380. private _babylonGamepads;
  99381. private _oneGamepadConnected;
  99382. /** @hidden */
  99383. _isMonitoring: boolean;
  99384. private _gamepadEventSupported;
  99385. private _gamepadSupport;
  99386. /**
  99387. * observable to be triggered when the gamepad controller has been connected
  99388. */
  99389. onGamepadConnectedObservable: Observable<Gamepad>;
  99390. /**
  99391. * observable to be triggered when the gamepad controller has been disconnected
  99392. */
  99393. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99394. private _onGamepadConnectedEvent;
  99395. private _onGamepadDisconnectedEvent;
  99396. /**
  99397. * Initializes the gamepad manager
  99398. * @param _scene BabylonJS scene
  99399. */
  99400. constructor(_scene?: Scene | undefined);
  99401. /**
  99402. * The gamepads in the game pad manager
  99403. */
  99404. readonly gamepads: Gamepad[];
  99405. /**
  99406. * Get the gamepad controllers based on type
  99407. * @param type The type of gamepad controller
  99408. * @returns Nullable gamepad
  99409. */
  99410. getGamepadByType(type?: number): Nullable<Gamepad>;
  99411. /**
  99412. * Disposes the gamepad manager
  99413. */
  99414. dispose(): void;
  99415. private _addNewGamepad;
  99416. private _startMonitoringGamepads;
  99417. private _stopMonitoringGamepads;
  99418. /** @hidden */
  99419. _checkGamepadsStatus(): void;
  99420. private _updateGamepadObjects;
  99421. }
  99422. }
  99423. declare module BABYLON {
  99424. interface Scene {
  99425. /** @hidden */
  99426. _gamepadManager: Nullable<GamepadManager>;
  99427. /**
  99428. * Gets the gamepad manager associated with the scene
  99429. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99430. */
  99431. gamepadManager: GamepadManager;
  99432. }
  99433. /**
  99434. * Interface representing a free camera inputs manager
  99435. */
  99436. interface FreeCameraInputsManager {
  99437. /**
  99438. * Adds gamepad input support to the FreeCameraInputsManager.
  99439. * @returns the FreeCameraInputsManager
  99440. */
  99441. addGamepad(): FreeCameraInputsManager;
  99442. }
  99443. /**
  99444. * Interface representing an arc rotate camera inputs manager
  99445. */
  99446. interface ArcRotateCameraInputsManager {
  99447. /**
  99448. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99449. * @returns the camera inputs manager
  99450. */
  99451. addGamepad(): ArcRotateCameraInputsManager;
  99452. }
  99453. /**
  99454. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99455. */
  99456. export class GamepadSystemSceneComponent implements ISceneComponent {
  99457. /**
  99458. * The component name helpfull to identify the component in the list of scene components.
  99459. */
  99460. readonly name: string;
  99461. /**
  99462. * The scene the component belongs to.
  99463. */
  99464. scene: Scene;
  99465. /**
  99466. * Creates a new instance of the component for the given scene
  99467. * @param scene Defines the scene to register the component in
  99468. */
  99469. constructor(scene: Scene);
  99470. /**
  99471. * Registers the component in a given scene
  99472. */
  99473. register(): void;
  99474. /**
  99475. * Rebuilds the elements related to this component in case of
  99476. * context lost for instance.
  99477. */
  99478. rebuild(): void;
  99479. /**
  99480. * Disposes the component and the associated ressources
  99481. */
  99482. dispose(): void;
  99483. private _beforeCameraUpdate;
  99484. }
  99485. }
  99486. declare module BABYLON {
  99487. /**
  99488. * Options to modify the vr teleportation behavior.
  99489. */
  99490. export interface VRTeleportationOptions {
  99491. /**
  99492. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99493. */
  99494. floorMeshName?: string;
  99495. /**
  99496. * A list of meshes to be used as the teleportation floor. (default: empty)
  99497. */
  99498. floorMeshes?: Mesh[];
  99499. }
  99500. /**
  99501. * Options to modify the vr experience helper's behavior.
  99502. */
  99503. export interface VRExperienceHelperOptions extends WebVROptions {
  99504. /**
  99505. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99506. */
  99507. createDeviceOrientationCamera?: boolean;
  99508. /**
  99509. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99510. */
  99511. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99512. /**
  99513. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99514. */
  99515. laserToggle?: boolean;
  99516. /**
  99517. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99518. */
  99519. floorMeshes?: Mesh[];
  99520. /**
  99521. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99522. */
  99523. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99524. }
  99525. /**
  99526. * Event containing information after VR has been entered
  99527. */
  99528. export class OnAfterEnteringVRObservableEvent {
  99529. /**
  99530. * If entering vr was successful
  99531. */
  99532. success: boolean;
  99533. }
  99534. /**
  99535. * Helps to quickly add VR support to an existing scene.
  99536. * See http://doc.babylonjs.com/how_to/webvr_helper
  99537. */
  99538. export class VRExperienceHelper {
  99539. /** Options to modify the vr experience helper's behavior. */
  99540. webVROptions: VRExperienceHelperOptions;
  99541. private _scene;
  99542. private _position;
  99543. private _btnVR;
  99544. private _btnVRDisplayed;
  99545. private _webVRsupported;
  99546. private _webVRready;
  99547. private _webVRrequesting;
  99548. private _webVRpresenting;
  99549. private _hasEnteredVR;
  99550. private _fullscreenVRpresenting;
  99551. private _canvas;
  99552. private _webVRCamera;
  99553. private _vrDeviceOrientationCamera;
  99554. private _deviceOrientationCamera;
  99555. private _existingCamera;
  99556. private _onKeyDown;
  99557. private _onVrDisplayPresentChange;
  99558. private _onVRDisplayChanged;
  99559. private _onVRRequestPresentStart;
  99560. private _onVRRequestPresentComplete;
  99561. /**
  99562. * Observable raised right before entering VR.
  99563. */
  99564. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99565. /**
  99566. * Observable raised when entering VR has completed.
  99567. */
  99568. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99569. /**
  99570. * Observable raised when exiting VR.
  99571. */
  99572. onExitingVRObservable: Observable<VRExperienceHelper>;
  99573. /**
  99574. * Observable raised when controller mesh is loaded.
  99575. */
  99576. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99577. /** Return this.onEnteringVRObservable
  99578. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99579. */
  99580. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99581. /** Return this.onExitingVRObservable
  99582. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99583. */
  99584. readonly onExitingVR: Observable<VRExperienceHelper>;
  99585. /** Return this.onControllerMeshLoadedObservable
  99586. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99587. */
  99588. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99589. private _rayLength;
  99590. private _useCustomVRButton;
  99591. private _teleportationRequested;
  99592. private _teleportActive;
  99593. private _floorMeshName;
  99594. private _floorMeshesCollection;
  99595. private _rotationAllowed;
  99596. private _teleportBackwardsVector;
  99597. private _teleportationTarget;
  99598. private _isDefaultTeleportationTarget;
  99599. private _postProcessMove;
  99600. private _teleportationFillColor;
  99601. private _teleportationBorderColor;
  99602. private _rotationAngle;
  99603. private _haloCenter;
  99604. private _cameraGazer;
  99605. private _padSensibilityUp;
  99606. private _padSensibilityDown;
  99607. private _leftController;
  99608. private _rightController;
  99609. /**
  99610. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99611. */
  99612. onNewMeshSelected: Observable<AbstractMesh>;
  99613. /**
  99614. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99615. */
  99616. onNewMeshPicked: Observable<PickingInfo>;
  99617. private _circleEase;
  99618. /**
  99619. * Observable raised before camera teleportation
  99620. */
  99621. onBeforeCameraTeleport: Observable<Vector3>;
  99622. /**
  99623. * Observable raised after camera teleportation
  99624. */
  99625. onAfterCameraTeleport: Observable<Vector3>;
  99626. /**
  99627. * Observable raised when current selected mesh gets unselected
  99628. */
  99629. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99630. private _raySelectionPredicate;
  99631. /**
  99632. * To be optionaly changed by user to define custom ray selection
  99633. */
  99634. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99635. /**
  99636. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99637. */
  99638. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99639. /**
  99640. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99641. */
  99642. teleportationEnabled: boolean;
  99643. private _defaultHeight;
  99644. private _teleportationInitialized;
  99645. private _interactionsEnabled;
  99646. private _interactionsRequested;
  99647. private _displayGaze;
  99648. private _displayLaserPointer;
  99649. /**
  99650. * The mesh used to display where the user is going to teleport.
  99651. */
  99652. /**
  99653. * Sets the mesh to be used to display where the user is going to teleport.
  99654. */
  99655. teleportationTarget: Mesh;
  99656. /**
  99657. * 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
  99658. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99659. * See http://doc.babylonjs.com/resources/baking_transformations
  99660. */
  99661. gazeTrackerMesh: Mesh;
  99662. /**
  99663. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99664. */
  99665. updateGazeTrackerScale: boolean;
  99666. /**
  99667. * If the gaze trackers color should be updated when selecting meshes
  99668. */
  99669. updateGazeTrackerColor: boolean;
  99670. /**
  99671. * The gaze tracking mesh corresponding to the left controller
  99672. */
  99673. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99674. /**
  99675. * The gaze tracking mesh corresponding to the right controller
  99676. */
  99677. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99678. /**
  99679. * If the ray of the gaze should be displayed.
  99680. */
  99681. /**
  99682. * Sets if the ray of the gaze should be displayed.
  99683. */
  99684. displayGaze: boolean;
  99685. /**
  99686. * If the ray of the LaserPointer should be displayed.
  99687. */
  99688. /**
  99689. * Sets if the ray of the LaserPointer should be displayed.
  99690. */
  99691. displayLaserPointer: boolean;
  99692. /**
  99693. * The deviceOrientationCamera used as the camera when not in VR.
  99694. */
  99695. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99696. /**
  99697. * Based on the current WebVR support, returns the current VR camera used.
  99698. */
  99699. readonly currentVRCamera: Nullable<Camera>;
  99700. /**
  99701. * The webVRCamera which is used when in VR.
  99702. */
  99703. readonly webVRCamera: WebVRFreeCamera;
  99704. /**
  99705. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99706. */
  99707. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99708. private readonly _teleportationRequestInitiated;
  99709. /**
  99710. * Defines wether or not Pointer lock should be requested when switching to
  99711. * full screen.
  99712. */
  99713. requestPointerLockOnFullScreen: boolean;
  99714. /**
  99715. * Instantiates a VRExperienceHelper.
  99716. * Helps to quickly add VR support to an existing scene.
  99717. * @param scene The scene the VRExperienceHelper belongs to.
  99718. * @param webVROptions Options to modify the vr experience helper's behavior.
  99719. */
  99720. constructor(scene: Scene,
  99721. /** Options to modify the vr experience helper's behavior. */
  99722. webVROptions?: VRExperienceHelperOptions);
  99723. private _onDefaultMeshLoaded;
  99724. private _onResize;
  99725. private _onFullscreenChange;
  99726. /**
  99727. * Gets a value indicating if we are currently in VR mode.
  99728. */
  99729. readonly isInVRMode: boolean;
  99730. private onVrDisplayPresentChange;
  99731. private onVRDisplayChanged;
  99732. private moveButtonToBottomRight;
  99733. private displayVRButton;
  99734. private updateButtonVisibility;
  99735. private _cachedAngularSensibility;
  99736. /**
  99737. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99738. * Otherwise, will use the fullscreen API.
  99739. */
  99740. enterVR(): void;
  99741. /**
  99742. * Attempt to exit VR, or fullscreen.
  99743. */
  99744. exitVR(): void;
  99745. /**
  99746. * The position of the vr experience helper.
  99747. */
  99748. /**
  99749. * Sets the position of the vr experience helper.
  99750. */
  99751. position: Vector3;
  99752. /**
  99753. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99754. */
  99755. enableInteractions(): void;
  99756. private readonly _noControllerIsActive;
  99757. private beforeRender;
  99758. private _isTeleportationFloor;
  99759. /**
  99760. * Adds a floor mesh to be used for teleportation.
  99761. * @param floorMesh the mesh to be used for teleportation.
  99762. */
  99763. addFloorMesh(floorMesh: Mesh): void;
  99764. /**
  99765. * Removes a floor mesh from being used for teleportation.
  99766. * @param floorMesh the mesh to be removed.
  99767. */
  99768. removeFloorMesh(floorMesh: Mesh): void;
  99769. /**
  99770. * Enables interactions and teleportation using the VR controllers and gaze.
  99771. * @param vrTeleportationOptions options to modify teleportation behavior.
  99772. */
  99773. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99774. private _onNewGamepadConnected;
  99775. private _tryEnableInteractionOnController;
  99776. private _onNewGamepadDisconnected;
  99777. private _enableInteractionOnController;
  99778. private _checkTeleportWithRay;
  99779. private _checkRotate;
  99780. private _checkTeleportBackwards;
  99781. private _enableTeleportationOnController;
  99782. private _createTeleportationCircles;
  99783. private _displayTeleportationTarget;
  99784. private _hideTeleportationTarget;
  99785. private _rotateCamera;
  99786. private _moveTeleportationSelectorTo;
  99787. private _workingVector;
  99788. private _workingQuaternion;
  99789. private _workingMatrix;
  99790. /**
  99791. * Teleports the users feet to the desired location
  99792. * @param location The location where the user's feet should be placed
  99793. */
  99794. teleportCamera(location: Vector3): void;
  99795. private _convertNormalToDirectionOfRay;
  99796. private _castRayAndSelectObject;
  99797. private _notifySelectedMeshUnselected;
  99798. /**
  99799. * Sets the color of the laser ray from the vr controllers.
  99800. * @param color new color for the ray.
  99801. */
  99802. changeLaserColor(color: Color3): void;
  99803. /**
  99804. * Sets the color of the ray from the vr headsets gaze.
  99805. * @param color new color for the ray.
  99806. */
  99807. changeGazeColor(color: Color3): void;
  99808. /**
  99809. * Exits VR and disposes of the vr experience helper
  99810. */
  99811. dispose(): void;
  99812. /**
  99813. * Gets the name of the VRExperienceHelper class
  99814. * @returns "VRExperienceHelper"
  99815. */
  99816. getClassName(): string;
  99817. }
  99818. }
  99819. declare module BABYLON {
  99820. /**
  99821. * Manages an XRSession
  99822. * @see https://doc.babylonjs.com/how_to/webxr
  99823. */
  99824. export class WebXRSessionManager implements IDisposable {
  99825. private scene;
  99826. /**
  99827. * Fires every time a new xrFrame arrives which can be used to update the camera
  99828. */
  99829. onXRFrameObservable: Observable<any>;
  99830. /**
  99831. * Fires when the xr session is ended either by the device or manually done
  99832. */
  99833. onXRSessionEnded: Observable<any>;
  99834. /** @hidden */
  99835. _xrSession: XRSession;
  99836. /** @hidden */
  99837. _frameOfReference: XRFrameOfReference;
  99838. /** @hidden */
  99839. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99840. /** @hidden */
  99841. _currentXRFrame: Nullable<XRFrame>;
  99842. private _xrNavigator;
  99843. private _xrDevice;
  99844. private _tmpMatrix;
  99845. /**
  99846. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99847. * @param scene The scene which the session should be created for
  99848. */
  99849. constructor(scene: Scene);
  99850. /**
  99851. * Initializes the manager
  99852. * After initialization enterXR can be called to start an XR session
  99853. * @returns Promise which resolves after it is initialized
  99854. */
  99855. initializeAsync(): Promise<void>;
  99856. /**
  99857. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99858. * @param sessionCreationOptions xr options to create the session with
  99859. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99860. * @returns Promise which resolves after it enters XR
  99861. */
  99862. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99863. /**
  99864. * Stops the xrSession and restores the renderloop
  99865. * @returns Promise which resolves after it exits XR
  99866. */
  99867. exitXRAsync(): Promise<void>;
  99868. /**
  99869. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99870. * @param ray ray to cast into the environment
  99871. * @returns Promise which resolves with a collision point in the environment if it exists
  99872. */
  99873. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99874. /**
  99875. * Checks if a session would be supported for the creation options specified
  99876. * @param options creation options to check if they are supported
  99877. * @returns true if supported
  99878. */
  99879. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99880. /**
  99881. * @hidden
  99882. * Converts the render layer of xrSession to a render target
  99883. * @param session session to create render target for
  99884. * @param scene scene the new render target should be created for
  99885. */
  99886. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99887. /**
  99888. * Disposes of the session manager
  99889. */
  99890. dispose(): void;
  99891. }
  99892. }
  99893. declare module BABYLON {
  99894. /**
  99895. * WebXR Camera which holds the views for the xrSession
  99896. * @see https://doc.babylonjs.com/how_to/webxr
  99897. */
  99898. export class WebXRCamera extends FreeCamera {
  99899. private static _TmpMatrix;
  99900. /**
  99901. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99902. * @param name the name of the camera
  99903. * @param scene the scene to add the camera to
  99904. */
  99905. constructor(name: string, scene: Scene);
  99906. private _updateNumberOfRigCameras;
  99907. /** @hidden */
  99908. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99909. /**
  99910. * Updates the cameras position from the current pose information of the XR session
  99911. * @param xrSessionManager the session containing pose information
  99912. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99913. */
  99914. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99915. }
  99916. }
  99917. declare module BABYLON {
  99918. /**
  99919. * States of the webXR experience
  99920. */
  99921. export enum WebXRState {
  99922. /**
  99923. * Transitioning to being in XR mode
  99924. */
  99925. ENTERING_XR = 0,
  99926. /**
  99927. * Transitioning to non XR mode
  99928. */
  99929. EXITING_XR = 1,
  99930. /**
  99931. * In XR mode and presenting
  99932. */
  99933. IN_XR = 2,
  99934. /**
  99935. * Not entered XR mode
  99936. */
  99937. NOT_IN_XR = 3
  99938. }
  99939. /**
  99940. * Helper class used to enable XR
  99941. * @see https://doc.babylonjs.com/how_to/webxr
  99942. */
  99943. export class WebXRExperienceHelper implements IDisposable {
  99944. private scene;
  99945. /**
  99946. * 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
  99947. */
  99948. container: AbstractMesh;
  99949. /**
  99950. * Camera used to render xr content
  99951. */
  99952. camera: WebXRCamera;
  99953. /**
  99954. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99955. */
  99956. state: WebXRState;
  99957. private _setState;
  99958. private static _TmpVector;
  99959. /**
  99960. * Fires when the state of the experience helper has changed
  99961. */
  99962. onStateChangedObservable: Observable<WebXRState>;
  99963. /** @hidden */
  99964. _sessionManager: WebXRSessionManager;
  99965. private _nonVRCamera;
  99966. private _originalSceneAutoClear;
  99967. private _supported;
  99968. /**
  99969. * Creates the experience helper
  99970. * @param scene the scene to attach the experience helper to
  99971. * @returns a promise for the experience helper
  99972. */
  99973. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99974. /**
  99975. * Creates a WebXRExperienceHelper
  99976. * @param scene The scene the helper should be created in
  99977. */
  99978. private constructor();
  99979. /**
  99980. * Exits XR mode and returns the scene to its original state
  99981. * @returns promise that resolves after xr mode has exited
  99982. */
  99983. exitXRAsync(): Promise<void>;
  99984. /**
  99985. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99986. * @param sessionCreationOptions options for the XR session
  99987. * @param frameOfReference frame of reference of the XR session
  99988. * @returns promise that resolves after xr mode has entered
  99989. */
  99990. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99991. /**
  99992. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99993. * @param ray ray to cast into the environment
  99994. * @returns Promise which resolves with a collision point in the environment if it exists
  99995. */
  99996. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99997. /**
  99998. * Updates the global position of the camera by moving the camera's container
  99999. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100000. * @param position The desired global position of the camera
  100001. */
  100002. setPositionOfCameraUsingContainer(position: Vector3): void;
  100003. /**
  100004. * Rotates the xr camera by rotating the camera's container around the camera's position
  100005. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100006. * @param rotation the desired quaternion rotation to apply to the camera
  100007. */
  100008. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100009. /**
  100010. * Checks if the creation options are supported by the xr session
  100011. * @param options creation options
  100012. * @returns true if supported
  100013. */
  100014. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100015. /**
  100016. * Disposes of the experience helper
  100017. */
  100018. dispose(): void;
  100019. }
  100020. }
  100021. declare module BABYLON {
  100022. /**
  100023. * Button which can be used to enter a different mode of XR
  100024. */
  100025. export class WebXREnterExitUIButton {
  100026. /** button element */
  100027. element: HTMLElement;
  100028. /** XR initialization options for the button */
  100029. initializationOptions: XRSessionCreationOptions;
  100030. /**
  100031. * Creates a WebXREnterExitUIButton
  100032. * @param element button element
  100033. * @param initializationOptions XR initialization options for the button
  100034. */
  100035. constructor(
  100036. /** button element */
  100037. element: HTMLElement,
  100038. /** XR initialization options for the button */
  100039. initializationOptions: XRSessionCreationOptions);
  100040. /**
  100041. * Overwritable function which can be used to update the button's visuals when the state changes
  100042. * @param activeButton the current active button in the UI
  100043. */
  100044. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100045. }
  100046. /**
  100047. * Options to create the webXR UI
  100048. */
  100049. export class WebXREnterExitUIOptions {
  100050. /**
  100051. * Context to enter xr with
  100052. */
  100053. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100054. /**
  100055. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100056. */
  100057. customButtons?: Array<WebXREnterExitUIButton>;
  100058. }
  100059. /**
  100060. * UI to allow the user to enter/exit XR mode
  100061. */
  100062. export class WebXREnterExitUI implements IDisposable {
  100063. private scene;
  100064. private _overlay;
  100065. private _buttons;
  100066. private _activeButton;
  100067. /**
  100068. * Fired every time the active button is changed.
  100069. *
  100070. * When xr is entered via a button that launches xr that button will be the callback parameter
  100071. *
  100072. * When exiting xr the callback parameter will be null)
  100073. */
  100074. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100075. /**
  100076. * Creates UI to allow the user to enter/exit XR mode
  100077. * @param scene the scene to add the ui to
  100078. * @param helper the xr experience helper to enter/exit xr with
  100079. * @param options options to configure the UI
  100080. * @returns the created ui
  100081. */
  100082. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100083. private constructor();
  100084. private _updateButtons;
  100085. /**
  100086. * Disposes of the object
  100087. */
  100088. dispose(): void;
  100089. }
  100090. }
  100091. declare module BABYLON {
  100092. /**
  100093. * Represents an XR input
  100094. */
  100095. export class WebXRController {
  100096. /**
  100097. * 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
  100098. */
  100099. grip?: AbstractMesh;
  100100. /**
  100101. * Pointer which can be used to select objects or attach a visible laser to
  100102. */
  100103. pointer: AbstractMesh;
  100104. /**
  100105. * Creates the controller
  100106. * @see https://doc.babylonjs.com/how_to/webxr
  100107. * @param scene the scene which the controller should be associated to
  100108. */
  100109. constructor(scene: Scene);
  100110. /**
  100111. * Disposes of the object
  100112. */
  100113. dispose(): void;
  100114. }
  100115. /**
  100116. * XR input used to track XR inputs such as controllers/rays
  100117. */
  100118. export class WebXRInput implements IDisposable {
  100119. private helper;
  100120. /**
  100121. * XR controllers being tracked
  100122. */
  100123. controllers: Array<WebXRController>;
  100124. private _tmpMatrix;
  100125. private _frameObserver;
  100126. /**
  100127. * Initializes the WebXRInput
  100128. * @param helper experience helper which the input should be created for
  100129. */
  100130. constructor(helper: WebXRExperienceHelper);
  100131. /**
  100132. * Disposes of the object
  100133. */
  100134. dispose(): void;
  100135. }
  100136. }
  100137. declare module BABYLON {
  100138. /**
  100139. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100140. */
  100141. export class WebXRManagedOutputCanvas implements IDisposable {
  100142. private _canvas;
  100143. /**
  100144. * xrpresent context of the canvas which can be used to display/mirror xr content
  100145. */
  100146. canvasContext: Nullable<WebGLRenderingContext>;
  100147. /**
  100148. * Initializes the canvas to be added/removed upon entering/exiting xr
  100149. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100150. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100151. */
  100152. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100153. /**
  100154. * Disposes of the object
  100155. */
  100156. dispose(): void;
  100157. private _setManagedOutputCanvas;
  100158. private _addCanvas;
  100159. private _removeCanvas;
  100160. }
  100161. }
  100162. declare module BABYLON {
  100163. /**
  100164. * Contains an array of blocks representing the octree
  100165. */
  100166. export interface IOctreeContainer<T> {
  100167. /**
  100168. * Blocks within the octree
  100169. */
  100170. blocks: Array<OctreeBlock<T>>;
  100171. }
  100172. /**
  100173. * Class used to store a cell in an octree
  100174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100175. */
  100176. export class OctreeBlock<T> {
  100177. /**
  100178. * Gets the content of the current block
  100179. */
  100180. entries: T[];
  100181. /**
  100182. * Gets the list of block children
  100183. */
  100184. blocks: Array<OctreeBlock<T>>;
  100185. private _depth;
  100186. private _maxDepth;
  100187. private _capacity;
  100188. private _minPoint;
  100189. private _maxPoint;
  100190. private _boundingVectors;
  100191. private _creationFunc;
  100192. /**
  100193. * Creates a new block
  100194. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100195. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100196. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100197. * @param depth defines the current depth of this block in the octree
  100198. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100199. * @param creationFunc defines a callback to call when an element is added to the block
  100200. */
  100201. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100202. /**
  100203. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100204. */
  100205. readonly capacity: number;
  100206. /**
  100207. * Gets the minimum vector (in world space) of the block's bounding box
  100208. */
  100209. readonly minPoint: Vector3;
  100210. /**
  100211. * Gets the maximum vector (in world space) of the block's bounding box
  100212. */
  100213. readonly maxPoint: Vector3;
  100214. /**
  100215. * Add a new element to this block
  100216. * @param entry defines the element to add
  100217. */
  100218. addEntry(entry: T): void;
  100219. /**
  100220. * Remove an element from this block
  100221. * @param entry defines the element to remove
  100222. */
  100223. removeEntry(entry: T): void;
  100224. /**
  100225. * Add an array of elements to this block
  100226. * @param entries defines the array of elements to add
  100227. */
  100228. addEntries(entries: T[]): void;
  100229. /**
  100230. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100231. * @param frustumPlanes defines the frustum planes to test
  100232. * @param selection defines the array to store current content if selection is positive
  100233. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100234. */
  100235. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100236. /**
  100237. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100238. * @param sphereCenter defines the bounding sphere center
  100239. * @param sphereRadius defines the bounding sphere radius
  100240. * @param selection defines the array to store current content if selection is positive
  100241. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100242. */
  100243. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100244. /**
  100245. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100246. * @param ray defines the ray to test with
  100247. * @param selection defines the array to store current content if selection is positive
  100248. */
  100249. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100250. /**
  100251. * Subdivide the content into child blocks (this block will then be empty)
  100252. */
  100253. createInnerBlocks(): void;
  100254. /**
  100255. * @hidden
  100256. */
  100257. 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;
  100258. }
  100259. }
  100260. declare module BABYLON {
  100261. /**
  100262. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100263. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100264. */
  100265. export class Octree<T> {
  100266. /** 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.) */
  100267. maxDepth: number;
  100268. /**
  100269. * Blocks within the octree containing objects
  100270. */
  100271. blocks: Array<OctreeBlock<T>>;
  100272. /**
  100273. * Content stored in the octree
  100274. */
  100275. dynamicContent: T[];
  100276. private _maxBlockCapacity;
  100277. private _selectionContent;
  100278. private _creationFunc;
  100279. /**
  100280. * Creates a octree
  100281. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100282. * @param creationFunc function to be used to instatiate the octree
  100283. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100284. * @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.)
  100285. */
  100286. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100287. /** 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.) */
  100288. maxDepth?: number);
  100289. /**
  100290. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100291. * @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);
  100292. * @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);
  100293. * @param entries meshes to be added to the octree blocks
  100294. */
  100295. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100296. /**
  100297. * Adds a mesh to the octree
  100298. * @param entry Mesh to add to the octree
  100299. */
  100300. addMesh(entry: T): void;
  100301. /**
  100302. * Remove an element from the octree
  100303. * @param entry defines the element to remove
  100304. */
  100305. removeMesh(entry: T): void;
  100306. /**
  100307. * Selects an array of meshes within the frustum
  100308. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100309. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100310. * @returns array of meshes within the frustum
  100311. */
  100312. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100313. /**
  100314. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100315. * @param sphereCenter defines the bounding sphere center
  100316. * @param sphereRadius defines the bounding sphere radius
  100317. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100318. * @returns an array of objects that intersect the sphere
  100319. */
  100320. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100321. /**
  100322. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100323. * @param ray defines the ray to test with
  100324. * @returns array of intersected objects
  100325. */
  100326. intersectsRay(ray: Ray): SmartArray<T>;
  100327. /**
  100328. * Adds a mesh into the octree block if it intersects the block
  100329. */
  100330. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100331. /**
  100332. * Adds a submesh into the octree block if it intersects the block
  100333. */
  100334. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100335. }
  100336. }
  100337. declare module BABYLON {
  100338. interface Scene {
  100339. /**
  100340. * @hidden
  100341. * Backing Filed
  100342. */
  100343. _selectionOctree: Octree<AbstractMesh>;
  100344. /**
  100345. * Gets the octree used to boost mesh selection (picking)
  100346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100347. */
  100348. selectionOctree: Octree<AbstractMesh>;
  100349. /**
  100350. * Creates or updates the octree used to boost selection (picking)
  100351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100352. * @param maxCapacity defines the maximum capacity per leaf
  100353. * @param maxDepth defines the maximum depth of the octree
  100354. * @returns an octree of AbstractMesh
  100355. */
  100356. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100357. }
  100358. interface AbstractMesh {
  100359. /**
  100360. * @hidden
  100361. * Backing Field
  100362. */
  100363. _submeshesOctree: Octree<SubMesh>;
  100364. /**
  100365. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100366. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100367. * @param maxCapacity defines the maximum size of each block (64 by default)
  100368. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100369. * @returns the new octree
  100370. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100372. */
  100373. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100374. }
  100375. /**
  100376. * Defines the octree scene component responsible to manage any octrees
  100377. * in a given scene.
  100378. */
  100379. export class OctreeSceneComponent {
  100380. /**
  100381. * The component name help to identify the component in the list of scene components.
  100382. */
  100383. readonly name: string;
  100384. /**
  100385. * The scene the component belongs to.
  100386. */
  100387. scene: Scene;
  100388. /**
  100389. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100390. */
  100391. readonly checksIsEnabled: boolean;
  100392. /**
  100393. * Creates a new instance of the component for the given scene
  100394. * @param scene Defines the scene to register the component in
  100395. */
  100396. constructor(scene: Scene);
  100397. /**
  100398. * Registers the component in a given scene
  100399. */
  100400. register(): void;
  100401. /**
  100402. * Return the list of active meshes
  100403. * @returns the list of active meshes
  100404. */
  100405. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100406. /**
  100407. * Return the list of active sub meshes
  100408. * @param mesh The mesh to get the candidates sub meshes from
  100409. * @returns the list of active sub meshes
  100410. */
  100411. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100412. private _tempRay;
  100413. /**
  100414. * Return the list of sub meshes intersecting with a given local ray
  100415. * @param mesh defines the mesh to find the submesh for
  100416. * @param localRay defines the ray in local space
  100417. * @returns the list of intersecting sub meshes
  100418. */
  100419. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100420. /**
  100421. * Return the list of sub meshes colliding with a collider
  100422. * @param mesh defines the mesh to find the submesh for
  100423. * @param collider defines the collider to evaluate the collision against
  100424. * @returns the list of colliding sub meshes
  100425. */
  100426. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100427. /**
  100428. * Rebuilds the elements related to this component in case of
  100429. * context lost for instance.
  100430. */
  100431. rebuild(): void;
  100432. /**
  100433. * Disposes the component and the associated ressources.
  100434. */
  100435. dispose(): void;
  100436. }
  100437. }
  100438. declare module BABYLON {
  100439. /**
  100440. * Renders a layer on top of an existing scene
  100441. */
  100442. export class UtilityLayerRenderer implements IDisposable {
  100443. /** the original scene that will be rendered on top of */
  100444. originalScene: Scene;
  100445. private _pointerCaptures;
  100446. private _lastPointerEvents;
  100447. private static _DefaultUtilityLayer;
  100448. private static _DefaultKeepDepthUtilityLayer;
  100449. private _sharedGizmoLight;
  100450. /**
  100451. * @hidden
  100452. * Light which used by gizmos to get light shading
  100453. */
  100454. _getSharedGizmoLight(): HemisphericLight;
  100455. /**
  100456. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100457. */
  100458. pickUtilitySceneFirst: boolean;
  100459. /**
  100460. * 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)
  100461. */
  100462. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100463. /**
  100464. * 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)
  100465. */
  100466. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100467. /**
  100468. * The scene that is rendered on top of the original scene
  100469. */
  100470. utilityLayerScene: Scene;
  100471. /**
  100472. * If the utility layer should automatically be rendered on top of existing scene
  100473. */
  100474. shouldRender: boolean;
  100475. /**
  100476. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100477. */
  100478. onlyCheckPointerDownEvents: boolean;
  100479. /**
  100480. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100481. */
  100482. processAllEvents: boolean;
  100483. /**
  100484. * Observable raised when the pointer move from the utility layer scene to the main scene
  100485. */
  100486. onPointerOutObservable: Observable<number>;
  100487. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100488. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100489. private _afterRenderObserver;
  100490. private _sceneDisposeObserver;
  100491. private _originalPointerObserver;
  100492. /**
  100493. * Instantiates a UtilityLayerRenderer
  100494. * @param originalScene the original scene that will be rendered on top of
  100495. * @param handleEvents boolean indicating if the utility layer should handle events
  100496. */
  100497. constructor(
  100498. /** the original scene that will be rendered on top of */
  100499. originalScene: Scene, handleEvents?: boolean);
  100500. private _notifyObservers;
  100501. /**
  100502. * Renders the utility layers scene on top of the original scene
  100503. */
  100504. render(): void;
  100505. /**
  100506. * Disposes of the renderer
  100507. */
  100508. dispose(): void;
  100509. private _updateCamera;
  100510. }
  100511. }
  100512. declare module BABYLON {
  100513. /**
  100514. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100515. */
  100516. export class Gizmo implements IDisposable {
  100517. /** The utility layer the gizmo will be added to */
  100518. gizmoLayer: UtilityLayerRenderer;
  100519. /**
  100520. * The root mesh of the gizmo
  100521. */
  100522. _rootMesh: Mesh;
  100523. private _attachedMesh;
  100524. /**
  100525. * Ratio for the scale of the gizmo (Default: 1)
  100526. */
  100527. scaleRatio: number;
  100528. /**
  100529. * If a custom mesh has been set (Default: false)
  100530. */
  100531. protected _customMeshSet: boolean;
  100532. /**
  100533. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100534. * * When set, interactions will be enabled
  100535. */
  100536. attachedMesh: Nullable<AbstractMesh>;
  100537. /**
  100538. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100539. * @param mesh The mesh to replace the default mesh of the gizmo
  100540. */
  100541. setCustomMesh(mesh: Mesh): void;
  100542. /**
  100543. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100544. */
  100545. updateGizmoRotationToMatchAttachedMesh: boolean;
  100546. /**
  100547. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100548. */
  100549. updateGizmoPositionToMatchAttachedMesh: boolean;
  100550. /**
  100551. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100552. */
  100553. protected _updateScale: boolean;
  100554. protected _interactionsEnabled: boolean;
  100555. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100556. private _beforeRenderObserver;
  100557. private _tempVector;
  100558. /**
  100559. * Creates a gizmo
  100560. * @param gizmoLayer The utility layer the gizmo will be added to
  100561. */
  100562. constructor(
  100563. /** The utility layer the gizmo will be added to */
  100564. gizmoLayer?: UtilityLayerRenderer);
  100565. /**
  100566. * Updates the gizmo to match the attached mesh's position/rotation
  100567. */
  100568. protected _update(): void;
  100569. /**
  100570. * Disposes of the gizmo
  100571. */
  100572. dispose(): void;
  100573. }
  100574. }
  100575. declare module BABYLON {
  100576. /**
  100577. * Single axis drag gizmo
  100578. */
  100579. export class AxisDragGizmo extends Gizmo {
  100580. /**
  100581. * Drag behavior responsible for the gizmos dragging interactions
  100582. */
  100583. dragBehavior: PointerDragBehavior;
  100584. private _pointerObserver;
  100585. /**
  100586. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100587. */
  100588. snapDistance: number;
  100589. /**
  100590. * Event that fires each time the gizmo snaps to a new location.
  100591. * * snapDistance is the the change in distance
  100592. */
  100593. onSnapObservable: Observable<{
  100594. snapDistance: number;
  100595. }>;
  100596. /** @hidden */
  100597. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100598. /** @hidden */
  100599. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100600. /**
  100601. * Creates an AxisDragGizmo
  100602. * @param gizmoLayer The utility layer the gizmo will be added to
  100603. * @param dragAxis The axis which the gizmo will be able to drag on
  100604. * @param color The color of the gizmo
  100605. */
  100606. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100607. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100608. /**
  100609. * Disposes of the gizmo
  100610. */
  100611. dispose(): void;
  100612. }
  100613. }
  100614. declare module BABYLON.Debug {
  100615. /**
  100616. * The Axes viewer will show 3 axes in a specific point in space
  100617. */
  100618. export class AxesViewer {
  100619. private _xAxis;
  100620. private _yAxis;
  100621. private _zAxis;
  100622. private _scaleLinesFactor;
  100623. private _instanced;
  100624. /**
  100625. * Gets the hosting scene
  100626. */
  100627. scene: Scene;
  100628. /**
  100629. * Gets or sets a number used to scale line length
  100630. */
  100631. scaleLines: number;
  100632. /** Gets the node hierarchy used to render x-axis */
  100633. readonly xAxis: TransformNode;
  100634. /** Gets the node hierarchy used to render y-axis */
  100635. readonly yAxis: TransformNode;
  100636. /** Gets the node hierarchy used to render z-axis */
  100637. readonly zAxis: TransformNode;
  100638. /**
  100639. * Creates a new AxesViewer
  100640. * @param scene defines the hosting scene
  100641. * @param scaleLines defines a number used to scale line length (1 by default)
  100642. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100643. * @param xAxis defines the node hierarchy used to render the x-axis
  100644. * @param yAxis defines the node hierarchy used to render the y-axis
  100645. * @param zAxis defines the node hierarchy used to render the z-axis
  100646. */
  100647. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100648. /**
  100649. * Force the viewer to update
  100650. * @param position defines the position of the viewer
  100651. * @param xaxis defines the x axis of the viewer
  100652. * @param yaxis defines the y axis of the viewer
  100653. * @param zaxis defines the z axis of the viewer
  100654. */
  100655. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100656. /**
  100657. * Creates an instance of this axes viewer.
  100658. * @returns a new axes viewer with instanced meshes
  100659. */
  100660. createInstance(): AxesViewer;
  100661. /** Releases resources */
  100662. dispose(): void;
  100663. private static _SetRenderingGroupId;
  100664. }
  100665. }
  100666. declare module BABYLON.Debug {
  100667. /**
  100668. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100669. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100670. */
  100671. export class BoneAxesViewer extends AxesViewer {
  100672. /**
  100673. * Gets or sets the target mesh where to display the axes viewer
  100674. */
  100675. mesh: Nullable<Mesh>;
  100676. /**
  100677. * Gets or sets the target bone where to display the axes viewer
  100678. */
  100679. bone: Nullable<Bone>;
  100680. /** Gets current position */
  100681. pos: Vector3;
  100682. /** Gets direction of X axis */
  100683. xaxis: Vector3;
  100684. /** Gets direction of Y axis */
  100685. yaxis: Vector3;
  100686. /** Gets direction of Z axis */
  100687. zaxis: Vector3;
  100688. /**
  100689. * Creates a new BoneAxesViewer
  100690. * @param scene defines the hosting scene
  100691. * @param bone defines the target bone
  100692. * @param mesh defines the target mesh
  100693. * @param scaleLines defines a scaling factor for line length (1 by default)
  100694. */
  100695. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100696. /**
  100697. * Force the viewer to update
  100698. */
  100699. update(): void;
  100700. /** Releases resources */
  100701. dispose(): void;
  100702. }
  100703. }
  100704. declare module BABYLON {
  100705. /**
  100706. * Interface used to define scene explorer extensibility option
  100707. */
  100708. export interface IExplorerExtensibilityOption {
  100709. /**
  100710. * Define the option label
  100711. */
  100712. label: string;
  100713. /**
  100714. * Defines the action to execute on click
  100715. */
  100716. action: (entity: any) => void;
  100717. }
  100718. /**
  100719. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100720. */
  100721. export interface IExplorerExtensibilityGroup {
  100722. /**
  100723. * Defines a predicate to test if a given type mut be extended
  100724. */
  100725. predicate: (entity: any) => boolean;
  100726. /**
  100727. * Gets the list of options added to a type
  100728. */
  100729. entries: IExplorerExtensibilityOption[];
  100730. }
  100731. /**
  100732. * Interface used to define the options to use to create the Inspector
  100733. */
  100734. export interface IInspectorOptions {
  100735. /**
  100736. * Display in overlay mode (default: false)
  100737. */
  100738. overlay?: boolean;
  100739. /**
  100740. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100741. */
  100742. globalRoot?: HTMLElement;
  100743. /**
  100744. * Display the Scene explorer
  100745. */
  100746. showExplorer?: boolean;
  100747. /**
  100748. * Display the property inspector
  100749. */
  100750. showInspector?: boolean;
  100751. /**
  100752. * Display in embed mode (both panes on the right)
  100753. */
  100754. embedMode?: boolean;
  100755. /**
  100756. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100757. */
  100758. handleResize?: boolean;
  100759. /**
  100760. * Allow the panes to popup (default: true)
  100761. */
  100762. enablePopup?: boolean;
  100763. /**
  100764. * Allow the panes to be closed by users (default: true)
  100765. */
  100766. enableClose?: boolean;
  100767. /**
  100768. * Optional list of extensibility entries
  100769. */
  100770. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100771. /**
  100772. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100773. */
  100774. inspectorURL?: string;
  100775. }
  100776. interface Scene {
  100777. /**
  100778. * @hidden
  100779. * Backing field
  100780. */
  100781. _debugLayer: DebugLayer;
  100782. /**
  100783. * Gets the debug layer (aka Inspector) associated with the scene
  100784. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100785. */
  100786. debugLayer: DebugLayer;
  100787. }
  100788. /**
  100789. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100790. * what is happening in your scene
  100791. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100792. */
  100793. export class DebugLayer {
  100794. /**
  100795. * Define the url to get the inspector script from.
  100796. * By default it uses the babylonjs CDN.
  100797. * @ignoreNaming
  100798. */
  100799. static InspectorURL: string;
  100800. private _scene;
  100801. private BJSINSPECTOR;
  100802. /**
  100803. * Observable triggered when a property is changed through the inspector.
  100804. */
  100805. onPropertyChangedObservable: Observable<{
  100806. object: any;
  100807. property: string;
  100808. value: any;
  100809. initialValue: any;
  100810. }>;
  100811. /**
  100812. * Instantiates a new debug layer.
  100813. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100814. * what is happening in your scene
  100815. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100816. * @param scene Defines the scene to inspect
  100817. */
  100818. constructor(scene: Scene);
  100819. /** Creates the inspector window. */
  100820. private _createInspector;
  100821. /**
  100822. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100823. * @param entity defines the entity to select
  100824. * @param lineContainerTitle defines the specific block to highlight
  100825. */
  100826. select(entity: any, lineContainerTitle?: string): void;
  100827. /** Get the inspector from bundle or global */
  100828. private _getGlobalInspector;
  100829. /**
  100830. * Get if the inspector is visible or not.
  100831. * @returns true if visible otherwise, false
  100832. */
  100833. isVisible(): boolean;
  100834. /**
  100835. * Hide the inspector and close its window.
  100836. */
  100837. hide(): void;
  100838. /**
  100839. * Launch the debugLayer.
  100840. * @param config Define the configuration of the inspector
  100841. * @return a promise fulfilled when the debug layer is visible
  100842. */
  100843. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100844. }
  100845. }
  100846. declare module BABYLON {
  100847. /**
  100848. * Class containing static functions to help procedurally build meshes
  100849. */
  100850. export class BoxBuilder {
  100851. /**
  100852. * Creates a box mesh
  100853. * * The parameter `size` sets the size (float) of each box side (default 1)
  100854. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100855. * * 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)
  100856. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100860. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100861. * @param name defines the name of the mesh
  100862. * @param options defines the options used to create the mesh
  100863. * @param scene defines the hosting scene
  100864. * @returns the box mesh
  100865. */
  100866. static CreateBox(name: string, options: {
  100867. size?: number;
  100868. width?: number;
  100869. height?: number;
  100870. depth?: number;
  100871. faceUV?: Vector4[];
  100872. faceColors?: Color4[];
  100873. sideOrientation?: number;
  100874. frontUVs?: Vector4;
  100875. backUVs?: Vector4;
  100876. wrap?: boolean;
  100877. topBaseAt?: number;
  100878. bottomBaseAt?: number;
  100879. updatable?: boolean;
  100880. }, scene?: Nullable<Scene>): Mesh;
  100881. }
  100882. }
  100883. declare module BABYLON {
  100884. /**
  100885. * Class containing static functions to help procedurally build meshes
  100886. */
  100887. export class SphereBuilder {
  100888. /**
  100889. * Creates a sphere mesh
  100890. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100891. * * 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`)
  100892. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100893. * * 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
  100894. * * 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)
  100895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100898. * @param name defines the name of the mesh
  100899. * @param options defines the options used to create the mesh
  100900. * @param scene defines the hosting scene
  100901. * @returns the sphere mesh
  100902. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100903. */
  100904. static CreateSphere(name: string, options: {
  100905. segments?: number;
  100906. diameter?: number;
  100907. diameterX?: number;
  100908. diameterY?: number;
  100909. diameterZ?: number;
  100910. arc?: number;
  100911. slice?: number;
  100912. sideOrientation?: number;
  100913. frontUVs?: Vector4;
  100914. backUVs?: Vector4;
  100915. updatable?: boolean;
  100916. }, scene: any): Mesh;
  100917. }
  100918. }
  100919. declare module BABYLON.Debug {
  100920. /**
  100921. * Used to show the physics impostor around the specific mesh
  100922. */
  100923. export class PhysicsViewer {
  100924. /** @hidden */
  100925. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100926. /** @hidden */
  100927. protected _meshes: Array<Nullable<AbstractMesh>>;
  100928. /** @hidden */
  100929. protected _scene: Nullable<Scene>;
  100930. /** @hidden */
  100931. protected _numMeshes: number;
  100932. /** @hidden */
  100933. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100934. private _renderFunction;
  100935. private _utilityLayer;
  100936. private _debugBoxMesh;
  100937. private _debugSphereMesh;
  100938. private _debugCylinderMesh;
  100939. private _debugMaterial;
  100940. private _debugMeshMeshes;
  100941. /**
  100942. * Creates a new PhysicsViewer
  100943. * @param scene defines the hosting scene
  100944. */
  100945. constructor(scene: Scene);
  100946. /** @hidden */
  100947. protected _updateDebugMeshes(): void;
  100948. /**
  100949. * Renders a specified physic impostor
  100950. * @param impostor defines the impostor to render
  100951. * @param targetMesh defines the mesh represented by the impostor
  100952. * @returns the new debug mesh used to render the impostor
  100953. */
  100954. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100955. /**
  100956. * Hides a specified physic impostor
  100957. * @param impostor defines the impostor to hide
  100958. */
  100959. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100960. private _getDebugMaterial;
  100961. private _getDebugBoxMesh;
  100962. private _getDebugSphereMesh;
  100963. private _getDebugCylinderMesh;
  100964. private _getDebugMeshMesh;
  100965. private _getDebugMesh;
  100966. /** Releases all resources */
  100967. dispose(): void;
  100968. }
  100969. }
  100970. declare module BABYLON {
  100971. /**
  100972. * Class containing static functions to help procedurally build meshes
  100973. */
  100974. export class LinesBuilder {
  100975. /**
  100976. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100977. * * 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
  100978. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100979. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100980. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100981. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100982. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100983. * * 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
  100984. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100987. * @param name defines the name of the new line system
  100988. * @param options defines the options used to create the line system
  100989. * @param scene defines the hosting scene
  100990. * @returns a new line system mesh
  100991. */
  100992. static CreateLineSystem(name: string, options: {
  100993. lines: Vector3[][];
  100994. updatable?: boolean;
  100995. instance?: Nullable<LinesMesh>;
  100996. colors?: Nullable<Color4[][]>;
  100997. useVertexAlpha?: boolean;
  100998. }, scene: Nullable<Scene>): LinesMesh;
  100999. /**
  101000. * Creates a line mesh
  101001. * 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
  101002. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101003. * * The parameter `points` is an array successive Vector3
  101004. * * 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
  101005. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101006. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101007. * * When updating an instance, remember that only point positions can change, not the number of points
  101008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101009. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101010. * @param name defines the name of the new line system
  101011. * @param options defines the options used to create the line system
  101012. * @param scene defines the hosting scene
  101013. * @returns a new line mesh
  101014. */
  101015. static CreateLines(name: string, options: {
  101016. points: Vector3[];
  101017. updatable?: boolean;
  101018. instance?: Nullable<LinesMesh>;
  101019. colors?: Color4[];
  101020. useVertexAlpha?: boolean;
  101021. }, scene?: Nullable<Scene>): LinesMesh;
  101022. /**
  101023. * Creates a dashed line mesh
  101024. * * 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
  101025. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101026. * * The parameter `points` is an array successive Vector3
  101027. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101028. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101029. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101030. * * 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
  101031. * * When updating an instance, remember that only point positions can change, not the number of points
  101032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101033. * @param name defines the name of the mesh
  101034. * @param options defines the options used to create the mesh
  101035. * @param scene defines the hosting scene
  101036. * @returns the dashed line mesh
  101037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101038. */
  101039. static CreateDashedLines(name: string, options: {
  101040. points: Vector3[];
  101041. dashSize?: number;
  101042. gapSize?: number;
  101043. dashNb?: number;
  101044. updatable?: boolean;
  101045. instance?: LinesMesh;
  101046. }, scene?: Nullable<Scene>): LinesMesh;
  101047. }
  101048. }
  101049. declare module BABYLON {
  101050. /**
  101051. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101052. * in order to better appreciate the issue one might have.
  101053. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101054. */
  101055. export class RayHelper {
  101056. /**
  101057. * Defines the ray we are currently tryin to visualize.
  101058. */
  101059. ray: Nullable<Ray>;
  101060. private _renderPoints;
  101061. private _renderLine;
  101062. private _renderFunction;
  101063. private _scene;
  101064. private _updateToMeshFunction;
  101065. private _attachedToMesh;
  101066. private _meshSpaceDirection;
  101067. private _meshSpaceOrigin;
  101068. /**
  101069. * Helper function to create a colored helper in a scene in one line.
  101070. * @param ray Defines the ray we are currently tryin to visualize
  101071. * @param scene Defines the scene the ray is used in
  101072. * @param color Defines the color we want to see the ray in
  101073. * @returns The newly created ray helper.
  101074. */
  101075. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101076. /**
  101077. * Instantiate a new ray helper.
  101078. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101079. * in order to better appreciate the issue one might have.
  101080. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101081. * @param ray Defines the ray we are currently tryin to visualize
  101082. */
  101083. constructor(ray: Ray);
  101084. /**
  101085. * Shows the ray we are willing to debug.
  101086. * @param scene Defines the scene the ray needs to be rendered in
  101087. * @param color Defines the color the ray needs to be rendered in
  101088. */
  101089. show(scene: Scene, color?: Color3): void;
  101090. /**
  101091. * Hides the ray we are debugging.
  101092. */
  101093. hide(): void;
  101094. private _render;
  101095. /**
  101096. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101097. * @param mesh Defines the mesh we want the helper attached to
  101098. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101099. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101100. * @param length Defines the length of the ray
  101101. */
  101102. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101103. /**
  101104. * Detach the ray helper from the mesh it has previously been attached to.
  101105. */
  101106. detachFromMesh(): void;
  101107. private _updateToMesh;
  101108. /**
  101109. * Dispose the helper and release its associated resources.
  101110. */
  101111. dispose(): void;
  101112. }
  101113. }
  101114. declare module BABYLON.Debug {
  101115. /**
  101116. * Class used to render a debug view of a given skeleton
  101117. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101118. */
  101119. export class SkeletonViewer {
  101120. /** defines the skeleton to render */
  101121. skeleton: Skeleton;
  101122. /** defines the mesh attached to the skeleton */
  101123. mesh: AbstractMesh;
  101124. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101125. autoUpdateBonesMatrices: boolean;
  101126. /** defines the rendering group id to use with the viewer */
  101127. renderingGroupId: number;
  101128. /** Gets or sets the color used to render the skeleton */
  101129. color: Color3;
  101130. private _scene;
  101131. private _debugLines;
  101132. private _debugMesh;
  101133. private _isEnabled;
  101134. private _renderFunction;
  101135. private _utilityLayer;
  101136. /**
  101137. * Returns the mesh used to render the bones
  101138. */
  101139. readonly debugMesh: Nullable<LinesMesh>;
  101140. /**
  101141. * Creates a new SkeletonViewer
  101142. * @param skeleton defines the skeleton to render
  101143. * @param mesh defines the mesh attached to the skeleton
  101144. * @param scene defines the hosting scene
  101145. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101146. * @param renderingGroupId defines the rendering group id to use with the viewer
  101147. */
  101148. constructor(
  101149. /** defines the skeleton to render */
  101150. skeleton: Skeleton,
  101151. /** defines the mesh attached to the skeleton */
  101152. mesh: AbstractMesh, scene: Scene,
  101153. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101154. autoUpdateBonesMatrices?: boolean,
  101155. /** defines the rendering group id to use with the viewer */
  101156. renderingGroupId?: number);
  101157. /** Gets or sets a boolean indicating if the viewer is enabled */
  101158. isEnabled: boolean;
  101159. private _getBonePosition;
  101160. private _getLinesForBonesWithLength;
  101161. private _getLinesForBonesNoLength;
  101162. /** Update the viewer to sync with current skeleton state */
  101163. update(): void;
  101164. /** Release associated resources */
  101165. dispose(): void;
  101166. }
  101167. }
  101168. declare module BABYLON {
  101169. /**
  101170. * Options to create the null engine
  101171. */
  101172. export class NullEngineOptions {
  101173. /**
  101174. * Render width (Default: 512)
  101175. */
  101176. renderWidth: number;
  101177. /**
  101178. * Render height (Default: 256)
  101179. */
  101180. renderHeight: number;
  101181. /**
  101182. * Texture size (Default: 512)
  101183. */
  101184. textureSize: number;
  101185. /**
  101186. * If delta time between frames should be constant
  101187. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101188. */
  101189. deterministicLockstep: boolean;
  101190. /**
  101191. * Maximum about of steps between frames (Default: 4)
  101192. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101193. */
  101194. lockstepMaxSteps: number;
  101195. }
  101196. /**
  101197. * The null engine class provides support for headless version of babylon.js.
  101198. * This can be used in server side scenario or for testing purposes
  101199. */
  101200. export class NullEngine extends Engine {
  101201. private _options;
  101202. /**
  101203. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101204. */
  101205. isDeterministicLockStep(): boolean;
  101206. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101207. getLockstepMaxSteps(): number;
  101208. /**
  101209. * Sets hardware scaling, used to save performance if needed
  101210. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101211. */
  101212. getHardwareScalingLevel(): number;
  101213. constructor(options?: NullEngineOptions);
  101214. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101215. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101216. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101217. getRenderWidth(useScreen?: boolean): number;
  101218. getRenderHeight(useScreen?: boolean): number;
  101219. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101220. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101221. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101222. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101223. bindSamplers(effect: Effect): void;
  101224. enableEffect(effect: Effect): void;
  101225. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101226. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101227. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101228. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101229. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101230. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101231. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101232. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101233. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101234. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101235. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101236. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101237. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101238. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101239. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101240. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101241. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101242. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101243. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101244. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101245. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101246. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101247. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101248. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101249. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101250. bindBuffers(vertexBuffers: {
  101251. [key: string]: VertexBuffer;
  101252. }, indexBuffer: DataBuffer, effect: Effect): void;
  101253. wipeCaches(bruteForce?: boolean): void;
  101254. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101255. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101256. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101257. /** @hidden */
  101258. _createTexture(): WebGLTexture;
  101259. /** @hidden */
  101260. _releaseTexture(texture: InternalTexture): void;
  101261. 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;
  101262. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101263. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101264. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101265. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101266. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101267. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101268. areAllEffectsReady(): boolean;
  101269. /**
  101270. * @hidden
  101271. * Get the current error code of the webGL context
  101272. * @returns the error code
  101273. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101274. */
  101275. getError(): number;
  101276. /** @hidden */
  101277. _getUnpackAlignement(): number;
  101278. /** @hidden */
  101279. _unpackFlipY(value: boolean): void;
  101280. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101281. /**
  101282. * Updates a dynamic vertex buffer.
  101283. * @param vertexBuffer the vertex buffer to update
  101284. * @param data the data used to update the vertex buffer
  101285. * @param byteOffset the byte offset of the data (optional)
  101286. * @param byteLength the byte length of the data (optional)
  101287. */
  101288. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101289. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101290. /** @hidden */
  101291. _bindTexture(channel: number, texture: InternalTexture): void;
  101292. /** @hidden */
  101293. _releaseBuffer(buffer: DataBuffer): boolean;
  101294. releaseEffects(): void;
  101295. displayLoadingUI(): void;
  101296. hideLoadingUI(): void;
  101297. /** @hidden */
  101298. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101299. /** @hidden */
  101300. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101301. /** @hidden */
  101302. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101303. /** @hidden */
  101304. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101305. }
  101306. }
  101307. declare module BABYLON {
  101308. /** @hidden */
  101309. export class _OcclusionDataStorage {
  101310. /** @hidden */
  101311. occlusionInternalRetryCounter: number;
  101312. /** @hidden */
  101313. isOcclusionQueryInProgress: boolean;
  101314. /** @hidden */
  101315. isOccluded: boolean;
  101316. /** @hidden */
  101317. occlusionRetryCount: number;
  101318. /** @hidden */
  101319. occlusionType: number;
  101320. /** @hidden */
  101321. occlusionQueryAlgorithmType: number;
  101322. }
  101323. interface Engine {
  101324. /**
  101325. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101326. * @return the new query
  101327. */
  101328. createQuery(): WebGLQuery;
  101329. /**
  101330. * Delete and release a webGL query
  101331. * @param query defines the query to delete
  101332. * @return the current engine
  101333. */
  101334. deleteQuery(query: WebGLQuery): Engine;
  101335. /**
  101336. * Check if a given query has resolved and got its value
  101337. * @param query defines the query to check
  101338. * @returns true if the query got its value
  101339. */
  101340. isQueryResultAvailable(query: WebGLQuery): boolean;
  101341. /**
  101342. * Gets the value of a given query
  101343. * @param query defines the query to check
  101344. * @returns the value of the query
  101345. */
  101346. getQueryResult(query: WebGLQuery): number;
  101347. /**
  101348. * Initiates an occlusion query
  101349. * @param algorithmType defines the algorithm to use
  101350. * @param query defines the query to use
  101351. * @returns the current engine
  101352. * @see http://doc.babylonjs.com/features/occlusionquery
  101353. */
  101354. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101355. /**
  101356. * Ends an occlusion query
  101357. * @see http://doc.babylonjs.com/features/occlusionquery
  101358. * @param algorithmType defines the algorithm to use
  101359. * @returns the current engine
  101360. */
  101361. endOcclusionQuery(algorithmType: number): Engine;
  101362. /**
  101363. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101364. * Please note that only one query can be issued at a time
  101365. * @returns a time token used to track the time span
  101366. */
  101367. startTimeQuery(): Nullable<_TimeToken>;
  101368. /**
  101369. * Ends a time query
  101370. * @param token defines the token used to measure the time span
  101371. * @returns the time spent (in ns)
  101372. */
  101373. endTimeQuery(token: _TimeToken): int;
  101374. /** @hidden */
  101375. _currentNonTimestampToken: Nullable<_TimeToken>;
  101376. /** @hidden */
  101377. _createTimeQuery(): WebGLQuery;
  101378. /** @hidden */
  101379. _deleteTimeQuery(query: WebGLQuery): void;
  101380. /** @hidden */
  101381. _getGlAlgorithmType(algorithmType: number): number;
  101382. /** @hidden */
  101383. _getTimeQueryResult(query: WebGLQuery): any;
  101384. /** @hidden */
  101385. _getTimeQueryAvailability(query: WebGLQuery): any;
  101386. }
  101387. interface AbstractMesh {
  101388. /**
  101389. * Backing filed
  101390. * @hidden
  101391. */
  101392. __occlusionDataStorage: _OcclusionDataStorage;
  101393. /**
  101394. * Access property
  101395. * @hidden
  101396. */
  101397. _occlusionDataStorage: _OcclusionDataStorage;
  101398. /**
  101399. * 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.
  101400. * The default value is -1 which means don't break the query and wait till the result
  101401. * @see http://doc.babylonjs.com/features/occlusionquery
  101402. */
  101403. occlusionRetryCount: number;
  101404. /**
  101405. * 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:
  101406. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101407. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101408. * * 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.
  101409. * @see http://doc.babylonjs.com/features/occlusionquery
  101410. */
  101411. occlusionType: number;
  101412. /**
  101413. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101414. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101415. * * 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.
  101416. * @see http://doc.babylonjs.com/features/occlusionquery
  101417. */
  101418. occlusionQueryAlgorithmType: number;
  101419. /**
  101420. * 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
  101421. * @see http://doc.babylonjs.com/features/occlusionquery
  101422. */
  101423. isOccluded: boolean;
  101424. /**
  101425. * Flag to check the progress status of the query
  101426. * @see http://doc.babylonjs.com/features/occlusionquery
  101427. */
  101428. isOcclusionQueryInProgress: boolean;
  101429. }
  101430. }
  101431. declare module BABYLON {
  101432. /** @hidden */
  101433. export var _forceTransformFeedbackToBundle: boolean;
  101434. interface Engine {
  101435. /**
  101436. * Creates a webGL transform feedback object
  101437. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101438. * @returns the webGL transform feedback object
  101439. */
  101440. createTransformFeedback(): WebGLTransformFeedback;
  101441. /**
  101442. * Delete a webGL transform feedback object
  101443. * @param value defines the webGL transform feedback object to delete
  101444. */
  101445. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101446. /**
  101447. * Bind a webGL transform feedback object to the webgl context
  101448. * @param value defines the webGL transform feedback object to bind
  101449. */
  101450. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101451. /**
  101452. * Begins a transform feedback operation
  101453. * @param usePoints defines if points or triangles must be used
  101454. */
  101455. beginTransformFeedback(usePoints: boolean): void;
  101456. /**
  101457. * Ends a transform feedback operation
  101458. */
  101459. endTransformFeedback(): void;
  101460. /**
  101461. * Specify the varyings to use with transform feedback
  101462. * @param program defines the associated webGL program
  101463. * @param value defines the list of strings representing the varying names
  101464. */
  101465. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101466. /**
  101467. * Bind a webGL buffer for a transform feedback operation
  101468. * @param value defines the webGL buffer to bind
  101469. */
  101470. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  101471. }
  101472. }
  101473. declare module BABYLON {
  101474. /**
  101475. * Creation options of the multi render target texture.
  101476. */
  101477. export interface IMultiRenderTargetOptions {
  101478. /**
  101479. * Define if the texture needs to create mip maps after render.
  101480. */
  101481. generateMipMaps?: boolean;
  101482. /**
  101483. * Define the types of all the draw buffers we want to create
  101484. */
  101485. types?: number[];
  101486. /**
  101487. * Define the sampling modes of all the draw buffers we want to create
  101488. */
  101489. samplingModes?: number[];
  101490. /**
  101491. * Define if a depth buffer is required
  101492. */
  101493. generateDepthBuffer?: boolean;
  101494. /**
  101495. * Define if a stencil buffer is required
  101496. */
  101497. generateStencilBuffer?: boolean;
  101498. /**
  101499. * Define if a depth texture is required instead of a depth buffer
  101500. */
  101501. generateDepthTexture?: boolean;
  101502. /**
  101503. * Define the number of desired draw buffers
  101504. */
  101505. textureCount?: number;
  101506. /**
  101507. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101508. */
  101509. doNotChangeAspectRatio?: boolean;
  101510. /**
  101511. * Define the default type of the buffers we are creating
  101512. */
  101513. defaultType?: number;
  101514. }
  101515. /**
  101516. * A multi render target, like a render target provides the ability to render to a texture.
  101517. * Unlike the render target, it can render to several draw buffers in one draw.
  101518. * This is specially interesting in deferred rendering or for any effects requiring more than
  101519. * just one color from a single pass.
  101520. */
  101521. export class MultiRenderTarget extends RenderTargetTexture {
  101522. private _internalTextures;
  101523. private _textures;
  101524. private _multiRenderTargetOptions;
  101525. /**
  101526. * Get if draw buffers are currently supported by the used hardware and browser.
  101527. */
  101528. readonly isSupported: boolean;
  101529. /**
  101530. * Get the list of textures generated by the multi render target.
  101531. */
  101532. readonly textures: Texture[];
  101533. /**
  101534. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101535. */
  101536. readonly depthTexture: Texture;
  101537. /**
  101538. * Set the wrapping mode on U of all the textures we are rendering to.
  101539. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101540. */
  101541. wrapU: number;
  101542. /**
  101543. * Set the wrapping mode on V of all the textures we are rendering to.
  101544. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101545. */
  101546. wrapV: number;
  101547. /**
  101548. * Instantiate a new multi render target texture.
  101549. * A multi render target, like a render target provides the ability to render to a texture.
  101550. * Unlike the render target, it can render to several draw buffers in one draw.
  101551. * This is specially interesting in deferred rendering or for any effects requiring more than
  101552. * just one color from a single pass.
  101553. * @param name Define the name of the texture
  101554. * @param size Define the size of the buffers to render to
  101555. * @param count Define the number of target we are rendering into
  101556. * @param scene Define the scene the texture belongs to
  101557. * @param options Define the options used to create the multi render target
  101558. */
  101559. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101560. /** @hidden */
  101561. _rebuild(): void;
  101562. private _createInternalTextures;
  101563. private _createTextures;
  101564. /**
  101565. * Define the number of samples used if MSAA is enabled.
  101566. */
  101567. samples: number;
  101568. /**
  101569. * Resize all the textures in the multi render target.
  101570. * Be carrefull as it will recreate all the data in the new texture.
  101571. * @param size Define the new size
  101572. */
  101573. resize(size: any): void;
  101574. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101575. /**
  101576. * Dispose the render targets and their associated resources
  101577. */
  101578. dispose(): void;
  101579. /**
  101580. * Release all the underlying texture used as draw buffers.
  101581. */
  101582. releaseInternalTextures(): void;
  101583. }
  101584. }
  101585. declare module BABYLON {
  101586. interface Engine {
  101587. /**
  101588. * Unbind a list of render target textures from the webGL context
  101589. * This is used only when drawBuffer extension or webGL2 are active
  101590. * @param textures defines the render target textures to unbind
  101591. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101592. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101593. */
  101594. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101595. /**
  101596. * Create a multi render target texture
  101597. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101598. * @param size defines the size of the texture
  101599. * @param options defines the creation options
  101600. * @returns the cube texture as an InternalTexture
  101601. */
  101602. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101603. /**
  101604. * Update the sample count for a given multiple render target texture
  101605. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101606. * @param textures defines the textures to update
  101607. * @param samples defines the sample count to set
  101608. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101609. */
  101610. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101611. }
  101612. }
  101613. declare module BABYLON {
  101614. /**
  101615. * Gather the list of clipboard event types as constants.
  101616. */
  101617. export class ClipboardEventTypes {
  101618. /**
  101619. * The clipboard event is fired when a copy command is active (pressed).
  101620. */
  101621. static readonly COPY: number;
  101622. /**
  101623. * The clipboard event is fired when a cut command is active (pressed).
  101624. */
  101625. static readonly CUT: number;
  101626. /**
  101627. * The clipboard event is fired when a paste command is active (pressed).
  101628. */
  101629. static readonly PASTE: number;
  101630. }
  101631. /**
  101632. * This class is used to store clipboard related info for the onClipboardObservable event.
  101633. */
  101634. export class ClipboardInfo {
  101635. /**
  101636. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101637. */
  101638. type: number;
  101639. /**
  101640. * Defines the related dom event
  101641. */
  101642. event: ClipboardEvent;
  101643. /**
  101644. *Creates an instance of ClipboardInfo.
  101645. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101646. * @param event Defines the related dom event
  101647. */
  101648. constructor(
  101649. /**
  101650. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101651. */
  101652. type: number,
  101653. /**
  101654. * Defines the related dom event
  101655. */
  101656. event: ClipboardEvent);
  101657. /**
  101658. * Get the clipboard event's type from the keycode.
  101659. * @param keyCode Defines the keyCode for the current keyboard event.
  101660. * @return {number}
  101661. */
  101662. static GetTypeFromCharacter(keyCode: number): number;
  101663. }
  101664. }
  101665. declare module BABYLON {
  101666. /**
  101667. * Class used to represent data loading progression
  101668. */
  101669. export class SceneLoaderProgressEvent {
  101670. /** defines if data length to load can be evaluated */
  101671. readonly lengthComputable: boolean;
  101672. /** defines the loaded data length */
  101673. readonly loaded: number;
  101674. /** defines the data length to load */
  101675. readonly total: number;
  101676. /**
  101677. * Create a new progress event
  101678. * @param lengthComputable defines if data length to load can be evaluated
  101679. * @param loaded defines the loaded data length
  101680. * @param total defines the data length to load
  101681. */
  101682. constructor(
  101683. /** defines if data length to load can be evaluated */
  101684. lengthComputable: boolean,
  101685. /** defines the loaded data length */
  101686. loaded: number,
  101687. /** defines the data length to load */
  101688. total: number);
  101689. /**
  101690. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101691. * @param event defines the source event
  101692. * @returns a new SceneLoaderProgressEvent
  101693. */
  101694. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101695. }
  101696. /**
  101697. * Interface used by SceneLoader plugins to define supported file extensions
  101698. */
  101699. export interface ISceneLoaderPluginExtensions {
  101700. /**
  101701. * Defines the list of supported extensions
  101702. */
  101703. [extension: string]: {
  101704. isBinary: boolean;
  101705. };
  101706. }
  101707. /**
  101708. * Interface used by SceneLoader plugin factory
  101709. */
  101710. export interface ISceneLoaderPluginFactory {
  101711. /**
  101712. * Defines the name of the factory
  101713. */
  101714. name: string;
  101715. /**
  101716. * Function called to create a new plugin
  101717. * @return the new plugin
  101718. */
  101719. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101720. /**
  101721. * Boolean indicating if the plugin can direct load specific data
  101722. */
  101723. canDirectLoad?: (data: string) => boolean;
  101724. }
  101725. /**
  101726. * Interface used to define a SceneLoader plugin
  101727. */
  101728. export interface ISceneLoaderPlugin {
  101729. /**
  101730. * The friendly name of this plugin.
  101731. */
  101732. name: string;
  101733. /**
  101734. * The file extensions supported by this plugin.
  101735. */
  101736. extensions: string | ISceneLoaderPluginExtensions;
  101737. /**
  101738. * Import meshes into a scene.
  101739. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101740. * @param scene The scene to import into
  101741. * @param data The data to import
  101742. * @param rootUrl The root url for scene and resources
  101743. * @param meshes The meshes array to import into
  101744. * @param particleSystems The particle systems array to import into
  101745. * @param skeletons The skeletons array to import into
  101746. * @param onError The callback when import fails
  101747. * @returns True if successful or false otherwise
  101748. */
  101749. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101750. /**
  101751. * Load into a scene.
  101752. * @param scene The scene to load into
  101753. * @param data The data to import
  101754. * @param rootUrl The root url for scene and resources
  101755. * @param onError The callback when import fails
  101756. * @returns true if successful or false otherwise
  101757. */
  101758. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101759. /**
  101760. * The callback that returns true if the data can be directly loaded.
  101761. */
  101762. canDirectLoad?: (data: string) => boolean;
  101763. /**
  101764. * The callback that allows custom handling of the root url based on the response url.
  101765. */
  101766. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101767. /**
  101768. * Load into an asset container.
  101769. * @param scene The scene to load into
  101770. * @param data The data to import
  101771. * @param rootUrl The root url for scene and resources
  101772. * @param onError The callback when import fails
  101773. * @returns The loaded asset container
  101774. */
  101775. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101776. }
  101777. /**
  101778. * Interface used to define an async SceneLoader plugin
  101779. */
  101780. export interface ISceneLoaderPluginAsync {
  101781. /**
  101782. * The friendly name of this plugin.
  101783. */
  101784. name: string;
  101785. /**
  101786. * The file extensions supported by this plugin.
  101787. */
  101788. extensions: string | ISceneLoaderPluginExtensions;
  101789. /**
  101790. * Import meshes into a scene.
  101791. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101792. * @param scene The scene to import into
  101793. * @param data The data to import
  101794. * @param rootUrl The root url for scene and resources
  101795. * @param onProgress The callback when the load progresses
  101796. * @param fileName Defines the name of the file to load
  101797. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101798. */
  101799. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101800. meshes: AbstractMesh[];
  101801. particleSystems: IParticleSystem[];
  101802. skeletons: Skeleton[];
  101803. animationGroups: AnimationGroup[];
  101804. }>;
  101805. /**
  101806. * Load into a scene.
  101807. * @param scene The scene to load into
  101808. * @param data The data to import
  101809. * @param rootUrl The root url for scene and resources
  101810. * @param onProgress The callback when the load progresses
  101811. * @param fileName Defines the name of the file to load
  101812. * @returns Nothing
  101813. */
  101814. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101815. /**
  101816. * The callback that returns true if the data can be directly loaded.
  101817. */
  101818. canDirectLoad?: (data: string) => boolean;
  101819. /**
  101820. * The callback that allows custom handling of the root url based on the response url.
  101821. */
  101822. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101823. /**
  101824. * Load into an asset container.
  101825. * @param scene The scene to load into
  101826. * @param data The data to import
  101827. * @param rootUrl The root url for scene and resources
  101828. * @param onProgress The callback when the load progresses
  101829. * @param fileName Defines the name of the file to load
  101830. * @returns The loaded asset container
  101831. */
  101832. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101833. }
  101834. /**
  101835. * Class used to load scene from various file formats using registered plugins
  101836. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101837. */
  101838. export class SceneLoader {
  101839. /**
  101840. * No logging while loading
  101841. */
  101842. static readonly NO_LOGGING: number;
  101843. /**
  101844. * Minimal logging while loading
  101845. */
  101846. static readonly MINIMAL_LOGGING: number;
  101847. /**
  101848. * Summary logging while loading
  101849. */
  101850. static readonly SUMMARY_LOGGING: number;
  101851. /**
  101852. * Detailled logging while loading
  101853. */
  101854. static readonly DETAILED_LOGGING: number;
  101855. /**
  101856. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101857. */
  101858. static ForceFullSceneLoadingForIncremental: boolean;
  101859. /**
  101860. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101861. */
  101862. static ShowLoadingScreen: boolean;
  101863. /**
  101864. * Defines the current logging level (while loading the scene)
  101865. * @ignorenaming
  101866. */
  101867. static loggingLevel: number;
  101868. /**
  101869. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101870. */
  101871. static CleanBoneMatrixWeights: boolean;
  101872. /**
  101873. * Event raised when a plugin is used to load a scene
  101874. */
  101875. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101876. private static _registeredPlugins;
  101877. private static _getDefaultPlugin;
  101878. private static _getPluginForExtension;
  101879. private static _getPluginForDirectLoad;
  101880. private static _getPluginForFilename;
  101881. private static _getDirectLoad;
  101882. private static _loadData;
  101883. private static _getFileInfo;
  101884. /**
  101885. * Gets a plugin that can load the given extension
  101886. * @param extension defines the extension to load
  101887. * @returns a plugin or null if none works
  101888. */
  101889. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101890. /**
  101891. * Gets a boolean indicating that the given extension can be loaded
  101892. * @param extension defines the extension to load
  101893. * @returns true if the extension is supported
  101894. */
  101895. static IsPluginForExtensionAvailable(extension: string): boolean;
  101896. /**
  101897. * Adds a new plugin to the list of registered plugins
  101898. * @param plugin defines the plugin to add
  101899. */
  101900. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101901. /**
  101902. * Import meshes into a scene
  101903. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101904. * @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)
  101905. * @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)
  101906. * @param scene the instance of BABYLON.Scene to append to
  101907. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101908. * @param onProgress a callback with a progress event for each file being loaded
  101909. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101910. * @param pluginExtension the extension used to determine the plugin
  101911. * @returns The loaded plugin
  101912. */
  101913. 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>;
  101914. /**
  101915. * Import meshes into a scene
  101916. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101917. * @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)
  101918. * @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)
  101919. * @param scene the instance of BABYLON.Scene to append to
  101920. * @param onProgress a callback with a progress event for each file being loaded
  101921. * @param pluginExtension the extension used to determine the plugin
  101922. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101923. */
  101924. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101925. meshes: AbstractMesh[];
  101926. particleSystems: IParticleSystem[];
  101927. skeletons: Skeleton[];
  101928. animationGroups: AnimationGroup[];
  101929. }>;
  101930. /**
  101931. * Load a scene
  101932. * @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)
  101933. * @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)
  101934. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101935. * @param onSuccess a callback with the scene when import succeeds
  101936. * @param onProgress a callback with a progress event for each file being loaded
  101937. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101938. * @param pluginExtension the extension used to determine the plugin
  101939. * @returns The loaded plugin
  101940. */
  101941. 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>;
  101942. /**
  101943. * Load a scene
  101944. * @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)
  101945. * @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)
  101946. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101947. * @param onProgress a callback with a progress event for each file being loaded
  101948. * @param pluginExtension the extension used to determine the plugin
  101949. * @returns The loaded scene
  101950. */
  101951. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101952. /**
  101953. * Append a scene
  101954. * @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)
  101955. * @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)
  101956. * @param scene is the instance of BABYLON.Scene to append to
  101957. * @param onSuccess a callback with the scene when import succeeds
  101958. * @param onProgress a callback with a progress event for each file being loaded
  101959. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101960. * @param pluginExtension the extension used to determine the plugin
  101961. * @returns The loaded plugin
  101962. */
  101963. 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>;
  101964. /**
  101965. * Append a scene
  101966. * @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)
  101967. * @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)
  101968. * @param scene is the instance of BABYLON.Scene to append to
  101969. * @param onProgress a callback with a progress event for each file being loaded
  101970. * @param pluginExtension the extension used to determine the plugin
  101971. * @returns The given scene
  101972. */
  101973. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101974. /**
  101975. * Load a scene into an asset container
  101976. * @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)
  101977. * @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)
  101978. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101979. * @param onSuccess a callback with the scene when import succeeds
  101980. * @param onProgress a callback with a progress event for each file being loaded
  101981. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101982. * @param pluginExtension the extension used to determine the plugin
  101983. * @returns The loaded plugin
  101984. */
  101985. 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>;
  101986. /**
  101987. * Load a scene into an asset container
  101988. * @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)
  101989. * @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)
  101990. * @param scene is the instance of Scene to append to
  101991. * @param onProgress a callback with a progress event for each file being loaded
  101992. * @param pluginExtension the extension used to determine the plugin
  101993. * @returns The loaded asset container
  101994. */
  101995. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101996. }
  101997. }
  101998. declare module BABYLON {
  101999. /**
  102000. * Google Daydream controller
  102001. */
  102002. export class DaydreamController extends WebVRController {
  102003. /**
  102004. * Base Url for the controller model.
  102005. */
  102006. static MODEL_BASE_URL: string;
  102007. /**
  102008. * File name for the controller model.
  102009. */
  102010. static MODEL_FILENAME: string;
  102011. /**
  102012. * Gamepad Id prefix used to identify Daydream Controller.
  102013. */
  102014. static readonly GAMEPAD_ID_PREFIX: string;
  102015. /**
  102016. * Creates a new DaydreamController from a gamepad
  102017. * @param vrGamepad the gamepad that the controller should be created from
  102018. */
  102019. constructor(vrGamepad: any);
  102020. /**
  102021. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102022. * @param scene scene in which to add meshes
  102023. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102024. */
  102025. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102026. /**
  102027. * Called once for each button that changed state since the last frame
  102028. * @param buttonIdx Which button index changed
  102029. * @param state New state of the button
  102030. * @param changes Which properties on the state changed since last frame
  102031. */
  102032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102033. }
  102034. }
  102035. declare module BABYLON {
  102036. /**
  102037. * Gear VR Controller
  102038. */
  102039. export class GearVRController extends WebVRController {
  102040. /**
  102041. * Base Url for the controller model.
  102042. */
  102043. static MODEL_BASE_URL: string;
  102044. /**
  102045. * File name for the controller model.
  102046. */
  102047. static MODEL_FILENAME: string;
  102048. /**
  102049. * Gamepad Id prefix used to identify this controller.
  102050. */
  102051. static readonly GAMEPAD_ID_PREFIX: string;
  102052. private readonly _buttonIndexToObservableNameMap;
  102053. /**
  102054. * Creates a new GearVRController from a gamepad
  102055. * @param vrGamepad the gamepad that the controller should be created from
  102056. */
  102057. constructor(vrGamepad: any);
  102058. /**
  102059. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102060. * @param scene scene in which to add meshes
  102061. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102062. */
  102063. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102064. /**
  102065. * Called once for each button that changed state since the last frame
  102066. * @param buttonIdx Which button index changed
  102067. * @param state New state of the button
  102068. * @param changes Which properties on the state changed since last frame
  102069. */
  102070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102071. }
  102072. }
  102073. declare module BABYLON {
  102074. /**
  102075. * Generic Controller
  102076. */
  102077. export class GenericController extends WebVRController {
  102078. /**
  102079. * Base Url for the controller model.
  102080. */
  102081. static readonly MODEL_BASE_URL: string;
  102082. /**
  102083. * File name for the controller model.
  102084. */
  102085. static readonly MODEL_FILENAME: string;
  102086. /**
  102087. * Creates a new GenericController from a gamepad
  102088. * @param vrGamepad the gamepad that the controller should be created from
  102089. */
  102090. constructor(vrGamepad: any);
  102091. /**
  102092. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102093. * @param scene scene in which to add meshes
  102094. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102095. */
  102096. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102097. /**
  102098. * Called once for each button that changed state since the last frame
  102099. * @param buttonIdx Which button index changed
  102100. * @param state New state of the button
  102101. * @param changes Which properties on the state changed since last frame
  102102. */
  102103. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102104. }
  102105. }
  102106. declare module BABYLON {
  102107. /**
  102108. * Oculus Touch Controller
  102109. */
  102110. export class OculusTouchController extends WebVRController {
  102111. /**
  102112. * Base Url for the controller model.
  102113. */
  102114. static MODEL_BASE_URL: string;
  102115. /**
  102116. * File name for the left controller model.
  102117. */
  102118. static MODEL_LEFT_FILENAME: string;
  102119. /**
  102120. * File name for the right controller model.
  102121. */
  102122. static MODEL_RIGHT_FILENAME: string;
  102123. /**
  102124. * Fired when the secondary trigger on this controller is modified
  102125. */
  102126. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102127. /**
  102128. * Fired when the thumb rest on this controller is modified
  102129. */
  102130. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102131. /**
  102132. * Creates a new OculusTouchController from a gamepad
  102133. * @param vrGamepad the gamepad that the controller should be created from
  102134. */
  102135. constructor(vrGamepad: any);
  102136. /**
  102137. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102138. * @param scene scene in which to add meshes
  102139. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102140. */
  102141. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102142. /**
  102143. * Fired when the A button on this controller is modified
  102144. */
  102145. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102146. /**
  102147. * Fired when the B button on this controller is modified
  102148. */
  102149. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102150. /**
  102151. * Fired when the X button on this controller is modified
  102152. */
  102153. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102154. /**
  102155. * Fired when the Y button on this controller is modified
  102156. */
  102157. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102158. /**
  102159. * Called once for each button that changed state since the last frame
  102160. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102161. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102162. * 2) secondary trigger (same)
  102163. * 3) A (right) X (left), touch, pressed = value
  102164. * 4) B / Y
  102165. * 5) thumb rest
  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. * Vive Controller
  102176. */
  102177. export class ViveController extends WebVRController {
  102178. /**
  102179. * Base Url for the controller model.
  102180. */
  102181. static MODEL_BASE_URL: string;
  102182. /**
  102183. * File name for the controller model.
  102184. */
  102185. static MODEL_FILENAME: string;
  102186. /**
  102187. * Creates a new ViveController from a gamepad
  102188. * @param vrGamepad the gamepad that the controller should be created from
  102189. */
  102190. constructor(vrGamepad: any);
  102191. /**
  102192. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102193. * @param scene scene in which to add meshes
  102194. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102195. */
  102196. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102197. /**
  102198. * Fired when the left button on this controller is modified
  102199. */
  102200. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102201. /**
  102202. * Fired when the right button on this controller is modified
  102203. */
  102204. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102205. /**
  102206. * Fired when the menu button on this controller is modified
  102207. */
  102208. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102209. /**
  102210. * Called once for each button that changed state since the last frame
  102211. * Vive mapping:
  102212. * 0: touchpad
  102213. * 1: trigger
  102214. * 2: left AND right buttons
  102215. * 3: menu button
  102216. * @param buttonIdx Which button index changed
  102217. * @param state New state of the button
  102218. * @param changes Which properties on the state changed since last frame
  102219. */
  102220. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102221. }
  102222. }
  102223. declare module BABYLON {
  102224. /**
  102225. * Defines the WindowsMotionController object that the state of the windows motion controller
  102226. */
  102227. export class WindowsMotionController extends WebVRController {
  102228. /**
  102229. * The base url used to load the left and right controller models
  102230. */
  102231. static MODEL_BASE_URL: string;
  102232. /**
  102233. * The name of the left controller model file
  102234. */
  102235. static MODEL_LEFT_FILENAME: string;
  102236. /**
  102237. * The name of the right controller model file
  102238. */
  102239. static MODEL_RIGHT_FILENAME: string;
  102240. /**
  102241. * The controller name prefix for this controller type
  102242. */
  102243. static readonly GAMEPAD_ID_PREFIX: string;
  102244. /**
  102245. * The controller id pattern for this controller type
  102246. */
  102247. private static readonly GAMEPAD_ID_PATTERN;
  102248. private _loadedMeshInfo;
  102249. private readonly _mapping;
  102250. /**
  102251. * Fired when the trackpad on this controller is clicked
  102252. */
  102253. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102254. /**
  102255. * Fired when the trackpad on this controller is modified
  102256. */
  102257. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102258. /**
  102259. * The current x and y values of this controller's trackpad
  102260. */
  102261. trackpad: StickValues;
  102262. /**
  102263. * Creates a new WindowsMotionController from a gamepad
  102264. * @param vrGamepad the gamepad that the controller should be created from
  102265. */
  102266. constructor(vrGamepad: any);
  102267. /**
  102268. * Fired when the trigger on this controller is modified
  102269. */
  102270. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102271. /**
  102272. * Fired when the menu button on this controller is modified
  102273. */
  102274. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102275. /**
  102276. * Fired when the grip button on this controller is modified
  102277. */
  102278. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102279. /**
  102280. * Fired when the thumbstick button on this controller is modified
  102281. */
  102282. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102283. /**
  102284. * Fired when the touchpad button on this controller is modified
  102285. */
  102286. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102287. /**
  102288. * Fired when the touchpad values on this controller are modified
  102289. */
  102290. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102291. private _updateTrackpad;
  102292. /**
  102293. * Called once per frame by the engine.
  102294. */
  102295. update(): void;
  102296. /**
  102297. * Called once for each button that changed state since the last frame
  102298. * @param buttonIdx Which button index changed
  102299. * @param state New state of the button
  102300. * @param changes Which properties on the state changed since last frame
  102301. */
  102302. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102303. /**
  102304. * Moves the buttons on the controller mesh based on their current state
  102305. * @param buttonName the name of the button to move
  102306. * @param buttonValue the value of the button which determines the buttons new position
  102307. */
  102308. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102309. /**
  102310. * Moves the axis on the controller mesh based on its current state
  102311. * @param axis the index of the axis
  102312. * @param axisValue the value of the axis which determines the meshes new position
  102313. * @hidden
  102314. */
  102315. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102316. /**
  102317. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102318. * @param scene scene in which to add meshes
  102319. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102320. */
  102321. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102322. /**
  102323. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102324. * can be transformed by button presses and axes values, based on this._mapping.
  102325. *
  102326. * @param scene scene in which the meshes exist
  102327. * @param meshes list of meshes that make up the controller model to process
  102328. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102329. */
  102330. private processModel;
  102331. private createMeshInfo;
  102332. /**
  102333. * Gets the ray of the controller in the direction the controller is pointing
  102334. * @param length the length the resulting ray should be
  102335. * @returns a ray in the direction the controller is pointing
  102336. */
  102337. getForwardRay(length?: number): Ray;
  102338. /**
  102339. * Disposes of the controller
  102340. */
  102341. dispose(): void;
  102342. }
  102343. }
  102344. declare module BABYLON {
  102345. /**
  102346. * Single axis scale gizmo
  102347. */
  102348. export class AxisScaleGizmo extends Gizmo {
  102349. private _coloredMaterial;
  102350. /**
  102351. * Drag behavior responsible for the gizmos dragging interactions
  102352. */
  102353. dragBehavior: PointerDragBehavior;
  102354. private _pointerObserver;
  102355. /**
  102356. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102357. */
  102358. snapDistance: number;
  102359. /**
  102360. * Event that fires each time the gizmo snaps to a new location.
  102361. * * snapDistance is the the change in distance
  102362. */
  102363. onSnapObservable: Observable<{
  102364. snapDistance: number;
  102365. }>;
  102366. /**
  102367. * If the scaling operation should be done on all axis (default: false)
  102368. */
  102369. uniformScaling: boolean;
  102370. /**
  102371. * Creates an AxisScaleGizmo
  102372. * @param gizmoLayer The utility layer the gizmo will be added to
  102373. * @param dragAxis The axis which the gizmo will be able to scale on
  102374. * @param color The color of the gizmo
  102375. */
  102376. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102377. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102378. /**
  102379. * Disposes of the gizmo
  102380. */
  102381. dispose(): void;
  102382. /**
  102383. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102384. * @param mesh The mesh to replace the default mesh of the gizmo
  102385. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102386. */
  102387. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102388. }
  102389. }
  102390. declare module BABYLON {
  102391. /**
  102392. * Bounding box gizmo
  102393. */
  102394. export class BoundingBoxGizmo extends Gizmo {
  102395. private _lineBoundingBox;
  102396. private _rotateSpheresParent;
  102397. private _scaleBoxesParent;
  102398. private _boundingDimensions;
  102399. private _renderObserver;
  102400. private _pointerObserver;
  102401. private _scaleDragSpeed;
  102402. private _tmpQuaternion;
  102403. private _tmpVector;
  102404. private _tmpRotationMatrix;
  102405. /**
  102406. * 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)
  102407. */
  102408. ignoreChildren: boolean;
  102409. /**
  102410. * 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)
  102411. */
  102412. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102413. /**
  102414. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102415. */
  102416. rotationSphereSize: number;
  102417. /**
  102418. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102419. */
  102420. scaleBoxSize: number;
  102421. /**
  102422. * 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)
  102423. */
  102424. fixedDragMeshScreenSize: boolean;
  102425. /**
  102426. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102427. */
  102428. fixedDragMeshScreenSizeDistanceFactor: number;
  102429. /**
  102430. * Fired when a rotation sphere or scale box is dragged
  102431. */
  102432. onDragStartObservable: Observable<{}>;
  102433. /**
  102434. * Fired when a scale box is dragged
  102435. */
  102436. onScaleBoxDragObservable: Observable<{}>;
  102437. /**
  102438. * Fired when a scale box drag is ended
  102439. */
  102440. onScaleBoxDragEndObservable: Observable<{}>;
  102441. /**
  102442. * Fired when a rotation sphere is dragged
  102443. */
  102444. onRotationSphereDragObservable: Observable<{}>;
  102445. /**
  102446. * Fired when a rotation sphere drag is ended
  102447. */
  102448. onRotationSphereDragEndObservable: Observable<{}>;
  102449. /**
  102450. * 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)
  102451. */
  102452. scalePivot: Nullable<Vector3>;
  102453. /**
  102454. * Mesh used as a pivot to rotate the attached mesh
  102455. */
  102456. private _anchorMesh;
  102457. private _existingMeshScale;
  102458. private _dragMesh;
  102459. private pointerDragBehavior;
  102460. private coloredMaterial;
  102461. private hoverColoredMaterial;
  102462. /**
  102463. * Sets the color of the bounding box gizmo
  102464. * @param color the color to set
  102465. */
  102466. setColor(color: Color3): void;
  102467. /**
  102468. * Creates an BoundingBoxGizmo
  102469. * @param gizmoLayer The utility layer the gizmo will be added to
  102470. * @param color The color of the gizmo
  102471. */
  102472. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102473. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102474. private _selectNode;
  102475. /**
  102476. * Updates the bounding box information for the Gizmo
  102477. */
  102478. updateBoundingBox(): void;
  102479. private _updateRotationSpheres;
  102480. private _updateScaleBoxes;
  102481. /**
  102482. * Enables rotation on the specified axis and disables rotation on the others
  102483. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102484. */
  102485. setEnabledRotationAxis(axis: string): void;
  102486. /**
  102487. * Enables/disables scaling
  102488. * @param enable if scaling should be enabled
  102489. */
  102490. setEnabledScaling(enable: boolean): void;
  102491. private _updateDummy;
  102492. /**
  102493. * Enables a pointer drag behavior on the bounding box of the gizmo
  102494. */
  102495. enableDragBehavior(): void;
  102496. /**
  102497. * Disposes of the gizmo
  102498. */
  102499. dispose(): void;
  102500. /**
  102501. * 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)
  102502. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102503. * @returns the bounding box mesh with the passed in mesh as a child
  102504. */
  102505. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102506. /**
  102507. * CustomMeshes are not supported by this gizmo
  102508. * @param mesh The mesh to replace the default mesh of the gizmo
  102509. */
  102510. setCustomMesh(mesh: Mesh): void;
  102511. }
  102512. }
  102513. declare module BABYLON {
  102514. /**
  102515. * Single plane rotation gizmo
  102516. */
  102517. export class PlaneRotationGizmo extends Gizmo {
  102518. /**
  102519. * Drag behavior responsible for the gizmos dragging interactions
  102520. */
  102521. dragBehavior: PointerDragBehavior;
  102522. private _pointerObserver;
  102523. /**
  102524. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102525. */
  102526. snapDistance: number;
  102527. /**
  102528. * Event that fires each time the gizmo snaps to a new location.
  102529. * * snapDistance is the the change in distance
  102530. */
  102531. onSnapObservable: Observable<{
  102532. snapDistance: number;
  102533. }>;
  102534. /**
  102535. * Creates a PlaneRotationGizmo
  102536. * @param gizmoLayer The utility layer the gizmo will be added to
  102537. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102538. * @param color The color of the gizmo
  102539. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102540. */
  102541. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102542. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102543. /**
  102544. * Disposes of the gizmo
  102545. */
  102546. dispose(): void;
  102547. }
  102548. }
  102549. declare module BABYLON {
  102550. /**
  102551. * Gizmo that enables rotating a mesh along 3 axis
  102552. */
  102553. export class RotationGizmo extends Gizmo {
  102554. /**
  102555. * Internal gizmo used for interactions on the x axis
  102556. */
  102557. xGizmo: PlaneRotationGizmo;
  102558. /**
  102559. * Internal gizmo used for interactions on the y axis
  102560. */
  102561. yGizmo: PlaneRotationGizmo;
  102562. /**
  102563. * Internal gizmo used for interactions on the z axis
  102564. */
  102565. zGizmo: PlaneRotationGizmo;
  102566. /** Fires an event when any of it's sub gizmos are dragged */
  102567. onDragStartObservable: Observable<{}>;
  102568. /** Fires an event when any of it's sub gizmos are released from dragging */
  102569. onDragEndObservable: Observable<{}>;
  102570. attachedMesh: Nullable<AbstractMesh>;
  102571. /**
  102572. * Creates a RotationGizmo
  102573. * @param gizmoLayer The utility layer the gizmo will be added to
  102574. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102575. */
  102576. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102577. updateGizmoRotationToMatchAttachedMesh: boolean;
  102578. /**
  102579. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102580. */
  102581. snapDistance: number;
  102582. /**
  102583. * Ratio for the scale of the gizmo (Default: 1)
  102584. */
  102585. scaleRatio: number;
  102586. /**
  102587. * Disposes of the gizmo
  102588. */
  102589. dispose(): void;
  102590. /**
  102591. * CustomMeshes are not supported by this gizmo
  102592. * @param mesh The mesh to replace the default mesh of the gizmo
  102593. */
  102594. setCustomMesh(mesh: Mesh): void;
  102595. }
  102596. }
  102597. declare module BABYLON {
  102598. /**
  102599. * Gizmo that enables dragging a mesh along 3 axis
  102600. */
  102601. export class PositionGizmo extends Gizmo {
  102602. /**
  102603. * Internal gizmo used for interactions on the x axis
  102604. */
  102605. xGizmo: AxisDragGizmo;
  102606. /**
  102607. * Internal gizmo used for interactions on the y axis
  102608. */
  102609. yGizmo: AxisDragGizmo;
  102610. /**
  102611. * Internal gizmo used for interactions on the z axis
  102612. */
  102613. zGizmo: AxisDragGizmo;
  102614. /** Fires an event when any of it's sub gizmos are dragged */
  102615. onDragStartObservable: Observable<{}>;
  102616. /** Fires an event when any of it's sub gizmos are released from dragging */
  102617. onDragEndObservable: Observable<{}>;
  102618. attachedMesh: Nullable<AbstractMesh>;
  102619. /**
  102620. * Creates a PositionGizmo
  102621. * @param gizmoLayer The utility layer the gizmo will be added to
  102622. */
  102623. constructor(gizmoLayer?: UtilityLayerRenderer);
  102624. updateGizmoRotationToMatchAttachedMesh: boolean;
  102625. /**
  102626. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102627. */
  102628. snapDistance: number;
  102629. /**
  102630. * Ratio for the scale of the gizmo (Default: 1)
  102631. */
  102632. scaleRatio: number;
  102633. /**
  102634. * Disposes of the gizmo
  102635. */
  102636. dispose(): void;
  102637. /**
  102638. * CustomMeshes are not supported by this gizmo
  102639. * @param mesh The mesh to replace the default mesh of the gizmo
  102640. */
  102641. setCustomMesh(mesh: Mesh): void;
  102642. }
  102643. }
  102644. declare module BABYLON {
  102645. /**
  102646. * Class containing static functions to help procedurally build meshes
  102647. */
  102648. export class PolyhedronBuilder {
  102649. /**
  102650. * Creates a polyhedron mesh
  102651. * * 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
  102652. * * The parameter `size` (positive float, default 1) sets the polygon size
  102653. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102654. * * 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`
  102655. * * 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
  102656. * * 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)`)
  102657. * * 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
  102658. * * 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
  102659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102662. * @param name defines the name of the mesh
  102663. * @param options defines the options used to create the mesh
  102664. * @param scene defines the hosting scene
  102665. * @returns the polyhedron mesh
  102666. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102667. */
  102668. static CreatePolyhedron(name: string, options: {
  102669. type?: number;
  102670. size?: number;
  102671. sizeX?: number;
  102672. sizeY?: number;
  102673. sizeZ?: number;
  102674. custom?: any;
  102675. faceUV?: Vector4[];
  102676. faceColors?: Color4[];
  102677. flat?: boolean;
  102678. updatable?: boolean;
  102679. sideOrientation?: number;
  102680. frontUVs?: Vector4;
  102681. backUVs?: Vector4;
  102682. }, scene?: Nullable<Scene>): Mesh;
  102683. }
  102684. }
  102685. declare module BABYLON {
  102686. /**
  102687. * Gizmo that enables scaling a mesh along 3 axis
  102688. */
  102689. export class ScaleGizmo extends Gizmo {
  102690. /**
  102691. * Internal gizmo used for interactions on the x axis
  102692. */
  102693. xGizmo: AxisScaleGizmo;
  102694. /**
  102695. * Internal gizmo used for interactions on the y axis
  102696. */
  102697. yGizmo: AxisScaleGizmo;
  102698. /**
  102699. * Internal gizmo used for interactions on the z axis
  102700. */
  102701. zGizmo: AxisScaleGizmo;
  102702. /**
  102703. * Internal gizmo used to scale all axis equally
  102704. */
  102705. uniformScaleGizmo: AxisScaleGizmo;
  102706. /** Fires an event when any of it's sub gizmos are dragged */
  102707. onDragStartObservable: Observable<{}>;
  102708. /** Fires an event when any of it's sub gizmos are released from dragging */
  102709. onDragEndObservable: Observable<{}>;
  102710. attachedMesh: Nullable<AbstractMesh>;
  102711. /**
  102712. * Creates a ScaleGizmo
  102713. * @param gizmoLayer The utility layer the gizmo will be added to
  102714. */
  102715. constructor(gizmoLayer?: UtilityLayerRenderer);
  102716. updateGizmoRotationToMatchAttachedMesh: boolean;
  102717. /**
  102718. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102719. */
  102720. snapDistance: number;
  102721. /**
  102722. * Ratio for the scale of the gizmo (Default: 1)
  102723. */
  102724. scaleRatio: number;
  102725. /**
  102726. * Disposes of the gizmo
  102727. */
  102728. dispose(): void;
  102729. }
  102730. }
  102731. declare module BABYLON {
  102732. /**
  102733. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102734. */
  102735. export class GizmoManager implements IDisposable {
  102736. private scene;
  102737. /**
  102738. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102739. */
  102740. gizmos: {
  102741. positionGizmo: Nullable<PositionGizmo>;
  102742. rotationGizmo: Nullable<RotationGizmo>;
  102743. scaleGizmo: Nullable<ScaleGizmo>;
  102744. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102745. };
  102746. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102747. clearGizmoOnEmptyPointerEvent: boolean;
  102748. /** Fires an event when the manager is attached to a mesh */
  102749. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102750. private _gizmosEnabled;
  102751. private _pointerObserver;
  102752. private _attachedMesh;
  102753. private _boundingBoxColor;
  102754. private _defaultUtilityLayer;
  102755. private _defaultKeepDepthUtilityLayer;
  102756. /**
  102757. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102758. */
  102759. boundingBoxDragBehavior: SixDofDragBehavior;
  102760. /**
  102761. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102762. */
  102763. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102764. /**
  102765. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102766. */
  102767. usePointerToAttachGizmos: boolean;
  102768. /**
  102769. * Instatiates a gizmo manager
  102770. * @param scene the scene to overlay the gizmos on top of
  102771. */
  102772. constructor(scene: Scene);
  102773. /**
  102774. * Attaches a set of gizmos to the specified mesh
  102775. * @param mesh The mesh the gizmo's should be attached to
  102776. */
  102777. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102778. /**
  102779. * If the position gizmo is enabled
  102780. */
  102781. positionGizmoEnabled: boolean;
  102782. /**
  102783. * If the rotation gizmo is enabled
  102784. */
  102785. rotationGizmoEnabled: boolean;
  102786. /**
  102787. * If the scale gizmo is enabled
  102788. */
  102789. scaleGizmoEnabled: boolean;
  102790. /**
  102791. * If the boundingBox gizmo is enabled
  102792. */
  102793. boundingBoxGizmoEnabled: boolean;
  102794. /**
  102795. * Disposes of the gizmo manager
  102796. */
  102797. dispose(): void;
  102798. }
  102799. }
  102800. declare module BABYLON {
  102801. /**
  102802. * A directional light is defined by a direction (what a surprise!).
  102803. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102804. * 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.
  102805. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102806. */
  102807. export class DirectionalLight extends ShadowLight {
  102808. private _shadowFrustumSize;
  102809. /**
  102810. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102811. */
  102812. /**
  102813. * Specifies a fix frustum size for the shadow generation.
  102814. */
  102815. shadowFrustumSize: number;
  102816. private _shadowOrthoScale;
  102817. /**
  102818. * Gets the shadow projection scale against the optimal computed one.
  102819. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102820. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102821. */
  102822. /**
  102823. * Sets the shadow projection scale against the optimal computed one.
  102824. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102825. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102826. */
  102827. shadowOrthoScale: number;
  102828. /**
  102829. * Automatically compute the projection matrix to best fit (including all the casters)
  102830. * on each frame.
  102831. */
  102832. autoUpdateExtends: boolean;
  102833. private _orthoLeft;
  102834. private _orthoRight;
  102835. private _orthoTop;
  102836. private _orthoBottom;
  102837. /**
  102838. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102839. * The directional light is emitted from everywhere in the given direction.
  102840. * It can cast shadows.
  102841. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102842. * @param name The friendly name of the light
  102843. * @param direction The direction of the light
  102844. * @param scene The scene the light belongs to
  102845. */
  102846. constructor(name: string, direction: Vector3, scene: Scene);
  102847. /**
  102848. * Returns the string "DirectionalLight".
  102849. * @return The class name
  102850. */
  102851. getClassName(): string;
  102852. /**
  102853. * Returns the integer 1.
  102854. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102855. */
  102856. getTypeID(): number;
  102857. /**
  102858. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102859. * Returns the DirectionalLight Shadow projection matrix.
  102860. */
  102861. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102862. /**
  102863. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102864. * Returns the DirectionalLight Shadow projection matrix.
  102865. */
  102866. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102867. /**
  102868. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102869. * Returns the DirectionalLight Shadow projection matrix.
  102870. */
  102871. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102872. protected _buildUniformLayout(): void;
  102873. /**
  102874. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102875. * @param effect The effect to update
  102876. * @param lightIndex The index of the light in the effect to update
  102877. * @returns The directional light
  102878. */
  102879. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102880. /**
  102881. * Gets the minZ used for shadow according to both the scene and the light.
  102882. *
  102883. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102884. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102885. * @param activeCamera The camera we are returning the min for
  102886. * @returns the depth min z
  102887. */
  102888. getDepthMinZ(activeCamera: Camera): number;
  102889. /**
  102890. * Gets the maxZ used for shadow according to both the scene and the light.
  102891. *
  102892. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102893. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102894. * @param activeCamera The camera we are returning the max for
  102895. * @returns the depth max z
  102896. */
  102897. getDepthMaxZ(activeCamera: Camera): number;
  102898. /**
  102899. * Prepares the list of defines specific to the light type.
  102900. * @param defines the list of defines
  102901. * @param lightIndex defines the index of the light for the effect
  102902. */
  102903. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102904. }
  102905. }
  102906. declare module BABYLON {
  102907. /**
  102908. * Class containing static functions to help procedurally build meshes
  102909. */
  102910. export class HemisphereBuilder {
  102911. /**
  102912. * Creates a hemisphere mesh
  102913. * @param name defines the name of the mesh
  102914. * @param options defines the options used to create the mesh
  102915. * @param scene defines the hosting scene
  102916. * @returns the hemisphere mesh
  102917. */
  102918. static CreateHemisphere(name: string, options: {
  102919. segments?: number;
  102920. diameter?: number;
  102921. sideOrientation?: number;
  102922. }, scene: any): Mesh;
  102923. }
  102924. }
  102925. declare module BABYLON {
  102926. /**
  102927. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102928. * These values define a cone of light starting from the position, emitting toward the direction.
  102929. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102930. * and the exponent defines the speed of the decay of the light with distance (reach).
  102931. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102932. */
  102933. export class SpotLight extends ShadowLight {
  102934. private _angle;
  102935. private _innerAngle;
  102936. private _cosHalfAngle;
  102937. private _lightAngleScale;
  102938. private _lightAngleOffset;
  102939. /**
  102940. * Gets the cone angle of the spot light in Radians.
  102941. */
  102942. /**
  102943. * Sets the cone angle of the spot light in Radians.
  102944. */
  102945. angle: number;
  102946. /**
  102947. * Only used in gltf falloff mode, this defines the angle where
  102948. * the directional falloff will start before cutting at angle which could be seen
  102949. * as outer angle.
  102950. */
  102951. /**
  102952. * Only used in gltf falloff mode, this defines the angle where
  102953. * the directional falloff will start before cutting at angle which could be seen
  102954. * as outer angle.
  102955. */
  102956. innerAngle: number;
  102957. private _shadowAngleScale;
  102958. /**
  102959. * Allows scaling the angle of the light for shadow generation only.
  102960. */
  102961. /**
  102962. * Allows scaling the angle of the light for shadow generation only.
  102963. */
  102964. shadowAngleScale: number;
  102965. /**
  102966. * The light decay speed with the distance from the emission spot.
  102967. */
  102968. exponent: number;
  102969. private _projectionTextureMatrix;
  102970. /**
  102971. * Allows reading the projecton texture
  102972. */
  102973. readonly projectionTextureMatrix: Matrix;
  102974. protected _projectionTextureLightNear: number;
  102975. /**
  102976. * Gets the near clip of the Spotlight for texture projection.
  102977. */
  102978. /**
  102979. * Sets the near clip of the Spotlight for texture projection.
  102980. */
  102981. projectionTextureLightNear: number;
  102982. protected _projectionTextureLightFar: number;
  102983. /**
  102984. * Gets the far clip of the Spotlight for texture projection.
  102985. */
  102986. /**
  102987. * Sets the far clip of the Spotlight for texture projection.
  102988. */
  102989. projectionTextureLightFar: number;
  102990. protected _projectionTextureUpDirection: Vector3;
  102991. /**
  102992. * Gets the Up vector of the Spotlight for texture projection.
  102993. */
  102994. /**
  102995. * Sets the Up vector of the Spotlight for texture projection.
  102996. */
  102997. projectionTextureUpDirection: Vector3;
  102998. private _projectionTexture;
  102999. /**
  103000. * Gets the projection texture of the light.
  103001. */
  103002. /**
  103003. * Sets the projection texture of the light.
  103004. */
  103005. projectionTexture: Nullable<BaseTexture>;
  103006. private _projectionTextureViewLightDirty;
  103007. private _projectionTextureProjectionLightDirty;
  103008. private _projectionTextureDirty;
  103009. private _projectionTextureViewTargetVector;
  103010. private _projectionTextureViewLightMatrix;
  103011. private _projectionTextureProjectionLightMatrix;
  103012. private _projectionTextureScalingMatrix;
  103013. /**
  103014. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103015. * It can cast shadows.
  103016. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103017. * @param name The light friendly name
  103018. * @param position The position of the spot light in the scene
  103019. * @param direction The direction of the light in the scene
  103020. * @param angle The cone angle of the light in Radians
  103021. * @param exponent The light decay speed with the distance from the emission spot
  103022. * @param scene The scene the lights belongs to
  103023. */
  103024. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103025. /**
  103026. * Returns the string "SpotLight".
  103027. * @returns the class name
  103028. */
  103029. getClassName(): string;
  103030. /**
  103031. * Returns the integer 2.
  103032. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103033. */
  103034. getTypeID(): number;
  103035. /**
  103036. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103037. */
  103038. protected _setDirection(value: Vector3): void;
  103039. /**
  103040. * Overrides the position setter to recompute the projection texture view light Matrix.
  103041. */
  103042. protected _setPosition(value: Vector3): void;
  103043. /**
  103044. * 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.
  103045. * Returns the SpotLight.
  103046. */
  103047. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103048. protected _computeProjectionTextureViewLightMatrix(): void;
  103049. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103050. /**
  103051. * Main function for light texture projection matrix computing.
  103052. */
  103053. protected _computeProjectionTextureMatrix(): void;
  103054. protected _buildUniformLayout(): void;
  103055. private _computeAngleValues;
  103056. /**
  103057. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103058. * @param effect The effect to update
  103059. * @param lightIndex The index of the light in the effect to update
  103060. * @returns The spot light
  103061. */
  103062. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103063. /**
  103064. * Disposes the light and the associated resources.
  103065. */
  103066. dispose(): void;
  103067. /**
  103068. * Prepares the list of defines specific to the light type.
  103069. * @param defines the list of defines
  103070. * @param lightIndex defines the index of the light for the effect
  103071. */
  103072. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103073. }
  103074. }
  103075. declare module BABYLON {
  103076. /**
  103077. * Gizmo that enables viewing a light
  103078. */
  103079. export class LightGizmo extends Gizmo {
  103080. private _lightMesh;
  103081. private _material;
  103082. /**
  103083. * Creates a LightGizmo
  103084. * @param gizmoLayer The utility layer the gizmo will be added to
  103085. */
  103086. constructor(gizmoLayer?: UtilityLayerRenderer);
  103087. private _light;
  103088. /**
  103089. * The light that the gizmo is attached to
  103090. */
  103091. light: Nullable<Light>;
  103092. /**
  103093. * @hidden
  103094. * Updates the gizmo to match the attached mesh's position/rotation
  103095. */
  103096. protected _update(): void;
  103097. private static _Scale;
  103098. /**
  103099. * Creates the lines for a light mesh
  103100. */
  103101. private static _createLightLines;
  103102. private static _CreateHemisphericLightMesh;
  103103. private static _CreatePointLightMesh;
  103104. private static _CreateSpotLightMesh;
  103105. private static _CreateDirectionalLightMesh;
  103106. }
  103107. }
  103108. declare module BABYLON {
  103109. /** @hidden */
  103110. export var backgroundFragmentDeclaration: {
  103111. name: string;
  103112. shader: string;
  103113. };
  103114. }
  103115. declare module BABYLON {
  103116. /** @hidden */
  103117. export var backgroundUboDeclaration: {
  103118. name: string;
  103119. shader: string;
  103120. };
  103121. }
  103122. declare module BABYLON {
  103123. /** @hidden */
  103124. export var backgroundPixelShader: {
  103125. name: string;
  103126. shader: string;
  103127. };
  103128. }
  103129. declare module BABYLON {
  103130. /** @hidden */
  103131. export var backgroundVertexDeclaration: {
  103132. name: string;
  103133. shader: string;
  103134. };
  103135. }
  103136. declare module BABYLON {
  103137. /** @hidden */
  103138. export var backgroundVertexShader: {
  103139. name: string;
  103140. shader: string;
  103141. };
  103142. }
  103143. declare module BABYLON {
  103144. /**
  103145. * Background material used to create an efficient environement around your scene.
  103146. */
  103147. export class BackgroundMaterial extends PushMaterial {
  103148. /**
  103149. * Standard reflectance value at parallel view angle.
  103150. */
  103151. static StandardReflectance0: number;
  103152. /**
  103153. * Standard reflectance value at grazing angle.
  103154. */
  103155. static StandardReflectance90: number;
  103156. protected _primaryColor: Color3;
  103157. /**
  103158. * Key light Color (multiply against the environement texture)
  103159. */
  103160. primaryColor: Color3;
  103161. protected __perceptualColor: Nullable<Color3>;
  103162. /**
  103163. * Experimental Internal Use Only.
  103164. *
  103165. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103166. * This acts as a helper to set the primary color to a more "human friendly" value.
  103167. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103168. * output color as close as possible from the chosen value.
  103169. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103170. * part of lighting setup.)
  103171. */
  103172. _perceptualColor: Nullable<Color3>;
  103173. protected _primaryColorShadowLevel: float;
  103174. /**
  103175. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103176. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103177. */
  103178. primaryColorShadowLevel: float;
  103179. protected _primaryColorHighlightLevel: float;
  103180. /**
  103181. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103182. * The primary color is used at the level chosen to define what the white area would look.
  103183. */
  103184. primaryColorHighlightLevel: float;
  103185. protected _reflectionTexture: Nullable<BaseTexture>;
  103186. /**
  103187. * Reflection Texture used in the material.
  103188. * Should be author in a specific way for the best result (refer to the documentation).
  103189. */
  103190. reflectionTexture: Nullable<BaseTexture>;
  103191. protected _reflectionBlur: float;
  103192. /**
  103193. * Reflection Texture level of blur.
  103194. *
  103195. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103196. * texture twice.
  103197. */
  103198. reflectionBlur: float;
  103199. protected _diffuseTexture: Nullable<BaseTexture>;
  103200. /**
  103201. * Diffuse Texture used in the material.
  103202. * Should be author in a specific way for the best result (refer to the documentation).
  103203. */
  103204. diffuseTexture: Nullable<BaseTexture>;
  103205. protected _shadowLights: Nullable<IShadowLight[]>;
  103206. /**
  103207. * Specify the list of lights casting shadow on the material.
  103208. * All scene shadow lights will be included if null.
  103209. */
  103210. shadowLights: Nullable<IShadowLight[]>;
  103211. protected _shadowLevel: float;
  103212. /**
  103213. * Helps adjusting the shadow to a softer level if required.
  103214. * 0 means black shadows and 1 means no shadows.
  103215. */
  103216. shadowLevel: float;
  103217. protected _sceneCenter: Vector3;
  103218. /**
  103219. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103220. * It is usually zero but might be interesting to modify according to your setup.
  103221. */
  103222. sceneCenter: Vector3;
  103223. protected _opacityFresnel: boolean;
  103224. /**
  103225. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103226. * This helps ensuring a nice transition when the camera goes under the ground.
  103227. */
  103228. opacityFresnel: boolean;
  103229. protected _reflectionFresnel: boolean;
  103230. /**
  103231. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103232. * This helps adding a mirror texture on the ground.
  103233. */
  103234. reflectionFresnel: boolean;
  103235. protected _reflectionFalloffDistance: number;
  103236. /**
  103237. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103238. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103239. */
  103240. reflectionFalloffDistance: number;
  103241. protected _reflectionAmount: number;
  103242. /**
  103243. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103244. */
  103245. reflectionAmount: number;
  103246. protected _reflectionReflectance0: number;
  103247. /**
  103248. * This specifies the weight of the reflection at grazing angle.
  103249. */
  103250. reflectionReflectance0: number;
  103251. protected _reflectionReflectance90: number;
  103252. /**
  103253. * This specifies the weight of the reflection at a perpendicular point of view.
  103254. */
  103255. reflectionReflectance90: number;
  103256. /**
  103257. * Sets the reflection reflectance fresnel values according to the default standard
  103258. * empirically know to work well :-)
  103259. */
  103260. reflectionStandardFresnelWeight: number;
  103261. protected _useRGBColor: boolean;
  103262. /**
  103263. * Helps to directly use the maps channels instead of their level.
  103264. */
  103265. useRGBColor: boolean;
  103266. protected _enableNoise: boolean;
  103267. /**
  103268. * This helps reducing the banding effect that could occur on the background.
  103269. */
  103270. enableNoise: boolean;
  103271. /**
  103272. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103273. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103274. * Recommended to be keep at 1.0 except for special cases.
  103275. */
  103276. fovMultiplier: number;
  103277. private _fovMultiplier;
  103278. /**
  103279. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103280. */
  103281. useEquirectangularFOV: boolean;
  103282. private _maxSimultaneousLights;
  103283. /**
  103284. * Number of Simultaneous lights allowed on the material.
  103285. */
  103286. maxSimultaneousLights: int;
  103287. /**
  103288. * Default configuration related to image processing available in the Background Material.
  103289. */
  103290. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103291. /**
  103292. * Keep track of the image processing observer to allow dispose and replace.
  103293. */
  103294. private _imageProcessingObserver;
  103295. /**
  103296. * Attaches a new image processing configuration to the PBR Material.
  103297. * @param configuration (if null the scene configuration will be use)
  103298. */
  103299. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103300. /**
  103301. * Gets the image processing configuration used either in this material.
  103302. */
  103303. /**
  103304. * Sets the Default image processing configuration used either in the this material.
  103305. *
  103306. * If sets to null, the scene one is in use.
  103307. */
  103308. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103309. /**
  103310. * Gets wether the color curves effect is enabled.
  103311. */
  103312. /**
  103313. * Sets wether the color curves effect is enabled.
  103314. */
  103315. cameraColorCurvesEnabled: boolean;
  103316. /**
  103317. * Gets wether the color grading effect is enabled.
  103318. */
  103319. /**
  103320. * Gets wether the color grading effect is enabled.
  103321. */
  103322. cameraColorGradingEnabled: boolean;
  103323. /**
  103324. * Gets wether tonemapping is enabled or not.
  103325. */
  103326. /**
  103327. * Sets wether tonemapping is enabled or not
  103328. */
  103329. cameraToneMappingEnabled: boolean;
  103330. /**
  103331. * The camera exposure used on this material.
  103332. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103333. * This corresponds to a photographic exposure.
  103334. */
  103335. /**
  103336. * The camera exposure used on this material.
  103337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103338. * This corresponds to a photographic exposure.
  103339. */
  103340. cameraExposure: float;
  103341. /**
  103342. * Gets The camera contrast used on this material.
  103343. */
  103344. /**
  103345. * Sets The camera contrast used on this material.
  103346. */
  103347. cameraContrast: float;
  103348. /**
  103349. * Gets the Color Grading 2D Lookup Texture.
  103350. */
  103351. /**
  103352. * Sets the Color Grading 2D Lookup Texture.
  103353. */
  103354. cameraColorGradingTexture: Nullable<BaseTexture>;
  103355. /**
  103356. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103357. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103358. * 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;
  103359. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103360. */
  103361. /**
  103362. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103363. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103364. * 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;
  103365. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103366. */
  103367. cameraColorCurves: Nullable<ColorCurves>;
  103368. /**
  103369. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103370. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103371. */
  103372. switchToBGR: boolean;
  103373. private _renderTargets;
  103374. private _reflectionControls;
  103375. private _white;
  103376. private _primaryShadowColor;
  103377. private _primaryHighlightColor;
  103378. /**
  103379. * Instantiates a Background Material in the given scene
  103380. * @param name The friendly name of the material
  103381. * @param scene The scene to add the material to
  103382. */
  103383. constructor(name: string, scene: Scene);
  103384. /**
  103385. * Gets a boolean indicating that current material needs to register RTT
  103386. */
  103387. readonly hasRenderTargetTextures: boolean;
  103388. /**
  103389. * The entire material has been created in order to prevent overdraw.
  103390. * @returns false
  103391. */
  103392. needAlphaTesting(): boolean;
  103393. /**
  103394. * The entire material has been created in order to prevent overdraw.
  103395. * @returns true if blending is enable
  103396. */
  103397. needAlphaBlending(): boolean;
  103398. /**
  103399. * Checks wether the material is ready to be rendered for a given mesh.
  103400. * @param mesh The mesh to render
  103401. * @param subMesh The submesh to check against
  103402. * @param useInstances Specify wether or not the material is used with instances
  103403. * @returns true if all the dependencies are ready (Textures, Effects...)
  103404. */
  103405. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103406. /**
  103407. * Compute the primary color according to the chosen perceptual color.
  103408. */
  103409. private _computePrimaryColorFromPerceptualColor;
  103410. /**
  103411. * Compute the highlights and shadow colors according to their chosen levels.
  103412. */
  103413. private _computePrimaryColors;
  103414. /**
  103415. * Build the uniform buffer used in the material.
  103416. */
  103417. buildUniformLayout(): void;
  103418. /**
  103419. * Unbind the material.
  103420. */
  103421. unbind(): void;
  103422. /**
  103423. * Bind only the world matrix to the material.
  103424. * @param world The world matrix to bind.
  103425. */
  103426. bindOnlyWorldMatrix(world: Matrix): void;
  103427. /**
  103428. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103429. * @param world The world matrix to bind.
  103430. * @param subMesh The submesh to bind for.
  103431. */
  103432. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103433. /**
  103434. * Dispose the material.
  103435. * @param forceDisposeEffect Force disposal of the associated effect.
  103436. * @param forceDisposeTextures Force disposal of the associated textures.
  103437. */
  103438. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103439. /**
  103440. * Clones the material.
  103441. * @param name The cloned name.
  103442. * @returns The cloned material.
  103443. */
  103444. clone(name: string): BackgroundMaterial;
  103445. /**
  103446. * Serializes the current material to its JSON representation.
  103447. * @returns The JSON representation.
  103448. */
  103449. serialize(): any;
  103450. /**
  103451. * Gets the class name of the material
  103452. * @returns "BackgroundMaterial"
  103453. */
  103454. getClassName(): string;
  103455. /**
  103456. * Parse a JSON input to create back a background material.
  103457. * @param source The JSON data to parse
  103458. * @param scene The scene to create the parsed material in
  103459. * @param rootUrl The root url of the assets the material depends upon
  103460. * @returns the instantiated BackgroundMaterial.
  103461. */
  103462. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103463. }
  103464. }
  103465. declare module BABYLON {
  103466. /**
  103467. * Represents the different options available during the creation of
  103468. * a Environment helper.
  103469. *
  103470. * This can control the default ground, skybox and image processing setup of your scene.
  103471. */
  103472. export interface IEnvironmentHelperOptions {
  103473. /**
  103474. * Specifies wether or not to create a ground.
  103475. * True by default.
  103476. */
  103477. createGround: boolean;
  103478. /**
  103479. * Specifies the ground size.
  103480. * 15 by default.
  103481. */
  103482. groundSize: number;
  103483. /**
  103484. * The texture used on the ground for the main color.
  103485. * Comes from the BabylonJS CDN by default.
  103486. *
  103487. * Remarks: Can be either a texture or a url.
  103488. */
  103489. groundTexture: string | BaseTexture;
  103490. /**
  103491. * The color mixed in the ground texture by default.
  103492. * BabylonJS clearColor by default.
  103493. */
  103494. groundColor: Color3;
  103495. /**
  103496. * Specifies the ground opacity.
  103497. * 1 by default.
  103498. */
  103499. groundOpacity: number;
  103500. /**
  103501. * Enables the ground to receive shadows.
  103502. * True by default.
  103503. */
  103504. enableGroundShadow: boolean;
  103505. /**
  103506. * Helps preventing the shadow to be fully black on the ground.
  103507. * 0.5 by default.
  103508. */
  103509. groundShadowLevel: number;
  103510. /**
  103511. * Creates a mirror texture attach to the ground.
  103512. * false by default.
  103513. */
  103514. enableGroundMirror: boolean;
  103515. /**
  103516. * Specifies the ground mirror size ratio.
  103517. * 0.3 by default as the default kernel is 64.
  103518. */
  103519. groundMirrorSizeRatio: number;
  103520. /**
  103521. * Specifies the ground mirror blur kernel size.
  103522. * 64 by default.
  103523. */
  103524. groundMirrorBlurKernel: number;
  103525. /**
  103526. * Specifies the ground mirror visibility amount.
  103527. * 1 by default
  103528. */
  103529. groundMirrorAmount: number;
  103530. /**
  103531. * Specifies the ground mirror reflectance weight.
  103532. * This uses the standard weight of the background material to setup the fresnel effect
  103533. * of the mirror.
  103534. * 1 by default.
  103535. */
  103536. groundMirrorFresnelWeight: number;
  103537. /**
  103538. * Specifies the ground mirror Falloff distance.
  103539. * This can helps reducing the size of the reflection.
  103540. * 0 by Default.
  103541. */
  103542. groundMirrorFallOffDistance: number;
  103543. /**
  103544. * Specifies the ground mirror texture type.
  103545. * Unsigned Int by Default.
  103546. */
  103547. groundMirrorTextureType: number;
  103548. /**
  103549. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103550. * the shown objects.
  103551. */
  103552. groundYBias: number;
  103553. /**
  103554. * Specifies wether or not to create a skybox.
  103555. * True by default.
  103556. */
  103557. createSkybox: boolean;
  103558. /**
  103559. * Specifies the skybox size.
  103560. * 20 by default.
  103561. */
  103562. skyboxSize: number;
  103563. /**
  103564. * The texture used on the skybox for the main color.
  103565. * Comes from the BabylonJS CDN by default.
  103566. *
  103567. * Remarks: Can be either a texture or a url.
  103568. */
  103569. skyboxTexture: string | BaseTexture;
  103570. /**
  103571. * The color mixed in the skybox texture by default.
  103572. * BabylonJS clearColor by default.
  103573. */
  103574. skyboxColor: Color3;
  103575. /**
  103576. * The background rotation around the Y axis of the scene.
  103577. * This helps aligning the key lights of your scene with the background.
  103578. * 0 by default.
  103579. */
  103580. backgroundYRotation: number;
  103581. /**
  103582. * Compute automatically the size of the elements to best fit with the scene.
  103583. */
  103584. sizeAuto: boolean;
  103585. /**
  103586. * Default position of the rootMesh if autoSize is not true.
  103587. */
  103588. rootPosition: Vector3;
  103589. /**
  103590. * Sets up the image processing in the scene.
  103591. * true by default.
  103592. */
  103593. setupImageProcessing: boolean;
  103594. /**
  103595. * The texture used as your environment texture in the scene.
  103596. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103597. *
  103598. * Remarks: Can be either a texture or a url.
  103599. */
  103600. environmentTexture: string | BaseTexture;
  103601. /**
  103602. * The value of the exposure to apply to the scene.
  103603. * 0.6 by default if setupImageProcessing is true.
  103604. */
  103605. cameraExposure: number;
  103606. /**
  103607. * The value of the contrast to apply to the scene.
  103608. * 1.6 by default if setupImageProcessing is true.
  103609. */
  103610. cameraContrast: number;
  103611. /**
  103612. * Specifies wether or not tonemapping should be enabled in the scene.
  103613. * true by default if setupImageProcessing is true.
  103614. */
  103615. toneMappingEnabled: boolean;
  103616. }
  103617. /**
  103618. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103619. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103620. * It also helps with the default setup of your imageProcessing configuration.
  103621. */
  103622. export class EnvironmentHelper {
  103623. /**
  103624. * Default ground texture URL.
  103625. */
  103626. private static _groundTextureCDNUrl;
  103627. /**
  103628. * Default skybox texture URL.
  103629. */
  103630. private static _skyboxTextureCDNUrl;
  103631. /**
  103632. * Default environment texture URL.
  103633. */
  103634. private static _environmentTextureCDNUrl;
  103635. /**
  103636. * Creates the default options for the helper.
  103637. */
  103638. private static _getDefaultOptions;
  103639. private _rootMesh;
  103640. /**
  103641. * Gets the root mesh created by the helper.
  103642. */
  103643. readonly rootMesh: Mesh;
  103644. private _skybox;
  103645. /**
  103646. * Gets the skybox created by the helper.
  103647. */
  103648. readonly skybox: Nullable<Mesh>;
  103649. private _skyboxTexture;
  103650. /**
  103651. * Gets the skybox texture created by the helper.
  103652. */
  103653. readonly skyboxTexture: Nullable<BaseTexture>;
  103654. private _skyboxMaterial;
  103655. /**
  103656. * Gets the skybox material created by the helper.
  103657. */
  103658. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103659. private _ground;
  103660. /**
  103661. * Gets the ground mesh created by the helper.
  103662. */
  103663. readonly ground: Nullable<Mesh>;
  103664. private _groundTexture;
  103665. /**
  103666. * Gets the ground texture created by the helper.
  103667. */
  103668. readonly groundTexture: Nullable<BaseTexture>;
  103669. private _groundMirror;
  103670. /**
  103671. * Gets the ground mirror created by the helper.
  103672. */
  103673. readonly groundMirror: Nullable<MirrorTexture>;
  103674. /**
  103675. * Gets the ground mirror render list to helps pushing the meshes
  103676. * you wish in the ground reflection.
  103677. */
  103678. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103679. private _groundMaterial;
  103680. /**
  103681. * Gets the ground material created by the helper.
  103682. */
  103683. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103684. /**
  103685. * Stores the creation options.
  103686. */
  103687. private readonly _scene;
  103688. private _options;
  103689. /**
  103690. * This observable will be notified with any error during the creation of the environment,
  103691. * mainly texture creation errors.
  103692. */
  103693. onErrorObservable: Observable<{
  103694. message?: string;
  103695. exception?: any;
  103696. }>;
  103697. /**
  103698. * constructor
  103699. * @param options Defines the options we want to customize the helper
  103700. * @param scene The scene to add the material to
  103701. */
  103702. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103703. /**
  103704. * Updates the background according to the new options
  103705. * @param options
  103706. */
  103707. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103708. /**
  103709. * Sets the primary color of all the available elements.
  103710. * @param color the main color to affect to the ground and the background
  103711. */
  103712. setMainColor(color: Color3): void;
  103713. /**
  103714. * Setup the image processing according to the specified options.
  103715. */
  103716. private _setupImageProcessing;
  103717. /**
  103718. * Setup the environment texture according to the specified options.
  103719. */
  103720. private _setupEnvironmentTexture;
  103721. /**
  103722. * Setup the background according to the specified options.
  103723. */
  103724. private _setupBackground;
  103725. /**
  103726. * Get the scene sizes according to the setup.
  103727. */
  103728. private _getSceneSize;
  103729. /**
  103730. * Setup the ground according to the specified options.
  103731. */
  103732. private _setupGround;
  103733. /**
  103734. * Setup the ground material according to the specified options.
  103735. */
  103736. private _setupGroundMaterial;
  103737. /**
  103738. * Setup the ground diffuse texture according to the specified options.
  103739. */
  103740. private _setupGroundDiffuseTexture;
  103741. /**
  103742. * Setup the ground mirror texture according to the specified options.
  103743. */
  103744. private _setupGroundMirrorTexture;
  103745. /**
  103746. * Setup the ground to receive the mirror texture.
  103747. */
  103748. private _setupMirrorInGroundMaterial;
  103749. /**
  103750. * Setup the skybox according to the specified options.
  103751. */
  103752. private _setupSkybox;
  103753. /**
  103754. * Setup the skybox material according to the specified options.
  103755. */
  103756. private _setupSkyboxMaterial;
  103757. /**
  103758. * Setup the skybox reflection texture according to the specified options.
  103759. */
  103760. private _setupSkyboxReflectionTexture;
  103761. private _errorHandler;
  103762. /**
  103763. * Dispose all the elements created by the Helper.
  103764. */
  103765. dispose(): void;
  103766. }
  103767. }
  103768. declare module BABYLON {
  103769. /**
  103770. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103771. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103772. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103773. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103774. */
  103775. export class PhotoDome extends TransformNode {
  103776. private _useDirectMapping;
  103777. /**
  103778. * The texture being displayed on the sphere
  103779. */
  103780. protected _photoTexture: Texture;
  103781. /**
  103782. * Gets or sets the texture being displayed on the sphere
  103783. */
  103784. photoTexture: Texture;
  103785. /**
  103786. * Observable raised when an error occured while loading the 360 image
  103787. */
  103788. onLoadErrorObservable: Observable<string>;
  103789. /**
  103790. * The skybox material
  103791. */
  103792. protected _material: BackgroundMaterial;
  103793. /**
  103794. * The surface used for the skybox
  103795. */
  103796. protected _mesh: Mesh;
  103797. /**
  103798. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103799. * Also see the options.resolution property.
  103800. */
  103801. fovMultiplier: number;
  103802. /**
  103803. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103804. * @param name Element's name, child elements will append suffixes for their own names.
  103805. * @param urlsOfPhoto defines the url of the photo to display
  103806. * @param options defines an object containing optional or exposed sub element properties
  103807. * @param onError defines a callback called when an error occured while loading the texture
  103808. */
  103809. constructor(name: string, urlOfPhoto: string, options: {
  103810. resolution?: number;
  103811. size?: number;
  103812. useDirectMapping?: boolean;
  103813. faceForward?: boolean;
  103814. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103815. /**
  103816. * Releases resources associated with this node.
  103817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103819. */
  103820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103821. }
  103822. }
  103823. declare module BABYLON {
  103824. /** @hidden */
  103825. export var rgbdDecodePixelShader: {
  103826. name: string;
  103827. shader: string;
  103828. };
  103829. }
  103830. declare module BABYLON {
  103831. /**
  103832. * Class used to host texture specific utilities
  103833. */
  103834. export class BRDFTextureTools {
  103835. /**
  103836. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103837. * @param texture the texture to expand.
  103838. */
  103839. private static _ExpandDefaultBRDFTexture;
  103840. /**
  103841. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103842. * @param scene defines the hosting scene
  103843. * @returns the environment BRDF texture
  103844. */
  103845. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103846. private static _environmentBRDFBase64Texture;
  103847. }
  103848. }
  103849. declare module BABYLON {
  103850. /**
  103851. * @hidden
  103852. */
  103853. export interface IMaterialClearCoatDefines {
  103854. CLEARCOAT: boolean;
  103855. CLEARCOAT_DEFAULTIOR: boolean;
  103856. CLEARCOAT_TEXTURE: boolean;
  103857. CLEARCOAT_TEXTUREDIRECTUV: number;
  103858. CLEARCOAT_BUMP: boolean;
  103859. CLEARCOAT_BUMPDIRECTUV: number;
  103860. CLEARCOAT_TINT: boolean;
  103861. CLEARCOAT_TINT_TEXTURE: boolean;
  103862. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103863. /** @hidden */
  103864. _areTexturesDirty: boolean;
  103865. }
  103866. /**
  103867. * Define the code related to the clear coat parameters of the pbr material.
  103868. */
  103869. export class PBRClearCoatConfiguration {
  103870. /**
  103871. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103872. * The default fits with a polyurethane material.
  103873. */
  103874. private static readonly _DefaultIndiceOfRefraction;
  103875. private _isEnabled;
  103876. /**
  103877. * Defines if the clear coat is enabled in the material.
  103878. */
  103879. isEnabled: boolean;
  103880. /**
  103881. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103882. */
  103883. intensity: number;
  103884. /**
  103885. * Defines the clear coat layer roughness.
  103886. */
  103887. roughness: number;
  103888. private _indiceOfRefraction;
  103889. /**
  103890. * Defines the indice of refraction of the clear coat.
  103891. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103892. * The default fits with a polyurethane material.
  103893. * Changing the default value is more performance intensive.
  103894. */
  103895. indiceOfRefraction: number;
  103896. private _texture;
  103897. /**
  103898. * Stores the clear coat values in a texture.
  103899. */
  103900. texture: Nullable<BaseTexture>;
  103901. private _bumpTexture;
  103902. /**
  103903. * Define the clear coat specific bump texture.
  103904. */
  103905. bumpTexture: Nullable<BaseTexture>;
  103906. private _isTintEnabled;
  103907. /**
  103908. * Defines if the clear coat tint is enabled in the material.
  103909. */
  103910. isTintEnabled: boolean;
  103911. /**
  103912. * Defines the clear coat tint of the material.
  103913. * This is only use if tint is enabled
  103914. */
  103915. tintColor: Color3;
  103916. /**
  103917. * Defines the distance at which the tint color should be found in the
  103918. * clear coat media.
  103919. * This is only use if tint is enabled
  103920. */
  103921. tintColorAtDistance: number;
  103922. /**
  103923. * Defines the clear coat layer thickness.
  103924. * This is only use if tint is enabled
  103925. */
  103926. tintThickness: number;
  103927. private _tintTexture;
  103928. /**
  103929. * Stores the clear tint values in a texture.
  103930. * rgb is tint
  103931. * a is a thickness factor
  103932. */
  103933. tintTexture: Nullable<BaseTexture>;
  103934. /** @hidden */
  103935. private _internalMarkAllSubMeshesAsTexturesDirty;
  103936. /** @hidden */
  103937. _markAllSubMeshesAsTexturesDirty(): void;
  103938. /**
  103939. * Instantiate a new istance of clear coat configuration.
  103940. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103941. */
  103942. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103943. /**
  103944. * Gets wehter the submesh is ready to be used or not.
  103945. * @param defines the list of "defines" to update.
  103946. * @param scene defines the scene the material belongs to.
  103947. * @param engine defines the engine the material belongs to.
  103948. * @param disableBumpMap defines wether the material disables bump or not.
  103949. * @returns - boolean indicating that the submesh is ready or not.
  103950. */
  103951. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103952. /**
  103953. * Checks to see if a texture is used in the material.
  103954. * @param defines the list of "defines" to update.
  103955. * @param scene defines the scene to the material belongs to.
  103956. */
  103957. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103958. /**
  103959. * Binds the material data.
  103960. * @param uniformBuffer defines the Uniform buffer to fill in.
  103961. * @param scene defines the scene the material belongs to.
  103962. * @param engine defines the engine the material belongs to.
  103963. * @param disableBumpMap defines wether the material disables bump or not.
  103964. * @param isFrozen defines wether the material is frozen or not.
  103965. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103966. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103967. */
  103968. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103969. /**
  103970. * Checks to see if a texture is used in the material.
  103971. * @param texture - Base texture to use.
  103972. * @returns - Boolean specifying if a texture is used in the material.
  103973. */
  103974. hasTexture(texture: BaseTexture): boolean;
  103975. /**
  103976. * Returns an array of the actively used textures.
  103977. * @param activeTextures Array of BaseTextures
  103978. */
  103979. getActiveTextures(activeTextures: BaseTexture[]): void;
  103980. /**
  103981. * Returns the animatable textures.
  103982. * @param animatables Array of animatable textures.
  103983. */
  103984. getAnimatables(animatables: IAnimatable[]): void;
  103985. /**
  103986. * Disposes the resources of the material.
  103987. * @param forceDisposeTextures - Forces the disposal of all textures.
  103988. */
  103989. dispose(forceDisposeTextures?: boolean): void;
  103990. /**
  103991. * Get the current class name of the texture useful for serialization or dynamic coding.
  103992. * @returns "PBRClearCoatConfiguration"
  103993. */
  103994. getClassName(): string;
  103995. /**
  103996. * Add fallbacks to the effect fallbacks list.
  103997. * @param defines defines the Base texture to use.
  103998. * @param fallbacks defines the current fallback list.
  103999. * @param currentRank defines the current fallback rank.
  104000. * @returns the new fallback rank.
  104001. */
  104002. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104003. /**
  104004. * Add the required uniforms to the current list.
  104005. * @param uniforms defines the current uniform list.
  104006. */
  104007. static AddUniforms(uniforms: string[]): void;
  104008. /**
  104009. * Add the required samplers to the current list.
  104010. * @param samplers defines the current sampler list.
  104011. */
  104012. static AddSamplers(samplers: string[]): void;
  104013. /**
  104014. * Add the required uniforms to the current buffer.
  104015. * @param uniformBuffer defines the current uniform buffer.
  104016. */
  104017. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104018. /**
  104019. * Makes a duplicate of the current configuration into another one.
  104020. * @param clearCoatConfiguration define the config where to copy the info
  104021. */
  104022. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104023. /**
  104024. * Serializes this clear coat configuration.
  104025. * @returns - An object with the serialized config.
  104026. */
  104027. serialize(): any;
  104028. /**
  104029. * Parses a Clear Coat Configuration from a serialized object.
  104030. * @param source - Serialized object.
  104031. */
  104032. parse(source: any): void;
  104033. }
  104034. }
  104035. declare module BABYLON {
  104036. /**
  104037. * @hidden
  104038. */
  104039. export interface IMaterialAnisotropicDefines {
  104040. ANISOTROPIC: boolean;
  104041. ANISOTROPIC_TEXTURE: boolean;
  104042. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104043. MAINUV1: boolean;
  104044. _areTexturesDirty: boolean;
  104045. _needUVs: boolean;
  104046. }
  104047. /**
  104048. * Define the code related to the anisotropic parameters of the pbr material.
  104049. */
  104050. export class PBRAnisotropicConfiguration {
  104051. private _isEnabled;
  104052. /**
  104053. * Defines if the anisotropy is enabled in the material.
  104054. */
  104055. isEnabled: boolean;
  104056. /**
  104057. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104058. */
  104059. intensity: number;
  104060. /**
  104061. * Defines if the effect is along the tangents, bitangents or in between.
  104062. * By default, the effect is "strectching" the highlights along the tangents.
  104063. */
  104064. direction: Vector2;
  104065. private _texture;
  104066. /**
  104067. * Stores the anisotropy values in a texture.
  104068. * rg is direction (like normal from -1 to 1)
  104069. * b is a intensity
  104070. */
  104071. texture: Nullable<BaseTexture>;
  104072. /** @hidden */
  104073. private _internalMarkAllSubMeshesAsTexturesDirty;
  104074. /** @hidden */
  104075. _markAllSubMeshesAsTexturesDirty(): void;
  104076. /**
  104077. * Instantiate a new istance of anisotropy configuration.
  104078. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104079. */
  104080. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104081. /**
  104082. * Specifies that the submesh is ready to be used.
  104083. * @param defines the list of "defines" to update.
  104084. * @param scene defines the scene the material belongs to.
  104085. * @returns - boolean indicating that the submesh is ready or not.
  104086. */
  104087. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104088. /**
  104089. * Checks to see if a texture is used in the material.
  104090. * @param defines the list of "defines" to update.
  104091. * @param mesh the mesh we are preparing the defines for.
  104092. * @param scene defines the scene the material belongs to.
  104093. */
  104094. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104095. /**
  104096. * Binds the material data.
  104097. * @param uniformBuffer defines the Uniform buffer to fill in.
  104098. * @param scene defines the scene the material belongs to.
  104099. * @param isFrozen defines wether the material is frozen or not.
  104100. */
  104101. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104102. /**
  104103. * Checks to see if a texture is used in the material.
  104104. * @param texture - Base texture to use.
  104105. * @returns - Boolean specifying if a texture is used in the material.
  104106. */
  104107. hasTexture(texture: BaseTexture): boolean;
  104108. /**
  104109. * Returns an array of the actively used textures.
  104110. * @param activeTextures Array of BaseTextures
  104111. */
  104112. getActiveTextures(activeTextures: BaseTexture[]): void;
  104113. /**
  104114. * Returns the animatable textures.
  104115. * @param animatables Array of animatable textures.
  104116. */
  104117. getAnimatables(animatables: IAnimatable[]): void;
  104118. /**
  104119. * Disposes the resources of the material.
  104120. * @param forceDisposeTextures - Forces the disposal of all textures.
  104121. */
  104122. dispose(forceDisposeTextures?: boolean): void;
  104123. /**
  104124. * Get the current class name of the texture useful for serialization or dynamic coding.
  104125. * @returns "PBRAnisotropicConfiguration"
  104126. */
  104127. getClassName(): string;
  104128. /**
  104129. * Add fallbacks to the effect fallbacks list.
  104130. * @param defines defines the Base texture to use.
  104131. * @param fallbacks defines the current fallback list.
  104132. * @param currentRank defines the current fallback rank.
  104133. * @returns the new fallback rank.
  104134. */
  104135. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104136. /**
  104137. * Add the required uniforms to the current list.
  104138. * @param uniforms defines the current uniform list.
  104139. */
  104140. static AddUniforms(uniforms: string[]): void;
  104141. /**
  104142. * Add the required uniforms to the current buffer.
  104143. * @param uniformBuffer defines the current uniform buffer.
  104144. */
  104145. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104146. /**
  104147. * Add the required samplers to the current list.
  104148. * @param samplers defines the current sampler list.
  104149. */
  104150. static AddSamplers(samplers: string[]): void;
  104151. /**
  104152. * Makes a duplicate of the current configuration into another one.
  104153. * @param anisotropicConfiguration define the config where to copy the info
  104154. */
  104155. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104156. /**
  104157. * Serializes this anisotropy configuration.
  104158. * @returns - An object with the serialized config.
  104159. */
  104160. serialize(): any;
  104161. /**
  104162. * Parses a anisotropy Configuration from a serialized object.
  104163. * @param source - Serialized object.
  104164. */
  104165. parse(source: any): void;
  104166. }
  104167. }
  104168. declare module BABYLON {
  104169. /**
  104170. * @hidden
  104171. */
  104172. export interface IMaterialBRDFDefines {
  104173. BRDF_V_HEIGHT_CORRELATED: boolean;
  104174. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104175. /** @hidden */
  104176. _areMiscDirty: boolean;
  104177. }
  104178. /**
  104179. * Define the code related to the BRDF parameters of the pbr material.
  104180. */
  104181. export class PBRBRDFConfiguration {
  104182. /**
  104183. * Default value used for the energy conservation.
  104184. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104185. */
  104186. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104187. /**
  104188. * Default value used for the Smith Visibility Height Correlated mode.
  104189. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104190. */
  104191. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104192. private _useEnergyConservation;
  104193. /**
  104194. * Defines if the material uses energy conservation.
  104195. */
  104196. useEnergyConservation: boolean;
  104197. private _useSmithVisibilityHeightCorrelated;
  104198. /**
  104199. * LEGACY Mode set to false
  104200. * Defines if the material uses height smith correlated visibility term.
  104201. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104202. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104203. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104204. * Not relying on height correlated will also disable energy conservation.
  104205. */
  104206. useSmithVisibilityHeightCorrelated: boolean;
  104207. /** @hidden */
  104208. private _internalMarkAllSubMeshesAsMiscDirty;
  104209. /** @hidden */
  104210. _markAllSubMeshesAsMiscDirty(): void;
  104211. /**
  104212. * Instantiate a new istance of clear coat configuration.
  104213. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104214. */
  104215. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104216. /**
  104217. * Checks to see if a texture is used in the material.
  104218. * @param defines the list of "defines" to update.
  104219. */
  104220. prepareDefines(defines: IMaterialBRDFDefines): void;
  104221. /**
  104222. * Get the current class name of the texture useful for serialization or dynamic coding.
  104223. * @returns "PBRClearCoatConfiguration"
  104224. */
  104225. getClassName(): string;
  104226. /**
  104227. * Makes a duplicate of the current configuration into another one.
  104228. * @param brdfConfiguration define the config where to copy the info
  104229. */
  104230. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104231. /**
  104232. * Serializes this BRDF configuration.
  104233. * @returns - An object with the serialized config.
  104234. */
  104235. serialize(): any;
  104236. /**
  104237. * Parses a BRDF Configuration from a serialized object.
  104238. * @param source - Serialized object.
  104239. */
  104240. parse(source: any): void;
  104241. }
  104242. }
  104243. declare module BABYLON {
  104244. /**
  104245. * @hidden
  104246. */
  104247. export interface IMaterialSheenDefines {
  104248. SHEEN: boolean;
  104249. SHEEN_TEXTURE: boolean;
  104250. SHEEN_TEXTUREDIRECTUV: number;
  104251. SHEEN_LINKWITHALBEDO: boolean;
  104252. /** @hidden */
  104253. _areTexturesDirty: boolean;
  104254. }
  104255. /**
  104256. * Define the code related to the Sheen parameters of the pbr material.
  104257. */
  104258. export class PBRSheenConfiguration {
  104259. private _isEnabled;
  104260. /**
  104261. * Defines if the material uses sheen.
  104262. */
  104263. isEnabled: boolean;
  104264. private _linkSheenWithAlbedo;
  104265. /**
  104266. * Defines if the sheen is linked to the sheen color.
  104267. */
  104268. linkSheenWithAlbedo: boolean;
  104269. /**
  104270. * Defines the sheen intensity.
  104271. */
  104272. intensity: number;
  104273. /**
  104274. * Defines the sheen color.
  104275. */
  104276. color: Color3;
  104277. private _texture;
  104278. /**
  104279. * Stores the sheen tint values in a texture.
  104280. * rgb is tint
  104281. * a is a intensity
  104282. */
  104283. texture: Nullable<BaseTexture>;
  104284. /** @hidden */
  104285. private _internalMarkAllSubMeshesAsTexturesDirty;
  104286. /** @hidden */
  104287. _markAllSubMeshesAsTexturesDirty(): void;
  104288. /**
  104289. * Instantiate a new istance of clear coat configuration.
  104290. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104291. */
  104292. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104293. /**
  104294. * Specifies that the submesh is ready to be used.
  104295. * @param defines the list of "defines" to update.
  104296. * @param scene defines the scene the material belongs to.
  104297. * @returns - boolean indicating that the submesh is ready or not.
  104298. */
  104299. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104300. /**
  104301. * Checks to see if a texture is used in the material.
  104302. * @param defines the list of "defines" to update.
  104303. * @param scene defines the scene the material belongs to.
  104304. */
  104305. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104306. /**
  104307. * Binds the material data.
  104308. * @param uniformBuffer defines the Uniform buffer to fill in.
  104309. * @param scene defines the scene the material belongs to.
  104310. * @param isFrozen defines wether the material is frozen or not.
  104311. */
  104312. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104313. /**
  104314. * Checks to see if a texture is used in the material.
  104315. * @param texture - Base texture to use.
  104316. * @returns - Boolean specifying if a texture is used in the material.
  104317. */
  104318. hasTexture(texture: BaseTexture): boolean;
  104319. /**
  104320. * Returns an array of the actively used textures.
  104321. * @param activeTextures Array of BaseTextures
  104322. */
  104323. getActiveTextures(activeTextures: BaseTexture[]): void;
  104324. /**
  104325. * Returns the animatable textures.
  104326. * @param animatables Array of animatable textures.
  104327. */
  104328. getAnimatables(animatables: IAnimatable[]): void;
  104329. /**
  104330. * Disposes the resources of the material.
  104331. * @param forceDisposeTextures - Forces the disposal of all textures.
  104332. */
  104333. dispose(forceDisposeTextures?: boolean): void;
  104334. /**
  104335. * Get the current class name of the texture useful for serialization or dynamic coding.
  104336. * @returns "PBRSheenConfiguration"
  104337. */
  104338. getClassName(): string;
  104339. /**
  104340. * Add fallbacks to the effect fallbacks list.
  104341. * @param defines defines the Base texture to use.
  104342. * @param fallbacks defines the current fallback list.
  104343. * @param currentRank defines the current fallback rank.
  104344. * @returns the new fallback rank.
  104345. */
  104346. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104347. /**
  104348. * Add the required uniforms to the current list.
  104349. * @param uniforms defines the current uniform list.
  104350. */
  104351. static AddUniforms(uniforms: string[]): void;
  104352. /**
  104353. * Add the required uniforms to the current buffer.
  104354. * @param uniformBuffer defines the current uniform buffer.
  104355. */
  104356. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104357. /**
  104358. * Add the required samplers to the current list.
  104359. * @param samplers defines the current sampler list.
  104360. */
  104361. static AddSamplers(samplers: string[]): void;
  104362. /**
  104363. * Makes a duplicate of the current configuration into another one.
  104364. * @param sheenConfiguration define the config where to copy the info
  104365. */
  104366. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104367. /**
  104368. * Serializes this BRDF configuration.
  104369. * @returns - An object with the serialized config.
  104370. */
  104371. serialize(): any;
  104372. /**
  104373. * Parses a Sheen Configuration from a serialized object.
  104374. * @param source - Serialized object.
  104375. */
  104376. parse(source: any): void;
  104377. }
  104378. }
  104379. declare module BABYLON {
  104380. /**
  104381. * @hidden
  104382. */
  104383. export interface IMaterialSubSurfaceDefines {
  104384. SUBSURFACE: boolean;
  104385. SS_REFRACTION: boolean;
  104386. SS_TRANSLUCENCY: boolean;
  104387. SS_SCATERRING: boolean;
  104388. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104389. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104390. SS_REFRACTIONMAP_3D: boolean;
  104391. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104392. SS_LODINREFRACTIONALPHA: boolean;
  104393. SS_GAMMAREFRACTION: boolean;
  104394. SS_RGBDREFRACTION: boolean;
  104395. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104396. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104397. /** @hidden */
  104398. _areTexturesDirty: boolean;
  104399. }
  104400. /**
  104401. * Define the code related to the sub surface parameters of the pbr material.
  104402. */
  104403. export class PBRSubSurfaceConfiguration {
  104404. private _isRefractionEnabled;
  104405. /**
  104406. * Defines if the refraction is enabled in the material.
  104407. */
  104408. isRefractionEnabled: boolean;
  104409. private _isTranslucencyEnabled;
  104410. /**
  104411. * Defines if the translucency is enabled in the material.
  104412. */
  104413. isTranslucencyEnabled: boolean;
  104414. private _isScatteringEnabled;
  104415. /**
  104416. * Defines the refraction intensity of the material.
  104417. * The refraction when enabled replaces the Diffuse part of the material.
  104418. * The intensity helps transitionning between diffuse and refraction.
  104419. */
  104420. refractionIntensity: number;
  104421. /**
  104422. * Defines the translucency intensity of the material.
  104423. * When translucency has been enabled, this defines how much of the "translucency"
  104424. * is addded to the diffuse part of the material.
  104425. */
  104426. translucencyIntensity: number;
  104427. /**
  104428. * Defines the scattering intensity of the material.
  104429. * When scattering has been enabled, this defines how much of the "scattered light"
  104430. * is addded to the diffuse part of the material.
  104431. */
  104432. scatteringIntensity: number;
  104433. private _thicknessTexture;
  104434. /**
  104435. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104436. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104437. * 0 would mean minimumThickness
  104438. * 1 would mean maximumThickness
  104439. * The other channels might be use as a mask to vary the different effects intensity.
  104440. */
  104441. thicknessTexture: Nullable<BaseTexture>;
  104442. private _refractionTexture;
  104443. /**
  104444. * Defines the texture to use for refraction.
  104445. */
  104446. refractionTexture: Nullable<BaseTexture>;
  104447. private _indexOfRefraction;
  104448. /**
  104449. * Defines the indice of refraction used in the material.
  104450. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104451. */
  104452. indexOfRefraction: number;
  104453. private _invertRefractionY;
  104454. /**
  104455. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104456. */
  104457. invertRefractionY: boolean;
  104458. private _linkRefractionWithTransparency;
  104459. /**
  104460. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104461. * Materials half opaque for instance using refraction could benefit from this control.
  104462. */
  104463. linkRefractionWithTransparency: boolean;
  104464. /**
  104465. * Defines the minimum thickness stored in the thickness map.
  104466. * If no thickness map is defined, this value will be used to simulate thickness.
  104467. */
  104468. minimumThickness: number;
  104469. /**
  104470. * Defines the maximum thickness stored in the thickness map.
  104471. */
  104472. maximumThickness: number;
  104473. /**
  104474. * Defines the volume tint of the material.
  104475. * This is used for both translucency and scattering.
  104476. */
  104477. tintColor: Color3;
  104478. /**
  104479. * Defines the distance at which the tint color should be found in the media.
  104480. * This is used for refraction only.
  104481. */
  104482. tintColorAtDistance: number;
  104483. /**
  104484. * Defines how far each channel transmit through the media.
  104485. * It is defined as a color to simplify it selection.
  104486. */
  104487. diffusionDistance: Color3;
  104488. private _useMaskFromThicknessTexture;
  104489. /**
  104490. * Stores the intensity of the different subsurface effects in the thickness texture.
  104491. * * the green channel is the translucency intensity.
  104492. * * the blue channel is the scattering intensity.
  104493. * * the alpha channel is the refraction intensity.
  104494. */
  104495. useMaskFromThicknessTexture: boolean;
  104496. /** @hidden */
  104497. private _internalMarkAllSubMeshesAsTexturesDirty;
  104498. /** @hidden */
  104499. _markAllSubMeshesAsTexturesDirty(): void;
  104500. /**
  104501. * Instantiate a new istance of sub surface configuration.
  104502. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104503. */
  104504. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104505. /**
  104506. * Gets wehter the submesh is ready to be used or not.
  104507. * @param defines the list of "defines" to update.
  104508. * @param scene defines the scene the material belongs to.
  104509. * @returns - boolean indicating that the submesh is ready or not.
  104510. */
  104511. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104512. /**
  104513. * Checks to see if a texture is used in the material.
  104514. * @param defines the list of "defines" to update.
  104515. * @param scene defines the scene to the material belongs to.
  104516. */
  104517. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104518. /**
  104519. * Binds the material data.
  104520. * @param uniformBuffer defines the Uniform buffer to fill in.
  104521. * @param scene defines the scene the material belongs to.
  104522. * @param engine defines the engine the material belongs to.
  104523. * @param isFrozen defines wether the material is frozen or not.
  104524. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104525. */
  104526. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104527. /**
  104528. * Unbinds the material from the mesh.
  104529. * @param activeEffect defines the effect that should be unbound from.
  104530. * @returns true if unbound, otherwise false
  104531. */
  104532. unbind(activeEffect: Effect): boolean;
  104533. /**
  104534. * Returns the texture used for refraction or null if none is used.
  104535. * @param scene defines the scene the material belongs to.
  104536. * @returns - Refraction texture if present. If no refraction texture and refraction
  104537. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104538. */
  104539. private _getRefractionTexture;
  104540. /**
  104541. * Returns true if alpha blending should be disabled.
  104542. */
  104543. readonly disableAlphaBlending: boolean;
  104544. /**
  104545. * Fills the list of render target textures.
  104546. * @param renderTargets the list of render targets to update
  104547. */
  104548. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104549. /**
  104550. * Checks to see if a texture is used in the material.
  104551. * @param texture - Base texture to use.
  104552. * @returns - Boolean specifying if a texture is used in the material.
  104553. */
  104554. hasTexture(texture: BaseTexture): boolean;
  104555. /**
  104556. * Gets a boolean indicating that current material needs to register RTT
  104557. * @returns true if this uses a render target otherwise false.
  104558. */
  104559. hasRenderTargetTextures(): boolean;
  104560. /**
  104561. * Returns an array of the actively used textures.
  104562. * @param activeTextures Array of BaseTextures
  104563. */
  104564. getActiveTextures(activeTextures: BaseTexture[]): void;
  104565. /**
  104566. * Returns the animatable textures.
  104567. * @param animatables Array of animatable textures.
  104568. */
  104569. getAnimatables(animatables: IAnimatable[]): void;
  104570. /**
  104571. * Disposes the resources of the material.
  104572. * @param forceDisposeTextures - Forces the disposal of all textures.
  104573. */
  104574. dispose(forceDisposeTextures?: boolean): void;
  104575. /**
  104576. * Get the current class name of the texture useful for serialization or dynamic coding.
  104577. * @returns "PBRSubSurfaceConfiguration"
  104578. */
  104579. getClassName(): string;
  104580. /**
  104581. * Add fallbacks to the effect fallbacks list.
  104582. * @param defines defines the Base texture to use.
  104583. * @param fallbacks defines the current fallback list.
  104584. * @param currentRank defines the current fallback rank.
  104585. * @returns the new fallback rank.
  104586. */
  104587. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104588. /**
  104589. * Add the required uniforms to the current list.
  104590. * @param uniforms defines the current uniform list.
  104591. */
  104592. static AddUniforms(uniforms: string[]): void;
  104593. /**
  104594. * Add the required samplers to the current list.
  104595. * @param samplers defines the current sampler list.
  104596. */
  104597. static AddSamplers(samplers: string[]): void;
  104598. /**
  104599. * Add the required uniforms to the current buffer.
  104600. * @param uniformBuffer defines the current uniform buffer.
  104601. */
  104602. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104603. /**
  104604. * Makes a duplicate of the current configuration into another one.
  104605. * @param configuration define the config where to copy the info
  104606. */
  104607. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104608. /**
  104609. * Serializes this Sub Surface configuration.
  104610. * @returns - An object with the serialized config.
  104611. */
  104612. serialize(): any;
  104613. /**
  104614. * Parses a Sub Surface Configuration from a serialized object.
  104615. * @param source - Serialized object.
  104616. */
  104617. parse(source: any): void;
  104618. }
  104619. }
  104620. declare module BABYLON {
  104621. /** @hidden */
  104622. export var pbrFragmentDeclaration: {
  104623. name: string;
  104624. shader: string;
  104625. };
  104626. }
  104627. declare module BABYLON {
  104628. /** @hidden */
  104629. export var pbrUboDeclaration: {
  104630. name: string;
  104631. shader: string;
  104632. };
  104633. }
  104634. declare module BABYLON {
  104635. /** @hidden */
  104636. export var pbrFragmentExtraDeclaration: {
  104637. name: string;
  104638. shader: string;
  104639. };
  104640. }
  104641. declare module BABYLON {
  104642. /** @hidden */
  104643. export var pbrFragmentSamplersDeclaration: {
  104644. name: string;
  104645. shader: string;
  104646. };
  104647. }
  104648. declare module BABYLON {
  104649. /** @hidden */
  104650. export var pbrHelperFunctions: {
  104651. name: string;
  104652. shader: string;
  104653. };
  104654. }
  104655. declare module BABYLON {
  104656. /** @hidden */
  104657. export var harmonicsFunctions: {
  104658. name: string;
  104659. shader: string;
  104660. };
  104661. }
  104662. declare module BABYLON {
  104663. /** @hidden */
  104664. export var pbrDirectLightingSetupFunctions: {
  104665. name: string;
  104666. shader: string;
  104667. };
  104668. }
  104669. declare module BABYLON {
  104670. /** @hidden */
  104671. export var pbrDirectLightingFalloffFunctions: {
  104672. name: string;
  104673. shader: string;
  104674. };
  104675. }
  104676. declare module BABYLON {
  104677. /** @hidden */
  104678. export var pbrBRDFFunctions: {
  104679. name: string;
  104680. shader: string;
  104681. };
  104682. }
  104683. declare module BABYLON {
  104684. /** @hidden */
  104685. export var pbrDirectLightingFunctions: {
  104686. name: string;
  104687. shader: string;
  104688. };
  104689. }
  104690. declare module BABYLON {
  104691. /** @hidden */
  104692. export var pbrIBLFunctions: {
  104693. name: string;
  104694. shader: string;
  104695. };
  104696. }
  104697. declare module BABYLON {
  104698. /** @hidden */
  104699. export var pbrDebug: {
  104700. name: string;
  104701. shader: string;
  104702. };
  104703. }
  104704. declare module BABYLON {
  104705. /** @hidden */
  104706. export var pbrPixelShader: {
  104707. name: string;
  104708. shader: string;
  104709. };
  104710. }
  104711. declare module BABYLON {
  104712. /** @hidden */
  104713. export var pbrVertexDeclaration: {
  104714. name: string;
  104715. shader: string;
  104716. };
  104717. }
  104718. declare module BABYLON {
  104719. /** @hidden */
  104720. export var pbrVertexShader: {
  104721. name: string;
  104722. shader: string;
  104723. };
  104724. }
  104725. declare module BABYLON {
  104726. /**
  104727. * Manages the defines for the PBR Material.
  104728. * @hidden
  104729. */
  104730. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104731. PBR: boolean;
  104732. MAINUV1: boolean;
  104733. MAINUV2: boolean;
  104734. UV1: boolean;
  104735. UV2: boolean;
  104736. ALBEDO: boolean;
  104737. ALBEDODIRECTUV: number;
  104738. VERTEXCOLOR: boolean;
  104739. AMBIENT: boolean;
  104740. AMBIENTDIRECTUV: number;
  104741. AMBIENTINGRAYSCALE: boolean;
  104742. OPACITY: boolean;
  104743. VERTEXALPHA: boolean;
  104744. OPACITYDIRECTUV: number;
  104745. OPACITYRGB: boolean;
  104746. ALPHATEST: boolean;
  104747. DEPTHPREPASS: boolean;
  104748. ALPHABLEND: boolean;
  104749. ALPHAFROMALBEDO: boolean;
  104750. ALPHATESTVALUE: string;
  104751. SPECULAROVERALPHA: boolean;
  104752. RADIANCEOVERALPHA: boolean;
  104753. ALPHAFRESNEL: boolean;
  104754. LINEARALPHAFRESNEL: boolean;
  104755. PREMULTIPLYALPHA: boolean;
  104756. EMISSIVE: boolean;
  104757. EMISSIVEDIRECTUV: number;
  104758. REFLECTIVITY: boolean;
  104759. REFLECTIVITYDIRECTUV: number;
  104760. SPECULARTERM: boolean;
  104761. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104762. MICROSURFACEAUTOMATIC: boolean;
  104763. LODBASEDMICROSFURACE: boolean;
  104764. MICROSURFACEMAP: boolean;
  104765. MICROSURFACEMAPDIRECTUV: number;
  104766. METALLICWORKFLOW: boolean;
  104767. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104768. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104769. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104770. AOSTOREINMETALMAPRED: boolean;
  104771. ENVIRONMENTBRDF: boolean;
  104772. ENVIRONMENTBRDF_RGBD: boolean;
  104773. NORMAL: boolean;
  104774. TANGENT: boolean;
  104775. BUMP: boolean;
  104776. BUMPDIRECTUV: number;
  104777. OBJECTSPACE_NORMALMAP: boolean;
  104778. PARALLAX: boolean;
  104779. PARALLAXOCCLUSION: boolean;
  104780. NORMALXYSCALE: boolean;
  104781. LIGHTMAP: boolean;
  104782. LIGHTMAPDIRECTUV: number;
  104783. USELIGHTMAPASSHADOWMAP: boolean;
  104784. GAMMALIGHTMAP: boolean;
  104785. REFLECTION: boolean;
  104786. REFLECTIONMAP_3D: boolean;
  104787. REFLECTIONMAP_SPHERICAL: boolean;
  104788. REFLECTIONMAP_PLANAR: boolean;
  104789. REFLECTIONMAP_CUBIC: boolean;
  104790. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104791. REFLECTIONMAP_PROJECTION: boolean;
  104792. REFLECTIONMAP_SKYBOX: boolean;
  104793. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104794. REFLECTIONMAP_EXPLICIT: boolean;
  104795. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104796. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104797. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104798. INVERTCUBICMAP: boolean;
  104799. USESPHERICALFROMREFLECTIONMAP: boolean;
  104800. USESPHERICALINVERTEX: boolean;
  104801. REFLECTIONMAP_OPPOSITEZ: boolean;
  104802. LODINREFLECTIONALPHA: boolean;
  104803. GAMMAREFLECTION: boolean;
  104804. RGBDREFLECTION: boolean;
  104805. RADIANCEOCCLUSION: boolean;
  104806. HORIZONOCCLUSION: boolean;
  104807. INSTANCES: boolean;
  104808. NUM_BONE_INFLUENCERS: number;
  104809. BonesPerMesh: number;
  104810. BONETEXTURE: boolean;
  104811. NONUNIFORMSCALING: boolean;
  104812. MORPHTARGETS: boolean;
  104813. MORPHTARGETS_NORMAL: boolean;
  104814. MORPHTARGETS_TANGENT: boolean;
  104815. NUM_MORPH_INFLUENCERS: number;
  104816. IMAGEPROCESSING: boolean;
  104817. VIGNETTE: boolean;
  104818. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104819. VIGNETTEBLENDMODEOPAQUE: boolean;
  104820. TONEMAPPING: boolean;
  104821. TONEMAPPING_ACES: boolean;
  104822. CONTRAST: boolean;
  104823. COLORCURVES: boolean;
  104824. COLORGRADING: boolean;
  104825. COLORGRADING3D: boolean;
  104826. SAMPLER3DGREENDEPTH: boolean;
  104827. SAMPLER3DBGRMAP: boolean;
  104828. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104829. EXPOSURE: boolean;
  104830. MULTIVIEW: boolean;
  104831. USEPHYSICALLIGHTFALLOFF: boolean;
  104832. USEGLTFLIGHTFALLOFF: boolean;
  104833. TWOSIDEDLIGHTING: boolean;
  104834. SHADOWFLOAT: boolean;
  104835. CLIPPLANE: boolean;
  104836. CLIPPLANE2: boolean;
  104837. CLIPPLANE3: boolean;
  104838. CLIPPLANE4: boolean;
  104839. POINTSIZE: boolean;
  104840. FOG: boolean;
  104841. LOGARITHMICDEPTH: boolean;
  104842. FORCENORMALFORWARD: boolean;
  104843. SPECULARAA: boolean;
  104844. CLEARCOAT: boolean;
  104845. CLEARCOAT_DEFAULTIOR: boolean;
  104846. CLEARCOAT_TEXTURE: boolean;
  104847. CLEARCOAT_TEXTUREDIRECTUV: number;
  104848. CLEARCOAT_BUMP: boolean;
  104849. CLEARCOAT_BUMPDIRECTUV: number;
  104850. CLEARCOAT_TINT: boolean;
  104851. CLEARCOAT_TINT_TEXTURE: boolean;
  104852. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104853. ANISOTROPIC: boolean;
  104854. ANISOTROPIC_TEXTURE: boolean;
  104855. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104856. BRDF_V_HEIGHT_CORRELATED: boolean;
  104857. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104858. SHEEN: boolean;
  104859. SHEEN_TEXTURE: boolean;
  104860. SHEEN_TEXTUREDIRECTUV: number;
  104861. SHEEN_LINKWITHALBEDO: boolean;
  104862. SUBSURFACE: boolean;
  104863. SS_REFRACTION: boolean;
  104864. SS_TRANSLUCENCY: boolean;
  104865. SS_SCATERRING: boolean;
  104866. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104867. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104868. SS_REFRACTIONMAP_3D: boolean;
  104869. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104870. SS_LODINREFRACTIONALPHA: boolean;
  104871. SS_GAMMAREFRACTION: boolean;
  104872. SS_RGBDREFRACTION: boolean;
  104873. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104874. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104875. UNLIT: boolean;
  104876. DEBUGMODE: number;
  104877. /**
  104878. * Initializes the PBR Material defines.
  104879. */
  104880. constructor();
  104881. /**
  104882. * Resets the PBR Material defines.
  104883. */
  104884. reset(): void;
  104885. }
  104886. /**
  104887. * The Physically based material base class of BJS.
  104888. *
  104889. * This offers the main features of a standard PBR material.
  104890. * For more information, please refer to the documentation :
  104891. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104892. */
  104893. export abstract class PBRBaseMaterial extends PushMaterial {
  104894. /**
  104895. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104896. */
  104897. static readonly PBRMATERIAL_OPAQUE: number;
  104898. /**
  104899. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104900. */
  104901. static readonly PBRMATERIAL_ALPHATEST: number;
  104902. /**
  104903. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104904. */
  104905. static readonly PBRMATERIAL_ALPHABLEND: number;
  104906. /**
  104907. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104908. * They are also discarded below the alpha cutoff threshold to improve performances.
  104909. */
  104910. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104911. /**
  104912. * Defines the default value of how much AO map is occluding the analytical lights
  104913. * (point spot...).
  104914. */
  104915. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104916. /**
  104917. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104918. */
  104919. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104920. /**
  104921. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104922. * to enhance interoperability with other engines.
  104923. */
  104924. static readonly LIGHTFALLOFF_GLTF: number;
  104925. /**
  104926. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104927. * to enhance interoperability with other materials.
  104928. */
  104929. static readonly LIGHTFALLOFF_STANDARD: number;
  104930. /**
  104931. * Intensity of the direct lights e.g. the four lights available in your scene.
  104932. * This impacts both the direct diffuse and specular highlights.
  104933. */
  104934. protected _directIntensity: number;
  104935. /**
  104936. * Intensity of the emissive part of the material.
  104937. * This helps controlling the emissive effect without modifying the emissive color.
  104938. */
  104939. protected _emissiveIntensity: number;
  104940. /**
  104941. * Intensity of the environment e.g. how much the environment will light the object
  104942. * either through harmonics for rough material or through the refelction for shiny ones.
  104943. */
  104944. protected _environmentIntensity: number;
  104945. /**
  104946. * This is a special control allowing the reduction of the specular highlights coming from the
  104947. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104948. */
  104949. protected _specularIntensity: number;
  104950. /**
  104951. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104952. */
  104953. private _lightingInfos;
  104954. /**
  104955. * Debug Control allowing disabling the bump map on this material.
  104956. */
  104957. protected _disableBumpMap: boolean;
  104958. /**
  104959. * AKA Diffuse Texture in standard nomenclature.
  104960. */
  104961. protected _albedoTexture: Nullable<BaseTexture>;
  104962. /**
  104963. * AKA Occlusion Texture in other nomenclature.
  104964. */
  104965. protected _ambientTexture: Nullable<BaseTexture>;
  104966. /**
  104967. * AKA Occlusion Texture Intensity in other nomenclature.
  104968. */
  104969. protected _ambientTextureStrength: number;
  104970. /**
  104971. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104972. * 1 means it completely occludes it
  104973. * 0 mean it has no impact
  104974. */
  104975. protected _ambientTextureImpactOnAnalyticalLights: number;
  104976. /**
  104977. * Stores the alpha values in a texture.
  104978. */
  104979. protected _opacityTexture: Nullable<BaseTexture>;
  104980. /**
  104981. * Stores the reflection values in a texture.
  104982. */
  104983. protected _reflectionTexture: Nullable<BaseTexture>;
  104984. /**
  104985. * Stores the emissive values in a texture.
  104986. */
  104987. protected _emissiveTexture: Nullable<BaseTexture>;
  104988. /**
  104989. * AKA Specular texture in other nomenclature.
  104990. */
  104991. protected _reflectivityTexture: Nullable<BaseTexture>;
  104992. /**
  104993. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104994. */
  104995. protected _metallicTexture: Nullable<BaseTexture>;
  104996. /**
  104997. * Specifies the metallic scalar of the metallic/roughness workflow.
  104998. * Can also be used to scale the metalness values of the metallic texture.
  104999. */
  105000. protected _metallic: Nullable<number>;
  105001. /**
  105002. * Specifies the roughness scalar of the metallic/roughness workflow.
  105003. * Can also be used to scale the roughness values of the metallic texture.
  105004. */
  105005. protected _roughness: Nullable<number>;
  105006. /**
  105007. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105008. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105009. */
  105010. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105011. /**
  105012. * Stores surface normal data used to displace a mesh in a texture.
  105013. */
  105014. protected _bumpTexture: Nullable<BaseTexture>;
  105015. /**
  105016. * Stores the pre-calculated light information of a mesh in a texture.
  105017. */
  105018. protected _lightmapTexture: Nullable<BaseTexture>;
  105019. /**
  105020. * The color of a material in ambient lighting.
  105021. */
  105022. protected _ambientColor: Color3;
  105023. /**
  105024. * AKA Diffuse Color in other nomenclature.
  105025. */
  105026. protected _albedoColor: Color3;
  105027. /**
  105028. * AKA Specular Color in other nomenclature.
  105029. */
  105030. protected _reflectivityColor: Color3;
  105031. /**
  105032. * The color applied when light is reflected from a material.
  105033. */
  105034. protected _reflectionColor: Color3;
  105035. /**
  105036. * The color applied when light is emitted from a material.
  105037. */
  105038. protected _emissiveColor: Color3;
  105039. /**
  105040. * AKA Glossiness in other nomenclature.
  105041. */
  105042. protected _microSurface: number;
  105043. /**
  105044. * Specifies that the material will use the light map as a show map.
  105045. */
  105046. protected _useLightmapAsShadowmap: boolean;
  105047. /**
  105048. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105049. * makes the reflect vector face the model (under horizon).
  105050. */
  105051. protected _useHorizonOcclusion: boolean;
  105052. /**
  105053. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105054. * too much the area relying on ambient texture to define their ambient occlusion.
  105055. */
  105056. protected _useRadianceOcclusion: boolean;
  105057. /**
  105058. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105059. */
  105060. protected _useAlphaFromAlbedoTexture: boolean;
  105061. /**
  105062. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105063. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105064. */
  105065. protected _useSpecularOverAlpha: boolean;
  105066. /**
  105067. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105068. */
  105069. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105070. /**
  105071. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105072. */
  105073. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105074. /**
  105075. * Specifies if the metallic texture contains the roughness information in its green channel.
  105076. */
  105077. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105078. /**
  105079. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105080. */
  105081. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105082. /**
  105083. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105084. */
  105085. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105086. /**
  105087. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105088. */
  105089. protected _useAmbientInGrayScale: boolean;
  105090. /**
  105091. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105092. * The material will try to infer what glossiness each pixel should be.
  105093. */
  105094. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105095. /**
  105096. * Defines the falloff type used in this material.
  105097. * It by default is Physical.
  105098. */
  105099. protected _lightFalloff: number;
  105100. /**
  105101. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105102. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105103. */
  105104. protected _useRadianceOverAlpha: boolean;
  105105. /**
  105106. * Allows using an object space normal map (instead of tangent space).
  105107. */
  105108. protected _useObjectSpaceNormalMap: boolean;
  105109. /**
  105110. * Allows using the bump map in parallax mode.
  105111. */
  105112. protected _useParallax: boolean;
  105113. /**
  105114. * Allows using the bump map in parallax occlusion mode.
  105115. */
  105116. protected _useParallaxOcclusion: boolean;
  105117. /**
  105118. * Controls the scale bias of the parallax mode.
  105119. */
  105120. protected _parallaxScaleBias: number;
  105121. /**
  105122. * If sets to true, disables all the lights affecting the material.
  105123. */
  105124. protected _disableLighting: boolean;
  105125. /**
  105126. * Number of Simultaneous lights allowed on the material.
  105127. */
  105128. protected _maxSimultaneousLights: number;
  105129. /**
  105130. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105131. */
  105132. protected _invertNormalMapX: boolean;
  105133. /**
  105134. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105135. */
  105136. protected _invertNormalMapY: boolean;
  105137. /**
  105138. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105139. */
  105140. protected _twoSidedLighting: boolean;
  105141. /**
  105142. * Defines the alpha limits in alpha test mode.
  105143. */
  105144. protected _alphaCutOff: number;
  105145. /**
  105146. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105147. */
  105148. protected _forceAlphaTest: boolean;
  105149. /**
  105150. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105151. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105152. */
  105153. protected _useAlphaFresnel: boolean;
  105154. /**
  105155. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105156. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105157. */
  105158. protected _useLinearAlphaFresnel: boolean;
  105159. /**
  105160. * The transparency mode of the material.
  105161. */
  105162. protected _transparencyMode: Nullable<number>;
  105163. /**
  105164. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105165. * from cos thetav and roughness:
  105166. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105167. */
  105168. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105169. /**
  105170. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105171. */
  105172. protected _forceIrradianceInFragment: boolean;
  105173. /**
  105174. * Force normal to face away from face.
  105175. */
  105176. protected _forceNormalForward: boolean;
  105177. /**
  105178. * Enables specular anti aliasing in the PBR shader.
  105179. * It will both interacts on the Geometry for analytical and IBL lighting.
  105180. * It also prefilter the roughness map based on the bump values.
  105181. */
  105182. protected _enableSpecularAntiAliasing: boolean;
  105183. /**
  105184. * Default configuration related to image processing available in the PBR Material.
  105185. */
  105186. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105187. /**
  105188. * Keep track of the image processing observer to allow dispose and replace.
  105189. */
  105190. private _imageProcessingObserver;
  105191. /**
  105192. * Attaches a new image processing configuration to the PBR Material.
  105193. * @param configuration
  105194. */
  105195. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105196. /**
  105197. * Stores the available render targets.
  105198. */
  105199. private _renderTargets;
  105200. /**
  105201. * Sets the global ambient color for the material used in lighting calculations.
  105202. */
  105203. private _globalAmbientColor;
  105204. /**
  105205. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105206. */
  105207. private _useLogarithmicDepth;
  105208. /**
  105209. * If set to true, no lighting calculations will be applied.
  105210. */
  105211. private _unlit;
  105212. private _debugMode;
  105213. /**
  105214. * @hidden
  105215. * This is reserved for the inspector.
  105216. * Defines the material debug mode.
  105217. * It helps seeing only some components of the material while troubleshooting.
  105218. */
  105219. debugMode: number;
  105220. /**
  105221. * @hidden
  105222. * This is reserved for the inspector.
  105223. * Specify from where on screen the debug mode should start.
  105224. * The value goes from -1 (full screen) to 1 (not visible)
  105225. * It helps with side by side comparison against the final render
  105226. * This defaults to -1
  105227. */
  105228. private debugLimit;
  105229. /**
  105230. * @hidden
  105231. * This is reserved for the inspector.
  105232. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105233. * You can use the factor to better multiply the final value.
  105234. */
  105235. private debugFactor;
  105236. /**
  105237. * Defines the clear coat layer parameters for the material.
  105238. */
  105239. readonly clearCoat: PBRClearCoatConfiguration;
  105240. /**
  105241. * Defines the anisotropic parameters for the material.
  105242. */
  105243. readonly anisotropy: PBRAnisotropicConfiguration;
  105244. /**
  105245. * Defines the BRDF parameters for the material.
  105246. */
  105247. readonly brdf: PBRBRDFConfiguration;
  105248. /**
  105249. * Defines the Sheen parameters for the material.
  105250. */
  105251. readonly sheen: PBRSheenConfiguration;
  105252. /**
  105253. * Defines the SubSurface parameters for the material.
  105254. */
  105255. readonly subSurface: PBRSubSurfaceConfiguration;
  105256. /**
  105257. * Custom callback helping to override the default shader used in the material.
  105258. */
  105259. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105260. /**
  105261. * Instantiates a new PBRMaterial instance.
  105262. *
  105263. * @param name The material name
  105264. * @param scene The scene the material will be use in.
  105265. */
  105266. constructor(name: string, scene: Scene);
  105267. /**
  105268. * Gets a boolean indicating that current material needs to register RTT
  105269. */
  105270. readonly hasRenderTargetTextures: boolean;
  105271. /**
  105272. * Gets the name of the material class.
  105273. */
  105274. getClassName(): string;
  105275. /**
  105276. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105277. */
  105278. /**
  105279. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105280. */
  105281. useLogarithmicDepth: boolean;
  105282. /**
  105283. * Gets the current transparency mode.
  105284. */
  105285. /**
  105286. * Sets the transparency mode of the material.
  105287. *
  105288. * | Value | Type | Description |
  105289. * | ----- | ----------------------------------- | ----------- |
  105290. * | 0 | OPAQUE | |
  105291. * | 1 | ALPHATEST | |
  105292. * | 2 | ALPHABLEND | |
  105293. * | 3 | ALPHATESTANDBLEND | |
  105294. *
  105295. */
  105296. transparencyMode: Nullable<number>;
  105297. /**
  105298. * Returns true if alpha blending should be disabled.
  105299. */
  105300. private readonly _disableAlphaBlending;
  105301. /**
  105302. * Specifies whether or not this material should be rendered in alpha blend mode.
  105303. */
  105304. needAlphaBlending(): boolean;
  105305. /**
  105306. * Specifies if the mesh will require alpha blending.
  105307. * @param mesh - BJS mesh.
  105308. */
  105309. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105310. /**
  105311. * Specifies whether or not this material should be rendered in alpha test mode.
  105312. */
  105313. needAlphaTesting(): boolean;
  105314. /**
  105315. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105316. */
  105317. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105318. /**
  105319. * Gets the texture used for the alpha test.
  105320. */
  105321. getAlphaTestTexture(): Nullable<BaseTexture>;
  105322. /**
  105323. * Specifies that the submesh is ready to be used.
  105324. * @param mesh - BJS mesh.
  105325. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105326. * @param useInstances - Specifies that instances should be used.
  105327. * @returns - boolean indicating that the submesh is ready or not.
  105328. */
  105329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105330. /**
  105331. * Specifies if the material uses metallic roughness workflow.
  105332. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105333. */
  105334. isMetallicWorkflow(): boolean;
  105335. private _prepareEffect;
  105336. private _prepareDefines;
  105337. /**
  105338. * Force shader compilation
  105339. */
  105340. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105341. clipPlane: boolean;
  105342. }>): void;
  105343. /**
  105344. * Initializes the uniform buffer layout for the shader.
  105345. */
  105346. buildUniformLayout(): void;
  105347. /**
  105348. * Unbinds the material from the mesh
  105349. */
  105350. unbind(): void;
  105351. /**
  105352. * Binds the submesh data.
  105353. * @param world - The world matrix.
  105354. * @param mesh - The BJS mesh.
  105355. * @param subMesh - A submesh of the BJS mesh.
  105356. */
  105357. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105358. /**
  105359. * Returns the animatable textures.
  105360. * @returns - Array of animatable textures.
  105361. */
  105362. getAnimatables(): IAnimatable[];
  105363. /**
  105364. * Returns the texture used for reflections.
  105365. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105366. */
  105367. private _getReflectionTexture;
  105368. /**
  105369. * Returns an array of the actively used textures.
  105370. * @returns - Array of BaseTextures
  105371. */
  105372. getActiveTextures(): BaseTexture[];
  105373. /**
  105374. * Checks to see if a texture is used in the material.
  105375. * @param texture - Base texture to use.
  105376. * @returns - Boolean specifying if a texture is used in the material.
  105377. */
  105378. hasTexture(texture: BaseTexture): boolean;
  105379. /**
  105380. * Disposes the resources of the material.
  105381. * @param forceDisposeEffect - Forces the disposal of effects.
  105382. * @param forceDisposeTextures - Forces the disposal of all textures.
  105383. */
  105384. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105385. }
  105386. }
  105387. declare module BABYLON {
  105388. /**
  105389. * The Physically based material of BJS.
  105390. *
  105391. * This offers the main features of a standard PBR material.
  105392. * For more information, please refer to the documentation :
  105393. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105394. */
  105395. export class PBRMaterial extends PBRBaseMaterial {
  105396. /**
  105397. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105398. */
  105399. static readonly PBRMATERIAL_OPAQUE: number;
  105400. /**
  105401. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105402. */
  105403. static readonly PBRMATERIAL_ALPHATEST: number;
  105404. /**
  105405. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105406. */
  105407. static readonly PBRMATERIAL_ALPHABLEND: number;
  105408. /**
  105409. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105410. * They are also discarded below the alpha cutoff threshold to improve performances.
  105411. */
  105412. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105413. /**
  105414. * Defines the default value of how much AO map is occluding the analytical lights
  105415. * (point spot...).
  105416. */
  105417. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105418. /**
  105419. * Intensity of the direct lights e.g. the four lights available in your scene.
  105420. * This impacts both the direct diffuse and specular highlights.
  105421. */
  105422. directIntensity: number;
  105423. /**
  105424. * Intensity of the emissive part of the material.
  105425. * This helps controlling the emissive effect without modifying the emissive color.
  105426. */
  105427. emissiveIntensity: number;
  105428. /**
  105429. * Intensity of the environment e.g. how much the environment will light the object
  105430. * either through harmonics for rough material or through the refelction for shiny ones.
  105431. */
  105432. environmentIntensity: number;
  105433. /**
  105434. * This is a special control allowing the reduction of the specular highlights coming from the
  105435. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105436. */
  105437. specularIntensity: number;
  105438. /**
  105439. * Debug Control allowing disabling the bump map on this material.
  105440. */
  105441. disableBumpMap: boolean;
  105442. /**
  105443. * AKA Diffuse Texture in standard nomenclature.
  105444. */
  105445. albedoTexture: BaseTexture;
  105446. /**
  105447. * AKA Occlusion Texture in other nomenclature.
  105448. */
  105449. ambientTexture: BaseTexture;
  105450. /**
  105451. * AKA Occlusion Texture Intensity in other nomenclature.
  105452. */
  105453. ambientTextureStrength: number;
  105454. /**
  105455. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105456. * 1 means it completely occludes it
  105457. * 0 mean it has no impact
  105458. */
  105459. ambientTextureImpactOnAnalyticalLights: number;
  105460. /**
  105461. * Stores the alpha values in a texture.
  105462. */
  105463. opacityTexture: BaseTexture;
  105464. /**
  105465. * Stores the reflection values in a texture.
  105466. */
  105467. reflectionTexture: Nullable<BaseTexture>;
  105468. /**
  105469. * Stores the emissive values in a texture.
  105470. */
  105471. emissiveTexture: BaseTexture;
  105472. /**
  105473. * AKA Specular texture in other nomenclature.
  105474. */
  105475. reflectivityTexture: BaseTexture;
  105476. /**
  105477. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105478. */
  105479. metallicTexture: BaseTexture;
  105480. /**
  105481. * Specifies the metallic scalar of the metallic/roughness workflow.
  105482. * Can also be used to scale the metalness values of the metallic texture.
  105483. */
  105484. metallic: Nullable<number>;
  105485. /**
  105486. * Specifies the roughness scalar of the metallic/roughness workflow.
  105487. * Can also be used to scale the roughness values of the metallic texture.
  105488. */
  105489. roughness: Nullable<number>;
  105490. /**
  105491. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105492. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105493. */
  105494. microSurfaceTexture: BaseTexture;
  105495. /**
  105496. * Stores surface normal data used to displace a mesh in a texture.
  105497. */
  105498. bumpTexture: BaseTexture;
  105499. /**
  105500. * Stores the pre-calculated light information of a mesh in a texture.
  105501. */
  105502. lightmapTexture: BaseTexture;
  105503. /**
  105504. * Stores the refracted light information in a texture.
  105505. */
  105506. refractionTexture: Nullable<BaseTexture>;
  105507. /**
  105508. * The color of a material in ambient lighting.
  105509. */
  105510. ambientColor: Color3;
  105511. /**
  105512. * AKA Diffuse Color in other nomenclature.
  105513. */
  105514. albedoColor: Color3;
  105515. /**
  105516. * AKA Specular Color in other nomenclature.
  105517. */
  105518. reflectivityColor: Color3;
  105519. /**
  105520. * The color reflected from the material.
  105521. */
  105522. reflectionColor: Color3;
  105523. /**
  105524. * The color emitted from the material.
  105525. */
  105526. emissiveColor: Color3;
  105527. /**
  105528. * AKA Glossiness in other nomenclature.
  105529. */
  105530. microSurface: number;
  105531. /**
  105532. * source material index of refraction (IOR)' / 'destination material IOR.
  105533. */
  105534. indexOfRefraction: number;
  105535. /**
  105536. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105537. */
  105538. invertRefractionY: boolean;
  105539. /**
  105540. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105541. * Materials half opaque for instance using refraction could benefit from this control.
  105542. */
  105543. linkRefractionWithTransparency: boolean;
  105544. /**
  105545. * If true, the light map contains occlusion information instead of lighting info.
  105546. */
  105547. useLightmapAsShadowmap: boolean;
  105548. /**
  105549. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105550. */
  105551. useAlphaFromAlbedoTexture: boolean;
  105552. /**
  105553. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105554. */
  105555. forceAlphaTest: boolean;
  105556. /**
  105557. * Defines the alpha limits in alpha test mode.
  105558. */
  105559. alphaCutOff: number;
  105560. /**
  105561. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105562. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105563. */
  105564. useSpecularOverAlpha: boolean;
  105565. /**
  105566. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105567. */
  105568. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105569. /**
  105570. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105571. */
  105572. useRoughnessFromMetallicTextureAlpha: boolean;
  105573. /**
  105574. * Specifies if the metallic texture contains the roughness information in its green channel.
  105575. */
  105576. useRoughnessFromMetallicTextureGreen: boolean;
  105577. /**
  105578. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105579. */
  105580. useMetallnessFromMetallicTextureBlue: boolean;
  105581. /**
  105582. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105583. */
  105584. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105585. /**
  105586. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105587. */
  105588. useAmbientInGrayScale: boolean;
  105589. /**
  105590. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105591. * The material will try to infer what glossiness each pixel should be.
  105592. */
  105593. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105594. /**
  105595. * BJS is using an harcoded light falloff based on a manually sets up range.
  105596. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105597. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105598. */
  105599. /**
  105600. * BJS is using an harcoded light falloff based on a manually sets up range.
  105601. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105602. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105603. */
  105604. usePhysicalLightFalloff: boolean;
  105605. /**
  105606. * In order to support the falloff compatibility with gltf, a special mode has been added
  105607. * to reproduce the gltf light falloff.
  105608. */
  105609. /**
  105610. * In order to support the falloff compatibility with gltf, a special mode has been added
  105611. * to reproduce the gltf light falloff.
  105612. */
  105613. useGLTFLightFalloff: boolean;
  105614. /**
  105615. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105616. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105617. */
  105618. useRadianceOverAlpha: boolean;
  105619. /**
  105620. * Allows using an object space normal map (instead of tangent space).
  105621. */
  105622. useObjectSpaceNormalMap: boolean;
  105623. /**
  105624. * Allows using the bump map in parallax mode.
  105625. */
  105626. useParallax: boolean;
  105627. /**
  105628. * Allows using the bump map in parallax occlusion mode.
  105629. */
  105630. useParallaxOcclusion: boolean;
  105631. /**
  105632. * Controls the scale bias of the parallax mode.
  105633. */
  105634. parallaxScaleBias: number;
  105635. /**
  105636. * If sets to true, disables all the lights affecting the material.
  105637. */
  105638. disableLighting: boolean;
  105639. /**
  105640. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105641. */
  105642. forceIrradianceInFragment: boolean;
  105643. /**
  105644. * Number of Simultaneous lights allowed on the material.
  105645. */
  105646. maxSimultaneousLights: number;
  105647. /**
  105648. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105649. */
  105650. invertNormalMapX: boolean;
  105651. /**
  105652. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105653. */
  105654. invertNormalMapY: boolean;
  105655. /**
  105656. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105657. */
  105658. twoSidedLighting: boolean;
  105659. /**
  105660. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105661. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105662. */
  105663. useAlphaFresnel: boolean;
  105664. /**
  105665. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105666. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105667. */
  105668. useLinearAlphaFresnel: boolean;
  105669. /**
  105670. * Let user defines the brdf lookup texture used for IBL.
  105671. * A default 8bit version is embedded but you could point at :
  105672. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105673. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105674. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105675. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105676. */
  105677. environmentBRDFTexture: Nullable<BaseTexture>;
  105678. /**
  105679. * Force normal to face away from face.
  105680. */
  105681. forceNormalForward: boolean;
  105682. /**
  105683. * Enables specular anti aliasing in the PBR shader.
  105684. * It will both interacts on the Geometry for analytical and IBL lighting.
  105685. * It also prefilter the roughness map based on the bump values.
  105686. */
  105687. enableSpecularAntiAliasing: boolean;
  105688. /**
  105689. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105690. * makes the reflect vector face the model (under horizon).
  105691. */
  105692. useHorizonOcclusion: boolean;
  105693. /**
  105694. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105695. * too much the area relying on ambient texture to define their ambient occlusion.
  105696. */
  105697. useRadianceOcclusion: boolean;
  105698. /**
  105699. * If set to true, no lighting calculations will be applied.
  105700. */
  105701. unlit: boolean;
  105702. /**
  105703. * Gets the image processing configuration used either in this material.
  105704. */
  105705. /**
  105706. * Sets the Default image processing configuration used either in the this material.
  105707. *
  105708. * If sets to null, the scene one is in use.
  105709. */
  105710. imageProcessingConfiguration: ImageProcessingConfiguration;
  105711. /**
  105712. * Gets wether the color curves effect is enabled.
  105713. */
  105714. /**
  105715. * Sets wether the color curves effect is enabled.
  105716. */
  105717. cameraColorCurvesEnabled: boolean;
  105718. /**
  105719. * Gets wether the color grading effect is enabled.
  105720. */
  105721. /**
  105722. * Gets wether the color grading effect is enabled.
  105723. */
  105724. cameraColorGradingEnabled: boolean;
  105725. /**
  105726. * Gets wether tonemapping is enabled or not.
  105727. */
  105728. /**
  105729. * Sets wether tonemapping is enabled or not
  105730. */
  105731. cameraToneMappingEnabled: boolean;
  105732. /**
  105733. * The camera exposure used on this material.
  105734. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105735. * This corresponds to a photographic exposure.
  105736. */
  105737. /**
  105738. * The camera exposure used on this material.
  105739. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105740. * This corresponds to a photographic exposure.
  105741. */
  105742. cameraExposure: number;
  105743. /**
  105744. * Gets The camera contrast used on this material.
  105745. */
  105746. /**
  105747. * Sets The camera contrast used on this material.
  105748. */
  105749. cameraContrast: number;
  105750. /**
  105751. * Gets the Color Grading 2D Lookup Texture.
  105752. */
  105753. /**
  105754. * Sets the Color Grading 2D Lookup Texture.
  105755. */
  105756. cameraColorGradingTexture: Nullable<BaseTexture>;
  105757. /**
  105758. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105759. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105760. * 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;
  105761. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105762. */
  105763. /**
  105764. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105765. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105766. * 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;
  105767. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105768. */
  105769. cameraColorCurves: Nullable<ColorCurves>;
  105770. /**
  105771. * Instantiates a new PBRMaterial instance.
  105772. *
  105773. * @param name The material name
  105774. * @param scene The scene the material will be use in.
  105775. */
  105776. constructor(name: string, scene: Scene);
  105777. /**
  105778. * Returns the name of this material class.
  105779. */
  105780. getClassName(): string;
  105781. /**
  105782. * Makes a duplicate of the current material.
  105783. * @param name - name to use for the new material.
  105784. */
  105785. clone(name: string): PBRMaterial;
  105786. /**
  105787. * Serializes this PBR Material.
  105788. * @returns - An object with the serialized material.
  105789. */
  105790. serialize(): any;
  105791. /**
  105792. * Parses a PBR Material from a serialized object.
  105793. * @param source - Serialized object.
  105794. * @param scene - BJS scene instance.
  105795. * @param rootUrl - url for the scene object
  105796. * @returns - PBRMaterial
  105797. */
  105798. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105799. }
  105800. }
  105801. declare module BABYLON {
  105802. /**
  105803. * Direct draw surface info
  105804. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105805. */
  105806. export interface DDSInfo {
  105807. /**
  105808. * Width of the texture
  105809. */
  105810. width: number;
  105811. /**
  105812. * Width of the texture
  105813. */
  105814. height: number;
  105815. /**
  105816. * Number of Mipmaps for the texture
  105817. * @see https://en.wikipedia.org/wiki/Mipmap
  105818. */
  105819. mipmapCount: number;
  105820. /**
  105821. * If the textures format is a known fourCC format
  105822. * @see https://www.fourcc.org/
  105823. */
  105824. isFourCC: boolean;
  105825. /**
  105826. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105827. */
  105828. isRGB: boolean;
  105829. /**
  105830. * If the texture is a lumincance format
  105831. */
  105832. isLuminance: boolean;
  105833. /**
  105834. * If this is a cube texture
  105835. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105836. */
  105837. isCube: boolean;
  105838. /**
  105839. * If the texture is a compressed format eg. FOURCC_DXT1
  105840. */
  105841. isCompressed: boolean;
  105842. /**
  105843. * The dxgiFormat of the texture
  105844. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105845. */
  105846. dxgiFormat: number;
  105847. /**
  105848. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105849. */
  105850. textureType: number;
  105851. /**
  105852. * Sphericle polynomial created for the dds texture
  105853. */
  105854. sphericalPolynomial?: SphericalPolynomial;
  105855. }
  105856. /**
  105857. * Class used to provide DDS decompression tools
  105858. */
  105859. export class DDSTools {
  105860. /**
  105861. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105862. */
  105863. static StoreLODInAlphaChannel: boolean;
  105864. /**
  105865. * Gets DDS information from an array buffer
  105866. * @param arrayBuffer defines the array buffer to read data from
  105867. * @returns the DDS information
  105868. */
  105869. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105870. private static _FloatView;
  105871. private static _Int32View;
  105872. private static _ToHalfFloat;
  105873. private static _FromHalfFloat;
  105874. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105875. private static _GetHalfFloatRGBAArrayBuffer;
  105876. private static _GetFloatRGBAArrayBuffer;
  105877. private static _GetFloatAsUIntRGBAArrayBuffer;
  105878. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105879. private static _GetRGBAArrayBuffer;
  105880. private static _ExtractLongWordOrder;
  105881. private static _GetRGBArrayBuffer;
  105882. private static _GetLuminanceArrayBuffer;
  105883. /**
  105884. * Uploads DDS Levels to a Babylon Texture
  105885. * @hidden
  105886. */
  105887. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105888. }
  105889. interface Engine {
  105890. /**
  105891. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105892. * @param rootUrl defines the url where the file to load is located
  105893. * @param scene defines the current scene
  105894. * @param lodScale defines scale to apply to the mip map selection
  105895. * @param lodOffset defines offset to apply to the mip map selection
  105896. * @param onLoad defines an optional callback raised when the texture is loaded
  105897. * @param onError defines an optional callback raised if there is an issue to load the texture
  105898. * @param format defines the format of the data
  105899. * @param forcedExtension defines the extension to use to pick the right loader
  105900. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105901. * @returns the cube texture as an InternalTexture
  105902. */
  105903. 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;
  105904. }
  105905. }
  105906. declare module BABYLON {
  105907. /**
  105908. * Implementation of the DDS Texture Loader.
  105909. * @hidden
  105910. */
  105911. export class _DDSTextureLoader implements IInternalTextureLoader {
  105912. /**
  105913. * Defines wether the loader supports cascade loading the different faces.
  105914. */
  105915. readonly supportCascades: boolean;
  105916. /**
  105917. * This returns if the loader support the current file information.
  105918. * @param extension defines the file extension of the file being loaded
  105919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105920. * @param fallback defines the fallback internal texture if any
  105921. * @param isBase64 defines whether the texture is encoded as a base64
  105922. * @param isBuffer defines whether the texture data are stored as a buffer
  105923. * @returns true if the loader can load the specified file
  105924. */
  105925. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105926. /**
  105927. * Transform the url before loading if required.
  105928. * @param rootUrl the url of the texture
  105929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105930. * @returns the transformed texture
  105931. */
  105932. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105933. /**
  105934. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105935. * @param rootUrl the url of the texture
  105936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105937. * @returns the fallback texture
  105938. */
  105939. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105940. /**
  105941. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105942. * @param data contains the texture data
  105943. * @param texture defines the BabylonJS internal texture
  105944. * @param createPolynomials will be true if polynomials have been requested
  105945. * @param onLoad defines the callback to trigger once the texture is ready
  105946. * @param onError defines the callback to trigger in case of error
  105947. */
  105948. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105949. /**
  105950. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105951. * @param data contains the texture data
  105952. * @param texture defines the BabylonJS internal texture
  105953. * @param callback defines the method to call once ready to upload
  105954. */
  105955. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105956. }
  105957. }
  105958. declare module BABYLON {
  105959. /** @hidden */
  105960. export var rgbdEncodePixelShader: {
  105961. name: string;
  105962. shader: string;
  105963. };
  105964. }
  105965. declare module BABYLON {
  105966. /**
  105967. * Raw texture data and descriptor sufficient for WebGL texture upload
  105968. */
  105969. export interface EnvironmentTextureInfo {
  105970. /**
  105971. * Version of the environment map
  105972. */
  105973. version: number;
  105974. /**
  105975. * Width of image
  105976. */
  105977. width: number;
  105978. /**
  105979. * Irradiance information stored in the file.
  105980. */
  105981. irradiance: any;
  105982. /**
  105983. * Specular information stored in the file.
  105984. */
  105985. specular: any;
  105986. }
  105987. /**
  105988. * Sets of helpers addressing the serialization and deserialization of environment texture
  105989. * stored in a BabylonJS env file.
  105990. * Those files are usually stored as .env files.
  105991. */
  105992. export class EnvironmentTextureTools {
  105993. /**
  105994. * Magic number identifying the env file.
  105995. */
  105996. private static _MagicBytes;
  105997. /**
  105998. * Gets the environment info from an env file.
  105999. * @param data The array buffer containing the .env bytes.
  106000. * @returns the environment file info (the json header) if successfully parsed.
  106001. */
  106002. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106003. /**
  106004. * Creates an environment texture from a loaded cube texture.
  106005. * @param texture defines the cube texture to convert in env file
  106006. * @return a promise containing the environment data if succesfull.
  106007. */
  106008. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106009. /**
  106010. * Creates a JSON representation of the spherical data.
  106011. * @param texture defines the texture containing the polynomials
  106012. * @return the JSON representation of the spherical info
  106013. */
  106014. private static _CreateEnvTextureIrradiance;
  106015. /**
  106016. * Uploads the texture info contained in the env file to the GPU.
  106017. * @param texture defines the internal texture to upload to
  106018. * @param arrayBuffer defines the buffer cotaining the data to load
  106019. * @param info defines the texture info retrieved through the GetEnvInfo method
  106020. * @returns a promise
  106021. */
  106022. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106023. /**
  106024. * Uploads the levels of image data to the GPU.
  106025. * @param texture defines the internal texture to upload to
  106026. * @param imageData defines the array buffer views of image data [mipmap][face]
  106027. * @returns a promise
  106028. */
  106029. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106030. /**
  106031. * Uploads spherical polynomials information to the texture.
  106032. * @param texture defines the texture we are trying to upload the information to
  106033. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106034. */
  106035. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106036. /** @hidden */
  106037. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106038. }
  106039. }
  106040. declare module BABYLON {
  106041. /**
  106042. * Implementation of the ENV Texture Loader.
  106043. * @hidden
  106044. */
  106045. export class _ENVTextureLoader implements IInternalTextureLoader {
  106046. /**
  106047. * Defines wether the loader supports cascade loading the different faces.
  106048. */
  106049. readonly supportCascades: boolean;
  106050. /**
  106051. * This returns if the loader support the current file information.
  106052. * @param extension defines the file extension of the file being loaded
  106053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106054. * @param fallback defines the fallback internal texture if any
  106055. * @param isBase64 defines whether the texture is encoded as a base64
  106056. * @param isBuffer defines whether the texture data are stored as a buffer
  106057. * @returns true if the loader can load the specified file
  106058. */
  106059. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106060. /**
  106061. * Transform the url before loading if required.
  106062. * @param rootUrl the url of the texture
  106063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106064. * @returns the transformed texture
  106065. */
  106066. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106067. /**
  106068. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106069. * @param rootUrl the url of the texture
  106070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106071. * @returns the fallback texture
  106072. */
  106073. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106074. /**
  106075. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106076. * @param data contains the texture data
  106077. * @param texture defines the BabylonJS internal texture
  106078. * @param createPolynomials will be true if polynomials have been requested
  106079. * @param onLoad defines the callback to trigger once the texture is ready
  106080. * @param onError defines the callback to trigger in case of error
  106081. */
  106082. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106083. /**
  106084. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106085. * @param data contains the texture data
  106086. * @param texture defines the BabylonJS internal texture
  106087. * @param callback defines the method to call once ready to upload
  106088. */
  106089. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106090. }
  106091. }
  106092. declare module BABYLON {
  106093. /**
  106094. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106095. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106096. */
  106097. export class KhronosTextureContainer {
  106098. /** contents of the KTX container file */
  106099. arrayBuffer: any;
  106100. private static HEADER_LEN;
  106101. private static COMPRESSED_2D;
  106102. private static COMPRESSED_3D;
  106103. private static TEX_2D;
  106104. private static TEX_3D;
  106105. /**
  106106. * Gets the openGL type
  106107. */
  106108. glType: number;
  106109. /**
  106110. * Gets the openGL type size
  106111. */
  106112. glTypeSize: number;
  106113. /**
  106114. * Gets the openGL format
  106115. */
  106116. glFormat: number;
  106117. /**
  106118. * Gets the openGL internal format
  106119. */
  106120. glInternalFormat: number;
  106121. /**
  106122. * Gets the base internal format
  106123. */
  106124. glBaseInternalFormat: number;
  106125. /**
  106126. * Gets image width in pixel
  106127. */
  106128. pixelWidth: number;
  106129. /**
  106130. * Gets image height in pixel
  106131. */
  106132. pixelHeight: number;
  106133. /**
  106134. * Gets image depth in pixels
  106135. */
  106136. pixelDepth: number;
  106137. /**
  106138. * Gets the number of array elements
  106139. */
  106140. numberOfArrayElements: number;
  106141. /**
  106142. * Gets the number of faces
  106143. */
  106144. numberOfFaces: number;
  106145. /**
  106146. * Gets the number of mipmap levels
  106147. */
  106148. numberOfMipmapLevels: number;
  106149. /**
  106150. * Gets the bytes of key value data
  106151. */
  106152. bytesOfKeyValueData: number;
  106153. /**
  106154. * Gets the load type
  106155. */
  106156. loadType: number;
  106157. /**
  106158. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106159. */
  106160. isInvalid: boolean;
  106161. /**
  106162. * Creates a new KhronosTextureContainer
  106163. * @param arrayBuffer contents of the KTX container file
  106164. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106165. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106166. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106167. */
  106168. constructor(
  106169. /** contents of the KTX container file */
  106170. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106171. /**
  106172. * Uploads KTX content to a Babylon Texture.
  106173. * It is assumed that the texture has already been created & is currently bound
  106174. * @hidden
  106175. */
  106176. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106177. private _upload2DCompressedLevels;
  106178. }
  106179. }
  106180. declare module BABYLON {
  106181. /**
  106182. * Implementation of the KTX Texture Loader.
  106183. * @hidden
  106184. */
  106185. export class _KTXTextureLoader implements IInternalTextureLoader {
  106186. /**
  106187. * Defines wether the loader supports cascade loading the different faces.
  106188. */
  106189. readonly supportCascades: boolean;
  106190. /**
  106191. * This returns if the loader support the current file information.
  106192. * @param extension defines the file extension of the file being loaded
  106193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106194. * @param fallback defines the fallback internal texture if any
  106195. * @param isBase64 defines whether the texture is encoded as a base64
  106196. * @param isBuffer defines whether the texture data are stored as a buffer
  106197. * @returns true if the loader can load the specified file
  106198. */
  106199. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106200. /**
  106201. * Transform the url before loading if required.
  106202. * @param rootUrl the url of the texture
  106203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106204. * @returns the transformed texture
  106205. */
  106206. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106207. /**
  106208. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106209. * @param rootUrl the url of the texture
  106210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106211. * @returns the fallback texture
  106212. */
  106213. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106214. /**
  106215. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106216. * @param data contains the texture data
  106217. * @param texture defines the BabylonJS internal texture
  106218. * @param createPolynomials will be true if polynomials have been requested
  106219. * @param onLoad defines the callback to trigger once the texture is ready
  106220. * @param onError defines the callback to trigger in case of error
  106221. */
  106222. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106223. /**
  106224. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106225. * @param data contains the texture data
  106226. * @param texture defines the BabylonJS internal texture
  106227. * @param callback defines the method to call once ready to upload
  106228. */
  106229. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106230. }
  106231. }
  106232. declare module BABYLON {
  106233. /** @hidden */
  106234. export var _forceSceneHelpersToBundle: boolean;
  106235. interface Scene {
  106236. /**
  106237. * Creates a default light for the scene.
  106238. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106239. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106240. */
  106241. createDefaultLight(replace?: boolean): void;
  106242. /**
  106243. * Creates a default camera for the scene.
  106244. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106245. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106246. * @param replace has default false, when true replaces the active camera in the scene
  106247. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106248. */
  106249. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106250. /**
  106251. * Creates a default camera and a default light.
  106252. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106253. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106254. * @param replace has the default false, when true replaces the active camera/light in the scene
  106255. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106256. */
  106257. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106258. /**
  106259. * Creates a new sky box
  106260. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106261. * @param environmentTexture defines the texture to use as environment texture
  106262. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106263. * @param scale defines the overall scale of the skybox
  106264. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106265. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106266. * @returns a new mesh holding the sky box
  106267. */
  106268. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106269. /**
  106270. * Creates a new environment
  106271. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106272. * @param options defines the options you can use to configure the environment
  106273. * @returns the new EnvironmentHelper
  106274. */
  106275. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106276. /**
  106277. * Creates a new VREXperienceHelper
  106278. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106279. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106280. * @returns a new VREXperienceHelper
  106281. */
  106282. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106283. /**
  106284. * Creates a new XREXperienceHelper
  106285. * @see http://doc.babylonjs.com/how_to/webxr
  106286. * @returns a promise for a new XREXperienceHelper
  106287. */
  106288. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106289. }
  106290. }
  106291. declare module BABYLON {
  106292. /**
  106293. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106294. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106295. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106296. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106297. */
  106298. export class VideoDome extends TransformNode {
  106299. /**
  106300. * Define the video source as a Monoscopic panoramic 360 video.
  106301. */
  106302. static readonly MODE_MONOSCOPIC: number;
  106303. /**
  106304. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106305. */
  106306. static readonly MODE_TOPBOTTOM: number;
  106307. /**
  106308. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106309. */
  106310. static readonly MODE_SIDEBYSIDE: number;
  106311. private _useDirectMapping;
  106312. /**
  106313. * The video texture being displayed on the sphere
  106314. */
  106315. protected _videoTexture: VideoTexture;
  106316. /**
  106317. * Gets the video texture being displayed on the sphere
  106318. */
  106319. readonly videoTexture: VideoTexture;
  106320. /**
  106321. * The skybox material
  106322. */
  106323. protected _material: BackgroundMaterial;
  106324. /**
  106325. * The surface used for the skybox
  106326. */
  106327. protected _mesh: Mesh;
  106328. /**
  106329. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106330. * Also see the options.resolution property.
  106331. */
  106332. fovMultiplier: number;
  106333. private _videoMode;
  106334. /**
  106335. * Gets or set the current video mode for the video. It can be:
  106336. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106337. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106338. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106339. */
  106340. videoMode: number;
  106341. /**
  106342. * Oberserver used in Stereoscopic VR Mode.
  106343. */
  106344. private _onBeforeCameraRenderObserver;
  106345. /**
  106346. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106347. * @param name Element's name, child elements will append suffixes for their own names.
  106348. * @param urlsOrVideo defines the url(s) or the video element to use
  106349. * @param options An object containing optional or exposed sub element properties
  106350. */
  106351. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106352. resolution?: number;
  106353. clickToPlay?: boolean;
  106354. autoPlay?: boolean;
  106355. loop?: boolean;
  106356. size?: number;
  106357. poster?: string;
  106358. faceForward?: boolean;
  106359. useDirectMapping?: boolean;
  106360. }, scene: Scene);
  106361. private _changeVideoMode;
  106362. /**
  106363. * Releases resources associated with this node.
  106364. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106365. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106366. */
  106367. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106368. }
  106369. }
  106370. declare module BABYLON {
  106371. /**
  106372. * This class can be used to get instrumentation data from a Babylon engine
  106373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106374. */
  106375. export class EngineInstrumentation implements IDisposable {
  106376. /**
  106377. * Define the instrumented engine.
  106378. */
  106379. engine: Engine;
  106380. private _captureGPUFrameTime;
  106381. private _gpuFrameTimeToken;
  106382. private _gpuFrameTime;
  106383. private _captureShaderCompilationTime;
  106384. private _shaderCompilationTime;
  106385. private _onBeginFrameObserver;
  106386. private _onEndFrameObserver;
  106387. private _onBeforeShaderCompilationObserver;
  106388. private _onAfterShaderCompilationObserver;
  106389. /**
  106390. * Gets the perf counter used for GPU frame time
  106391. */
  106392. readonly gpuFrameTimeCounter: PerfCounter;
  106393. /**
  106394. * Gets the GPU frame time capture status
  106395. */
  106396. /**
  106397. * Enable or disable the GPU frame time capture
  106398. */
  106399. captureGPUFrameTime: boolean;
  106400. /**
  106401. * Gets the perf counter used for shader compilation time
  106402. */
  106403. readonly shaderCompilationTimeCounter: PerfCounter;
  106404. /**
  106405. * Gets the shader compilation time capture status
  106406. */
  106407. /**
  106408. * Enable or disable the shader compilation time capture
  106409. */
  106410. captureShaderCompilationTime: boolean;
  106411. /**
  106412. * Instantiates a new engine instrumentation.
  106413. * This class can be used to get instrumentation data from a Babylon engine
  106414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106415. * @param engine Defines the engine to instrument
  106416. */
  106417. constructor(
  106418. /**
  106419. * Define the instrumented engine.
  106420. */
  106421. engine: Engine);
  106422. /**
  106423. * Dispose and release associated resources.
  106424. */
  106425. dispose(): void;
  106426. }
  106427. }
  106428. declare module BABYLON {
  106429. /**
  106430. * This class can be used to get instrumentation data from a Babylon engine
  106431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106432. */
  106433. export class SceneInstrumentation implements IDisposable {
  106434. /**
  106435. * Defines the scene to instrument
  106436. */
  106437. scene: Scene;
  106438. private _captureActiveMeshesEvaluationTime;
  106439. private _activeMeshesEvaluationTime;
  106440. private _captureRenderTargetsRenderTime;
  106441. private _renderTargetsRenderTime;
  106442. private _captureFrameTime;
  106443. private _frameTime;
  106444. private _captureRenderTime;
  106445. private _renderTime;
  106446. private _captureInterFrameTime;
  106447. private _interFrameTime;
  106448. private _captureParticlesRenderTime;
  106449. private _particlesRenderTime;
  106450. private _captureSpritesRenderTime;
  106451. private _spritesRenderTime;
  106452. private _capturePhysicsTime;
  106453. private _physicsTime;
  106454. private _captureAnimationsTime;
  106455. private _animationsTime;
  106456. private _captureCameraRenderTime;
  106457. private _cameraRenderTime;
  106458. private _onBeforeActiveMeshesEvaluationObserver;
  106459. private _onAfterActiveMeshesEvaluationObserver;
  106460. private _onBeforeRenderTargetsRenderObserver;
  106461. private _onAfterRenderTargetsRenderObserver;
  106462. private _onAfterRenderObserver;
  106463. private _onBeforeDrawPhaseObserver;
  106464. private _onAfterDrawPhaseObserver;
  106465. private _onBeforeAnimationsObserver;
  106466. private _onBeforeParticlesRenderingObserver;
  106467. private _onAfterParticlesRenderingObserver;
  106468. private _onBeforeSpritesRenderingObserver;
  106469. private _onAfterSpritesRenderingObserver;
  106470. private _onBeforePhysicsObserver;
  106471. private _onAfterPhysicsObserver;
  106472. private _onAfterAnimationsObserver;
  106473. private _onBeforeCameraRenderObserver;
  106474. private _onAfterCameraRenderObserver;
  106475. /**
  106476. * Gets the perf counter used for active meshes evaluation time
  106477. */
  106478. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106479. /**
  106480. * Gets the active meshes evaluation time capture status
  106481. */
  106482. /**
  106483. * Enable or disable the active meshes evaluation time capture
  106484. */
  106485. captureActiveMeshesEvaluationTime: boolean;
  106486. /**
  106487. * Gets the perf counter used for render targets render time
  106488. */
  106489. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106490. /**
  106491. * Gets the render targets render time capture status
  106492. */
  106493. /**
  106494. * Enable or disable the render targets render time capture
  106495. */
  106496. captureRenderTargetsRenderTime: boolean;
  106497. /**
  106498. * Gets the perf counter used for particles render time
  106499. */
  106500. readonly particlesRenderTimeCounter: PerfCounter;
  106501. /**
  106502. * Gets the particles render time capture status
  106503. */
  106504. /**
  106505. * Enable or disable the particles render time capture
  106506. */
  106507. captureParticlesRenderTime: boolean;
  106508. /**
  106509. * Gets the perf counter used for sprites render time
  106510. */
  106511. readonly spritesRenderTimeCounter: PerfCounter;
  106512. /**
  106513. * Gets the sprites render time capture status
  106514. */
  106515. /**
  106516. * Enable or disable the sprites render time capture
  106517. */
  106518. captureSpritesRenderTime: boolean;
  106519. /**
  106520. * Gets the perf counter used for physics time
  106521. */
  106522. readonly physicsTimeCounter: PerfCounter;
  106523. /**
  106524. * Gets the physics time capture status
  106525. */
  106526. /**
  106527. * Enable or disable the physics time capture
  106528. */
  106529. capturePhysicsTime: boolean;
  106530. /**
  106531. * Gets the perf counter used for animations time
  106532. */
  106533. readonly animationsTimeCounter: PerfCounter;
  106534. /**
  106535. * Gets the animations time capture status
  106536. */
  106537. /**
  106538. * Enable or disable the animations time capture
  106539. */
  106540. captureAnimationsTime: boolean;
  106541. /**
  106542. * Gets the perf counter used for frame time capture
  106543. */
  106544. readonly frameTimeCounter: PerfCounter;
  106545. /**
  106546. * Gets the frame time capture status
  106547. */
  106548. /**
  106549. * Enable or disable the frame time capture
  106550. */
  106551. captureFrameTime: boolean;
  106552. /**
  106553. * Gets the perf counter used for inter-frames time capture
  106554. */
  106555. readonly interFrameTimeCounter: PerfCounter;
  106556. /**
  106557. * Gets the inter-frames time capture status
  106558. */
  106559. /**
  106560. * Enable or disable the inter-frames time capture
  106561. */
  106562. captureInterFrameTime: boolean;
  106563. /**
  106564. * Gets the perf counter used for render time capture
  106565. */
  106566. readonly renderTimeCounter: PerfCounter;
  106567. /**
  106568. * Gets the render time capture status
  106569. */
  106570. /**
  106571. * Enable or disable the render time capture
  106572. */
  106573. captureRenderTime: boolean;
  106574. /**
  106575. * Gets the perf counter used for camera render time capture
  106576. */
  106577. readonly cameraRenderTimeCounter: PerfCounter;
  106578. /**
  106579. * Gets the camera render time capture status
  106580. */
  106581. /**
  106582. * Enable or disable the camera render time capture
  106583. */
  106584. captureCameraRenderTime: boolean;
  106585. /**
  106586. * Gets the perf counter used for draw calls
  106587. */
  106588. readonly drawCallsCounter: PerfCounter;
  106589. /**
  106590. * Instantiates a new scene instrumentation.
  106591. * This class can be used to get instrumentation data from a Babylon engine
  106592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106593. * @param scene Defines the scene to instrument
  106594. */
  106595. constructor(
  106596. /**
  106597. * Defines the scene to instrument
  106598. */
  106599. scene: Scene);
  106600. /**
  106601. * Dispose and release associated resources.
  106602. */
  106603. dispose(): void;
  106604. }
  106605. }
  106606. declare module BABYLON {
  106607. /** @hidden */
  106608. export var glowMapGenerationPixelShader: {
  106609. name: string;
  106610. shader: string;
  106611. };
  106612. }
  106613. declare module BABYLON {
  106614. /** @hidden */
  106615. export var glowMapGenerationVertexShader: {
  106616. name: string;
  106617. shader: string;
  106618. };
  106619. }
  106620. declare module BABYLON {
  106621. /**
  106622. * Effect layer options. This helps customizing the behaviour
  106623. * of the effect layer.
  106624. */
  106625. export interface IEffectLayerOptions {
  106626. /**
  106627. * Multiplication factor apply to the canvas size to compute the render target size
  106628. * used to generated the objects (the smaller the faster).
  106629. */
  106630. mainTextureRatio: number;
  106631. /**
  106632. * Enforces a fixed size texture to ensure effect stability across devices.
  106633. */
  106634. mainTextureFixedSize?: number;
  106635. /**
  106636. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106637. */
  106638. alphaBlendingMode: number;
  106639. /**
  106640. * The camera attached to the layer.
  106641. */
  106642. camera: Nullable<Camera>;
  106643. /**
  106644. * The rendering group to draw the layer in.
  106645. */
  106646. renderingGroupId: number;
  106647. }
  106648. /**
  106649. * The effect layer Helps adding post process effect blended with the main pass.
  106650. *
  106651. * This can be for instance use to generate glow or higlight effects on the scene.
  106652. *
  106653. * The effect layer class can not be used directly and is intented to inherited from to be
  106654. * customized per effects.
  106655. */
  106656. export abstract class EffectLayer {
  106657. private _vertexBuffers;
  106658. private _indexBuffer;
  106659. private _cachedDefines;
  106660. private _effectLayerMapGenerationEffect;
  106661. private _effectLayerOptions;
  106662. private _mergeEffect;
  106663. protected _scene: Scene;
  106664. protected _engine: Engine;
  106665. protected _maxSize: number;
  106666. protected _mainTextureDesiredSize: ISize;
  106667. protected _mainTexture: RenderTargetTexture;
  106668. protected _shouldRender: boolean;
  106669. protected _postProcesses: PostProcess[];
  106670. protected _textures: BaseTexture[];
  106671. protected _emissiveTextureAndColor: {
  106672. texture: Nullable<BaseTexture>;
  106673. color: Color4;
  106674. };
  106675. /**
  106676. * The name of the layer
  106677. */
  106678. name: string;
  106679. /**
  106680. * The clear color of the texture used to generate the glow map.
  106681. */
  106682. neutralColor: Color4;
  106683. /**
  106684. * Specifies wether the highlight layer is enabled or not.
  106685. */
  106686. isEnabled: boolean;
  106687. /**
  106688. * Gets the camera attached to the layer.
  106689. */
  106690. readonly camera: Nullable<Camera>;
  106691. /**
  106692. * Gets the rendering group id the layer should render in.
  106693. */
  106694. readonly renderingGroupId: number;
  106695. /**
  106696. * An event triggered when the effect layer has been disposed.
  106697. */
  106698. onDisposeObservable: Observable<EffectLayer>;
  106699. /**
  106700. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106701. */
  106702. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106703. /**
  106704. * An event triggered when the generated texture is being merged in the scene.
  106705. */
  106706. onBeforeComposeObservable: Observable<EffectLayer>;
  106707. /**
  106708. * An event triggered when the generated texture has been merged in the scene.
  106709. */
  106710. onAfterComposeObservable: Observable<EffectLayer>;
  106711. /**
  106712. * An event triggered when the efffect layer changes its size.
  106713. */
  106714. onSizeChangedObservable: Observable<EffectLayer>;
  106715. /** @hidden */
  106716. static _SceneComponentInitialization: (scene: Scene) => void;
  106717. /**
  106718. * Instantiates a new effect Layer and references it in the scene.
  106719. * @param name The name of the layer
  106720. * @param scene The scene to use the layer in
  106721. */
  106722. constructor(
  106723. /** The Friendly of the effect in the scene */
  106724. name: string, scene: Scene);
  106725. /**
  106726. * Get the effect name of the layer.
  106727. * @return The effect name
  106728. */
  106729. abstract getEffectName(): string;
  106730. /**
  106731. * Checks for the readiness of the element composing the layer.
  106732. * @param subMesh the mesh to check for
  106733. * @param useInstances specify wether or not to use instances to render the mesh
  106734. * @return true if ready otherwise, false
  106735. */
  106736. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106737. /**
  106738. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106739. * @returns true if the effect requires stencil during the main canvas render pass.
  106740. */
  106741. abstract needStencil(): boolean;
  106742. /**
  106743. * Create the merge effect. This is the shader use to blit the information back
  106744. * to the main canvas at the end of the scene rendering.
  106745. * @returns The effect containing the shader used to merge the effect on the main canvas
  106746. */
  106747. protected abstract _createMergeEffect(): Effect;
  106748. /**
  106749. * Creates the render target textures and post processes used in the effect layer.
  106750. */
  106751. protected abstract _createTextureAndPostProcesses(): void;
  106752. /**
  106753. * Implementation specific of rendering the generating effect on the main canvas.
  106754. * @param effect The effect used to render through
  106755. */
  106756. protected abstract _internalRender(effect: Effect): void;
  106757. /**
  106758. * Sets the required values for both the emissive texture and and the main color.
  106759. */
  106760. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106761. /**
  106762. * Free any resources and references associated to a mesh.
  106763. * Internal use
  106764. * @param mesh The mesh to free.
  106765. */
  106766. abstract _disposeMesh(mesh: Mesh): void;
  106767. /**
  106768. * Serializes this layer (Glow or Highlight for example)
  106769. * @returns a serialized layer object
  106770. */
  106771. abstract serialize?(): any;
  106772. /**
  106773. * Initializes the effect layer with the required options.
  106774. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106775. */
  106776. protected _init(options: Partial<IEffectLayerOptions>): void;
  106777. /**
  106778. * Generates the index buffer of the full screen quad blending to the main canvas.
  106779. */
  106780. private _generateIndexBuffer;
  106781. /**
  106782. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106783. */
  106784. private _generateVertexBuffer;
  106785. /**
  106786. * Sets the main texture desired size which is the closest power of two
  106787. * of the engine canvas size.
  106788. */
  106789. private _setMainTextureSize;
  106790. /**
  106791. * Creates the main texture for the effect layer.
  106792. */
  106793. protected _createMainTexture(): void;
  106794. /**
  106795. * Adds specific effects defines.
  106796. * @param defines The defines to add specifics to.
  106797. */
  106798. protected _addCustomEffectDefines(defines: string[]): void;
  106799. /**
  106800. * Checks for the readiness of the element composing the layer.
  106801. * @param subMesh the mesh to check for
  106802. * @param useInstances specify wether or not to use instances to render the mesh
  106803. * @param emissiveTexture the associated emissive texture used to generate the glow
  106804. * @return true if ready otherwise, false
  106805. */
  106806. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106807. /**
  106808. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106809. */
  106810. render(): void;
  106811. /**
  106812. * Determine if a given mesh will be used in the current effect.
  106813. * @param mesh mesh to test
  106814. * @returns true if the mesh will be used
  106815. */
  106816. hasMesh(mesh: AbstractMesh): boolean;
  106817. /**
  106818. * Returns true if the layer contains information to display, otherwise false.
  106819. * @returns true if the glow layer should be rendered
  106820. */
  106821. shouldRender(): boolean;
  106822. /**
  106823. * Returns true if the mesh should render, otherwise false.
  106824. * @param mesh The mesh to render
  106825. * @returns true if it should render otherwise false
  106826. */
  106827. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106828. /**
  106829. * Returns true if the mesh can be rendered, otherwise false.
  106830. * @param mesh The mesh to render
  106831. * @param material The material used on the mesh
  106832. * @returns true if it can be rendered otherwise false
  106833. */
  106834. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106835. /**
  106836. * Returns true if the mesh should render, otherwise false.
  106837. * @param mesh The mesh to render
  106838. * @returns true if it should render otherwise false
  106839. */
  106840. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106841. /**
  106842. * Renders the submesh passed in parameter to the generation map.
  106843. */
  106844. protected _renderSubMesh(subMesh: SubMesh): void;
  106845. /**
  106846. * Rebuild the required buffers.
  106847. * @hidden Internal use only.
  106848. */
  106849. _rebuild(): void;
  106850. /**
  106851. * Dispose only the render target textures and post process.
  106852. */
  106853. private _disposeTextureAndPostProcesses;
  106854. /**
  106855. * Dispose the highlight layer and free resources.
  106856. */
  106857. dispose(): void;
  106858. /**
  106859. * Gets the class name of the effect layer
  106860. * @returns the string with the class name of the effect layer
  106861. */
  106862. getClassName(): string;
  106863. /**
  106864. * Creates an effect layer from parsed effect layer data
  106865. * @param parsedEffectLayer defines effect layer data
  106866. * @param scene defines the current scene
  106867. * @param rootUrl defines the root URL containing the effect layer information
  106868. * @returns a parsed effect Layer
  106869. */
  106870. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106871. }
  106872. }
  106873. declare module BABYLON {
  106874. interface AbstractScene {
  106875. /**
  106876. * The list of effect layers (highlights/glow) added to the scene
  106877. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106878. * @see http://doc.babylonjs.com/how_to/glow_layer
  106879. */
  106880. effectLayers: Array<EffectLayer>;
  106881. /**
  106882. * Removes the given effect layer from this scene.
  106883. * @param toRemove defines the effect layer to remove
  106884. * @returns the index of the removed effect layer
  106885. */
  106886. removeEffectLayer(toRemove: EffectLayer): number;
  106887. /**
  106888. * Adds the given effect layer to this scene
  106889. * @param newEffectLayer defines the effect layer to add
  106890. */
  106891. addEffectLayer(newEffectLayer: EffectLayer): void;
  106892. }
  106893. /**
  106894. * Defines the layer scene component responsible to manage any effect layers
  106895. * in a given scene.
  106896. */
  106897. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106898. /**
  106899. * The component name helpfull to identify the component in the list of scene components.
  106900. */
  106901. readonly name: string;
  106902. /**
  106903. * The scene the component belongs to.
  106904. */
  106905. scene: Scene;
  106906. private _engine;
  106907. private _renderEffects;
  106908. private _needStencil;
  106909. private _previousStencilState;
  106910. /**
  106911. * Creates a new instance of the component for the given scene
  106912. * @param scene Defines the scene to register the component in
  106913. */
  106914. constructor(scene: Scene);
  106915. /**
  106916. * Registers the component in a given scene
  106917. */
  106918. register(): void;
  106919. /**
  106920. * Rebuilds the elements related to this component in case of
  106921. * context lost for instance.
  106922. */
  106923. rebuild(): void;
  106924. /**
  106925. * Serializes the component data to the specified json object
  106926. * @param serializationObject The object to serialize to
  106927. */
  106928. serialize(serializationObject: any): void;
  106929. /**
  106930. * Adds all the element from the container to the scene
  106931. * @param container the container holding the elements
  106932. */
  106933. addFromContainer(container: AbstractScene): void;
  106934. /**
  106935. * Removes all the elements in the container from the scene
  106936. * @param container contains the elements to remove
  106937. * @param dispose if the removed element should be disposed (default: false)
  106938. */
  106939. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106940. /**
  106941. * Disposes the component and the associated ressources.
  106942. */
  106943. dispose(): void;
  106944. private _isReadyForMesh;
  106945. private _renderMainTexture;
  106946. private _setStencil;
  106947. private _setStencilBack;
  106948. private _draw;
  106949. private _drawCamera;
  106950. private _drawRenderingGroup;
  106951. }
  106952. }
  106953. declare module BABYLON {
  106954. /** @hidden */
  106955. export var glowMapMergePixelShader: {
  106956. name: string;
  106957. shader: string;
  106958. };
  106959. }
  106960. declare module BABYLON {
  106961. /** @hidden */
  106962. export var glowMapMergeVertexShader: {
  106963. name: string;
  106964. shader: string;
  106965. };
  106966. }
  106967. declare module BABYLON {
  106968. interface AbstractScene {
  106969. /**
  106970. * Return a the first highlight layer of the scene with a given name.
  106971. * @param name The name of the highlight layer to look for.
  106972. * @return The highlight layer if found otherwise null.
  106973. */
  106974. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106975. }
  106976. /**
  106977. * Glow layer options. This helps customizing the behaviour
  106978. * of the glow layer.
  106979. */
  106980. export interface IGlowLayerOptions {
  106981. /**
  106982. * Multiplication factor apply to the canvas size to compute the render target size
  106983. * used to generated the glowing objects (the smaller the faster).
  106984. */
  106985. mainTextureRatio: number;
  106986. /**
  106987. * Enforces a fixed size texture to ensure resize independant blur.
  106988. */
  106989. mainTextureFixedSize?: number;
  106990. /**
  106991. * How big is the kernel of the blur texture.
  106992. */
  106993. blurKernelSize: number;
  106994. /**
  106995. * The camera attached to the layer.
  106996. */
  106997. camera: Nullable<Camera>;
  106998. /**
  106999. * Enable MSAA by chosing the number of samples.
  107000. */
  107001. mainTextureSamples?: number;
  107002. /**
  107003. * The rendering group to draw the layer in.
  107004. */
  107005. renderingGroupId: number;
  107006. }
  107007. /**
  107008. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107009. *
  107010. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107011. * glowy meshes to your scene.
  107012. *
  107013. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107014. */
  107015. export class GlowLayer extends EffectLayer {
  107016. /**
  107017. * Effect Name of the layer.
  107018. */
  107019. static readonly EffectName: string;
  107020. /**
  107021. * The default blur kernel size used for the glow.
  107022. */
  107023. static DefaultBlurKernelSize: number;
  107024. /**
  107025. * The default texture size ratio used for the glow.
  107026. */
  107027. static DefaultTextureRatio: number;
  107028. /**
  107029. * Sets the kernel size of the blur.
  107030. */
  107031. /**
  107032. * Gets the kernel size of the blur.
  107033. */
  107034. blurKernelSize: number;
  107035. /**
  107036. * Sets the glow intensity.
  107037. */
  107038. /**
  107039. * Gets the glow intensity.
  107040. */
  107041. intensity: number;
  107042. private _options;
  107043. private _intensity;
  107044. private _horizontalBlurPostprocess1;
  107045. private _verticalBlurPostprocess1;
  107046. private _horizontalBlurPostprocess2;
  107047. private _verticalBlurPostprocess2;
  107048. private _blurTexture1;
  107049. private _blurTexture2;
  107050. private _postProcesses1;
  107051. private _postProcesses2;
  107052. private _includedOnlyMeshes;
  107053. private _excludedMeshes;
  107054. /**
  107055. * Callback used to let the user override the color selection on a per mesh basis
  107056. */
  107057. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107058. /**
  107059. * Callback used to let the user override the texture selection on a per mesh basis
  107060. */
  107061. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107062. /**
  107063. * Instantiates a new glow Layer and references it to the scene.
  107064. * @param name The name of the layer
  107065. * @param scene The scene to use the layer in
  107066. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107067. */
  107068. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107069. /**
  107070. * Get the effect name of the layer.
  107071. * @return The effect name
  107072. */
  107073. getEffectName(): string;
  107074. /**
  107075. * Create the merge effect. This is the shader use to blit the information back
  107076. * to the main canvas at the end of the scene rendering.
  107077. */
  107078. protected _createMergeEffect(): Effect;
  107079. /**
  107080. * Creates the render target textures and post processes used in the glow layer.
  107081. */
  107082. protected _createTextureAndPostProcesses(): void;
  107083. /**
  107084. * Checks for the readiness of the element composing the layer.
  107085. * @param subMesh the mesh to check for
  107086. * @param useInstances specify wether or not to use instances to render the mesh
  107087. * @param emissiveTexture the associated emissive texture used to generate the glow
  107088. * @return true if ready otherwise, false
  107089. */
  107090. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107091. /**
  107092. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107093. */
  107094. needStencil(): boolean;
  107095. /**
  107096. * Returns true if the mesh can be rendered, otherwise false.
  107097. * @param mesh The mesh to render
  107098. * @param material The material used on the mesh
  107099. * @returns true if it can be rendered otherwise false
  107100. */
  107101. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107102. /**
  107103. * Implementation specific of rendering the generating effect on the main canvas.
  107104. * @param effect The effect used to render through
  107105. */
  107106. protected _internalRender(effect: Effect): void;
  107107. /**
  107108. * Sets the required values for both the emissive texture and and the main color.
  107109. */
  107110. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107111. /**
  107112. * Returns true if the mesh should render, otherwise false.
  107113. * @param mesh The mesh to render
  107114. * @returns true if it should render otherwise false
  107115. */
  107116. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107117. /**
  107118. * Adds specific effects defines.
  107119. * @param defines The defines to add specifics to.
  107120. */
  107121. protected _addCustomEffectDefines(defines: string[]): void;
  107122. /**
  107123. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107124. * @param mesh The mesh to exclude from the glow layer
  107125. */
  107126. addExcludedMesh(mesh: Mesh): void;
  107127. /**
  107128. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107129. * @param mesh The mesh to remove
  107130. */
  107131. removeExcludedMesh(mesh: Mesh): void;
  107132. /**
  107133. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107134. * @param mesh The mesh to include in the glow layer
  107135. */
  107136. addIncludedOnlyMesh(mesh: Mesh): void;
  107137. /**
  107138. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107139. * @param mesh The mesh to remove
  107140. */
  107141. removeIncludedOnlyMesh(mesh: Mesh): void;
  107142. /**
  107143. * Determine if a given mesh will be used in the glow layer
  107144. * @param mesh The mesh to test
  107145. * @returns true if the mesh will be highlighted by the current glow layer
  107146. */
  107147. hasMesh(mesh: AbstractMesh): boolean;
  107148. /**
  107149. * Free any resources and references associated to a mesh.
  107150. * Internal use
  107151. * @param mesh The mesh to free.
  107152. * @hidden
  107153. */
  107154. _disposeMesh(mesh: Mesh): void;
  107155. /**
  107156. * Gets the class name of the effect layer
  107157. * @returns the string with the class name of the effect layer
  107158. */
  107159. getClassName(): string;
  107160. /**
  107161. * Serializes this glow layer
  107162. * @returns a serialized glow layer object
  107163. */
  107164. serialize(): any;
  107165. /**
  107166. * Creates a Glow Layer from parsed glow layer data
  107167. * @param parsedGlowLayer defines glow layer data
  107168. * @param scene defines the current scene
  107169. * @param rootUrl defines the root URL containing the glow layer information
  107170. * @returns a parsed Glow Layer
  107171. */
  107172. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107173. }
  107174. }
  107175. declare module BABYLON {
  107176. /** @hidden */
  107177. export var glowBlurPostProcessPixelShader: {
  107178. name: string;
  107179. shader: string;
  107180. };
  107181. }
  107182. declare module BABYLON {
  107183. interface AbstractScene {
  107184. /**
  107185. * Return a the first highlight layer of the scene with a given name.
  107186. * @param name The name of the highlight layer to look for.
  107187. * @return The highlight layer if found otherwise null.
  107188. */
  107189. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107190. }
  107191. /**
  107192. * Highlight layer options. This helps customizing the behaviour
  107193. * of the highlight layer.
  107194. */
  107195. export interface IHighlightLayerOptions {
  107196. /**
  107197. * Multiplication factor apply to the canvas size to compute the render target size
  107198. * used to generated the glowing objects (the smaller the faster).
  107199. */
  107200. mainTextureRatio: number;
  107201. /**
  107202. * Enforces a fixed size texture to ensure resize independant blur.
  107203. */
  107204. mainTextureFixedSize?: number;
  107205. /**
  107206. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107207. * of the picture to blur (the smaller the faster).
  107208. */
  107209. blurTextureSizeRatio: number;
  107210. /**
  107211. * How big in texel of the blur texture is the vertical blur.
  107212. */
  107213. blurVerticalSize: number;
  107214. /**
  107215. * How big in texel of the blur texture is the horizontal blur.
  107216. */
  107217. blurHorizontalSize: number;
  107218. /**
  107219. * Alpha blending mode used to apply the blur. Default is combine.
  107220. */
  107221. alphaBlendingMode: number;
  107222. /**
  107223. * The camera attached to the layer.
  107224. */
  107225. camera: Nullable<Camera>;
  107226. /**
  107227. * Should we display highlight as a solid stroke?
  107228. */
  107229. isStroke?: boolean;
  107230. /**
  107231. * The rendering group to draw the layer in.
  107232. */
  107233. renderingGroupId: number;
  107234. }
  107235. /**
  107236. * The highlight layer Helps adding a glow effect around a mesh.
  107237. *
  107238. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107239. * glowy meshes to your scene.
  107240. *
  107241. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107242. */
  107243. export class HighlightLayer extends EffectLayer {
  107244. name: string;
  107245. /**
  107246. * Effect Name of the highlight layer.
  107247. */
  107248. static readonly EffectName: string;
  107249. /**
  107250. * The neutral color used during the preparation of the glow effect.
  107251. * This is black by default as the blend operation is a blend operation.
  107252. */
  107253. static NeutralColor: Color4;
  107254. /**
  107255. * Stencil value used for glowing meshes.
  107256. */
  107257. static GlowingMeshStencilReference: number;
  107258. /**
  107259. * Stencil value used for the other meshes in the scene.
  107260. */
  107261. static NormalMeshStencilReference: number;
  107262. /**
  107263. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107264. */
  107265. innerGlow: boolean;
  107266. /**
  107267. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107268. */
  107269. outerGlow: boolean;
  107270. /**
  107271. * Specifies the horizontal size of the blur.
  107272. */
  107273. /**
  107274. * Gets the horizontal size of the blur.
  107275. */
  107276. blurHorizontalSize: number;
  107277. /**
  107278. * Specifies the vertical size of the blur.
  107279. */
  107280. /**
  107281. * Gets the vertical size of the blur.
  107282. */
  107283. blurVerticalSize: number;
  107284. /**
  107285. * An event triggered when the highlight layer is being blurred.
  107286. */
  107287. onBeforeBlurObservable: Observable<HighlightLayer>;
  107288. /**
  107289. * An event triggered when the highlight layer has been blurred.
  107290. */
  107291. onAfterBlurObservable: Observable<HighlightLayer>;
  107292. private _instanceGlowingMeshStencilReference;
  107293. private _options;
  107294. private _downSamplePostprocess;
  107295. private _horizontalBlurPostprocess;
  107296. private _verticalBlurPostprocess;
  107297. private _blurTexture;
  107298. private _meshes;
  107299. private _excludedMeshes;
  107300. /**
  107301. * Instantiates a new highlight Layer and references it to the scene..
  107302. * @param name The name of the layer
  107303. * @param scene The scene to use the layer in
  107304. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107305. */
  107306. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107307. /**
  107308. * Get the effect name of the layer.
  107309. * @return The effect name
  107310. */
  107311. getEffectName(): string;
  107312. /**
  107313. * Create the merge effect. This is the shader use to blit the information back
  107314. * to the main canvas at the end of the scene rendering.
  107315. */
  107316. protected _createMergeEffect(): Effect;
  107317. /**
  107318. * Creates the render target textures and post processes used in the highlight layer.
  107319. */
  107320. protected _createTextureAndPostProcesses(): void;
  107321. /**
  107322. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107323. */
  107324. needStencil(): boolean;
  107325. /**
  107326. * Checks for the readiness of the element composing the layer.
  107327. * @param subMesh the mesh to check for
  107328. * @param useInstances specify wether or not to use instances to render the mesh
  107329. * @param emissiveTexture the associated emissive texture used to generate the glow
  107330. * @return true if ready otherwise, false
  107331. */
  107332. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107333. /**
  107334. * Implementation specific of rendering the generating effect on the main canvas.
  107335. * @param effect The effect used to render through
  107336. */
  107337. protected _internalRender(effect: Effect): void;
  107338. /**
  107339. * Returns true if the layer contains information to display, otherwise false.
  107340. */
  107341. shouldRender(): boolean;
  107342. /**
  107343. * Returns true if the mesh should render, otherwise false.
  107344. * @param mesh The mesh to render
  107345. * @returns true if it should render otherwise false
  107346. */
  107347. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107348. /**
  107349. * Sets the required values for both the emissive texture and and the main color.
  107350. */
  107351. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107352. /**
  107353. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107354. * @param mesh The mesh to exclude from the highlight layer
  107355. */
  107356. addExcludedMesh(mesh: Mesh): void;
  107357. /**
  107358. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107359. * @param mesh The mesh to highlight
  107360. */
  107361. removeExcludedMesh(mesh: Mesh): void;
  107362. /**
  107363. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107364. * @param mesh mesh to test
  107365. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107366. */
  107367. hasMesh(mesh: AbstractMesh): boolean;
  107368. /**
  107369. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107370. * @param mesh The mesh to highlight
  107371. * @param color The color of the highlight
  107372. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107373. */
  107374. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107375. /**
  107376. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107377. * @param mesh The mesh to highlight
  107378. */
  107379. removeMesh(mesh: Mesh): void;
  107380. /**
  107381. * Force the stencil to the normal expected value for none glowing parts
  107382. */
  107383. private _defaultStencilReference;
  107384. /**
  107385. * Free any resources and references associated to a mesh.
  107386. * Internal use
  107387. * @param mesh The mesh to free.
  107388. * @hidden
  107389. */
  107390. _disposeMesh(mesh: Mesh): void;
  107391. /**
  107392. * Dispose the highlight layer and free resources.
  107393. */
  107394. dispose(): void;
  107395. /**
  107396. * Gets the class name of the effect layer
  107397. * @returns the string with the class name of the effect layer
  107398. */
  107399. getClassName(): string;
  107400. /**
  107401. * Serializes this Highlight layer
  107402. * @returns a serialized Highlight layer object
  107403. */
  107404. serialize(): any;
  107405. /**
  107406. * Creates a Highlight layer from parsed Highlight layer data
  107407. * @param parsedHightlightLayer defines the Highlight layer data
  107408. * @param scene defines the current scene
  107409. * @param rootUrl defines the root URL containing the Highlight layer information
  107410. * @returns a parsed Highlight layer
  107411. */
  107412. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107413. }
  107414. }
  107415. declare module BABYLON {
  107416. /** @hidden */
  107417. export var lensFlarePixelShader: {
  107418. name: string;
  107419. shader: string;
  107420. };
  107421. }
  107422. declare module BABYLON {
  107423. /** @hidden */
  107424. export var lensFlareVertexShader: {
  107425. name: string;
  107426. shader: string;
  107427. };
  107428. }
  107429. declare module BABYLON {
  107430. /**
  107431. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107432. * It is usually composed of several `lensFlare`.
  107433. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107434. */
  107435. export class LensFlareSystem {
  107436. /**
  107437. * Define the name of the lens flare system
  107438. */
  107439. name: string;
  107440. /**
  107441. * List of lens flares used in this system.
  107442. */
  107443. lensFlares: LensFlare[];
  107444. /**
  107445. * Define a limit from the border the lens flare can be visible.
  107446. */
  107447. borderLimit: number;
  107448. /**
  107449. * Define a viewport border we do not want to see the lens flare in.
  107450. */
  107451. viewportBorder: number;
  107452. /**
  107453. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107454. */
  107455. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107456. /**
  107457. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107458. */
  107459. layerMask: number;
  107460. /**
  107461. * Define the id of the lens flare system in the scene.
  107462. * (equal to name by default)
  107463. */
  107464. id: string;
  107465. private _scene;
  107466. private _emitter;
  107467. private _vertexBuffers;
  107468. private _indexBuffer;
  107469. private _effect;
  107470. private _positionX;
  107471. private _positionY;
  107472. private _isEnabled;
  107473. /** @hidden */
  107474. static _SceneComponentInitialization: (scene: Scene) => void;
  107475. /**
  107476. * Instantiates a lens flare system.
  107477. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107478. * It is usually composed of several `lensFlare`.
  107479. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107480. * @param name Define the name of the lens flare system in the scene
  107481. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107482. * @param scene Define the scene the lens flare system belongs to
  107483. */
  107484. constructor(
  107485. /**
  107486. * Define the name of the lens flare system
  107487. */
  107488. name: string, emitter: any, scene: Scene);
  107489. /**
  107490. * Define if the lens flare system is enabled.
  107491. */
  107492. isEnabled: boolean;
  107493. /**
  107494. * Get the scene the effects belongs to.
  107495. * @returns the scene holding the lens flare system
  107496. */
  107497. getScene(): Scene;
  107498. /**
  107499. * Get the emitter of the lens flare system.
  107500. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107501. * @returns the emitter of the lens flare system
  107502. */
  107503. getEmitter(): any;
  107504. /**
  107505. * Set the emitter of the lens flare system.
  107506. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107507. * @param newEmitter Define the new emitter of the system
  107508. */
  107509. setEmitter(newEmitter: any): void;
  107510. /**
  107511. * Get the lens flare system emitter position.
  107512. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107513. * @returns the position
  107514. */
  107515. getEmitterPosition(): Vector3;
  107516. /**
  107517. * @hidden
  107518. */
  107519. computeEffectivePosition(globalViewport: Viewport): boolean;
  107520. /** @hidden */
  107521. _isVisible(): boolean;
  107522. /**
  107523. * @hidden
  107524. */
  107525. render(): boolean;
  107526. /**
  107527. * Dispose and release the lens flare with its associated resources.
  107528. */
  107529. dispose(): void;
  107530. /**
  107531. * Parse a lens flare system from a JSON repressentation
  107532. * @param parsedLensFlareSystem Define the JSON to parse
  107533. * @param scene Define the scene the parsed system should be instantiated in
  107534. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107535. * @returns the parsed system
  107536. */
  107537. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107538. /**
  107539. * Serialize the current Lens Flare System into a JSON representation.
  107540. * @returns the serialized JSON
  107541. */
  107542. serialize(): any;
  107543. }
  107544. }
  107545. declare module BABYLON {
  107546. /**
  107547. * This represents one of the lens effect in a `lensFlareSystem`.
  107548. * It controls one of the indiviual texture used in the effect.
  107549. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107550. */
  107551. export class LensFlare {
  107552. /**
  107553. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107554. */
  107555. size: number;
  107556. /**
  107557. * 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.
  107558. */
  107559. position: number;
  107560. /**
  107561. * Define the lens color.
  107562. */
  107563. color: Color3;
  107564. /**
  107565. * Define the lens texture.
  107566. */
  107567. texture: Nullable<Texture>;
  107568. /**
  107569. * Define the alpha mode to render this particular lens.
  107570. */
  107571. alphaMode: number;
  107572. private _system;
  107573. /**
  107574. * Creates a new Lens Flare.
  107575. * This represents one of the lens effect in a `lensFlareSystem`.
  107576. * It controls one of the indiviual texture used in the effect.
  107577. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107578. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107579. * @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.
  107580. * @param color Define the lens color
  107581. * @param imgUrl Define the lens texture url
  107582. * @param system Define the `lensFlareSystem` this flare is part of
  107583. * @returns The newly created Lens Flare
  107584. */
  107585. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107586. /**
  107587. * Instantiates a new Lens Flare.
  107588. * This represents one of the lens effect in a `lensFlareSystem`.
  107589. * It controls one of the indiviual texture used in the effect.
  107590. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107591. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107592. * @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.
  107593. * @param color Define the lens color
  107594. * @param imgUrl Define the lens texture url
  107595. * @param system Define the `lensFlareSystem` this flare is part of
  107596. */
  107597. constructor(
  107598. /**
  107599. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107600. */
  107601. size: number,
  107602. /**
  107603. * 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.
  107604. */
  107605. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107606. /**
  107607. * Dispose and release the lens flare with its associated resources.
  107608. */
  107609. dispose(): void;
  107610. }
  107611. }
  107612. declare module BABYLON {
  107613. interface AbstractScene {
  107614. /**
  107615. * The list of lens flare system added to the scene
  107616. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107617. */
  107618. lensFlareSystems: Array<LensFlareSystem>;
  107619. /**
  107620. * Removes the given lens flare system from this scene.
  107621. * @param toRemove The lens flare system to remove
  107622. * @returns The index of the removed lens flare system
  107623. */
  107624. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107625. /**
  107626. * Adds the given lens flare system to this scene
  107627. * @param newLensFlareSystem The lens flare system to add
  107628. */
  107629. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107630. /**
  107631. * Gets a lens flare system using its name
  107632. * @param name defines the name to look for
  107633. * @returns the lens flare system or null if not found
  107634. */
  107635. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107636. /**
  107637. * Gets a lens flare system using its id
  107638. * @param id defines the id to look for
  107639. * @returns the lens flare system or null if not found
  107640. */
  107641. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107642. }
  107643. /**
  107644. * Defines the lens flare scene component responsible to manage any lens flares
  107645. * in a given scene.
  107646. */
  107647. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107648. /**
  107649. * The component name helpfull to identify the component in the list of scene components.
  107650. */
  107651. readonly name: string;
  107652. /**
  107653. * The scene the component belongs to.
  107654. */
  107655. scene: Scene;
  107656. /**
  107657. * Creates a new instance of the component for the given scene
  107658. * @param scene Defines the scene to register the component in
  107659. */
  107660. constructor(scene: Scene);
  107661. /**
  107662. * Registers the component in a given scene
  107663. */
  107664. register(): void;
  107665. /**
  107666. * Rebuilds the elements related to this component in case of
  107667. * context lost for instance.
  107668. */
  107669. rebuild(): void;
  107670. /**
  107671. * Adds all the element from the container to the scene
  107672. * @param container the container holding the elements
  107673. */
  107674. addFromContainer(container: AbstractScene): void;
  107675. /**
  107676. * Removes all the elements in the container from the scene
  107677. * @param container contains the elements to remove
  107678. * @param dispose if the removed element should be disposed (default: false)
  107679. */
  107680. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107681. /**
  107682. * Serializes the component data to the specified json object
  107683. * @param serializationObject The object to serialize to
  107684. */
  107685. serialize(serializationObject: any): void;
  107686. /**
  107687. * Disposes the component and the associated ressources.
  107688. */
  107689. dispose(): void;
  107690. private _draw;
  107691. }
  107692. }
  107693. declare module BABYLON {
  107694. /**
  107695. * Defines the shadow generator component responsible to manage any shadow generators
  107696. * in a given scene.
  107697. */
  107698. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107699. /**
  107700. * The component name helpfull to identify the component in the list of scene components.
  107701. */
  107702. readonly name: string;
  107703. /**
  107704. * The scene the component belongs to.
  107705. */
  107706. scene: Scene;
  107707. /**
  107708. * Creates a new instance of the component for the given scene
  107709. * @param scene Defines the scene to register the component in
  107710. */
  107711. constructor(scene: Scene);
  107712. /**
  107713. * Registers the component in a given scene
  107714. */
  107715. register(): void;
  107716. /**
  107717. * Rebuilds the elements related to this component in case of
  107718. * context lost for instance.
  107719. */
  107720. rebuild(): void;
  107721. /**
  107722. * Serializes the component data to the specified json object
  107723. * @param serializationObject The object to serialize to
  107724. */
  107725. serialize(serializationObject: any): void;
  107726. /**
  107727. * Adds all the element from the container to the scene
  107728. * @param container the container holding the elements
  107729. */
  107730. addFromContainer(container: AbstractScene): void;
  107731. /**
  107732. * Removes all the elements in the container from the scene
  107733. * @param container contains the elements to remove
  107734. * @param dispose if the removed element should be disposed (default: false)
  107735. */
  107736. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107737. /**
  107738. * Rebuilds the elements related to this component in case of
  107739. * context lost for instance.
  107740. */
  107741. dispose(): void;
  107742. private _gatherRenderTargets;
  107743. }
  107744. }
  107745. declare module BABYLON {
  107746. /**
  107747. * A point light is a light defined by an unique point in world space.
  107748. * The light is emitted in every direction from this point.
  107749. * A good example of a point light is a standard light bulb.
  107750. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107751. */
  107752. export class PointLight extends ShadowLight {
  107753. private _shadowAngle;
  107754. /**
  107755. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107756. * This specifies what angle the shadow will use to be created.
  107757. *
  107758. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107759. */
  107760. /**
  107761. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107762. * This specifies what angle the shadow will use to be created.
  107763. *
  107764. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107765. */
  107766. shadowAngle: number;
  107767. /**
  107768. * Gets the direction if it has been set.
  107769. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107770. */
  107771. /**
  107772. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107773. */
  107774. direction: Vector3;
  107775. /**
  107776. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107777. * A PointLight emits the light in every direction.
  107778. * It can cast shadows.
  107779. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107780. * ```javascript
  107781. * var pointLight = new PointLight("pl", camera.position, scene);
  107782. * ```
  107783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107784. * @param name The light friendly name
  107785. * @param position The position of the point light in the scene
  107786. * @param scene The scene the lights belongs to
  107787. */
  107788. constructor(name: string, position: Vector3, scene: Scene);
  107789. /**
  107790. * Returns the string "PointLight"
  107791. * @returns the class name
  107792. */
  107793. getClassName(): string;
  107794. /**
  107795. * Returns the integer 0.
  107796. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107797. */
  107798. getTypeID(): number;
  107799. /**
  107800. * Specifies wether or not the shadowmap should be a cube texture.
  107801. * @returns true if the shadowmap needs to be a cube texture.
  107802. */
  107803. needCube(): boolean;
  107804. /**
  107805. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107806. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107807. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107808. */
  107809. getShadowDirection(faceIndex?: number): Vector3;
  107810. /**
  107811. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107812. * - fov = PI / 2
  107813. * - aspect ratio : 1.0
  107814. * - z-near and far equal to the active camera minZ and maxZ.
  107815. * Returns the PointLight.
  107816. */
  107817. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107818. protected _buildUniformLayout(): void;
  107819. /**
  107820. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107821. * @param effect The effect to update
  107822. * @param lightIndex The index of the light in the effect to update
  107823. * @returns The point light
  107824. */
  107825. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107826. /**
  107827. * Prepares the list of defines specific to the light type.
  107828. * @param defines the list of defines
  107829. * @param lightIndex defines the index of the light for the effect
  107830. */
  107831. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107832. }
  107833. }
  107834. declare module BABYLON {
  107835. /**
  107836. * Header information of HDR texture files.
  107837. */
  107838. export interface HDRInfo {
  107839. /**
  107840. * The height of the texture in pixels.
  107841. */
  107842. height: number;
  107843. /**
  107844. * The width of the texture in pixels.
  107845. */
  107846. width: number;
  107847. /**
  107848. * The index of the beginning of the data in the binary file.
  107849. */
  107850. dataPosition: number;
  107851. }
  107852. /**
  107853. * This groups tools to convert HDR texture to native colors array.
  107854. */
  107855. export class HDRTools {
  107856. private static Ldexp;
  107857. private static Rgbe2float;
  107858. private static readStringLine;
  107859. /**
  107860. * Reads header information from an RGBE texture stored in a native array.
  107861. * More information on this format are available here:
  107862. * https://en.wikipedia.org/wiki/RGBE_image_format
  107863. *
  107864. * @param uint8array The binary file stored in native array.
  107865. * @return The header information.
  107866. */
  107867. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107868. /**
  107869. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107870. * This RGBE texture needs to store the information as a panorama.
  107871. *
  107872. * More information on this format are available here:
  107873. * https://en.wikipedia.org/wiki/RGBE_image_format
  107874. *
  107875. * @param buffer The binary file stored in an array buffer.
  107876. * @param size The expected size of the extracted cubemap.
  107877. * @return The Cube Map information.
  107878. */
  107879. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107880. /**
  107881. * Returns the pixels data extracted from an RGBE texture.
  107882. * This pixels will be stored left to right up to down in the R G B order in one array.
  107883. *
  107884. * More information on this format are available here:
  107885. * https://en.wikipedia.org/wiki/RGBE_image_format
  107886. *
  107887. * @param uint8array The binary file stored in an array buffer.
  107888. * @param hdrInfo The header information of the file.
  107889. * @return The pixels data in RGB right to left up to down order.
  107890. */
  107891. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107892. private static RGBE_ReadPixels_RLE;
  107893. }
  107894. }
  107895. declare module BABYLON {
  107896. /**
  107897. * This represents a texture coming from an HDR input.
  107898. *
  107899. * The only supported format is currently panorama picture stored in RGBE format.
  107900. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107901. */
  107902. export class HDRCubeTexture extends BaseTexture {
  107903. private static _facesMapping;
  107904. private _generateHarmonics;
  107905. private _noMipmap;
  107906. private _textureMatrix;
  107907. private _size;
  107908. private _onLoad;
  107909. private _onError;
  107910. /**
  107911. * The texture URL.
  107912. */
  107913. url: string;
  107914. /**
  107915. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107916. */
  107917. coordinatesMode: number;
  107918. protected _isBlocking: boolean;
  107919. /**
  107920. * Sets wether or not the texture is blocking during loading.
  107921. */
  107922. /**
  107923. * Gets wether or not the texture is blocking during loading.
  107924. */
  107925. isBlocking: boolean;
  107926. protected _rotationY: number;
  107927. /**
  107928. * Sets texture matrix rotation angle around Y axis in radians.
  107929. */
  107930. /**
  107931. * Gets texture matrix rotation angle around Y axis radians.
  107932. */
  107933. rotationY: number;
  107934. /**
  107935. * Gets or sets the center of the bounding box associated with the cube texture
  107936. * It must define where the camera used to render the texture was set
  107937. */
  107938. boundingBoxPosition: Vector3;
  107939. private _boundingBoxSize;
  107940. /**
  107941. * Gets or sets the size of the bounding box associated with the cube texture
  107942. * When defined, the cubemap will switch to local mode
  107943. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107944. * @example https://www.babylonjs-playground.com/#RNASML
  107945. */
  107946. boundingBoxSize: Vector3;
  107947. /**
  107948. * Instantiates an HDRTexture from the following parameters.
  107949. *
  107950. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107951. * @param scene The scene the texture will be used in
  107952. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107953. * @param noMipmap Forces to not generate the mipmap if true
  107954. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107955. * @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)
  107956. * @param reserved Reserved flag for internal use.
  107957. */
  107958. 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>);
  107959. /**
  107960. * Get the current class name of the texture useful for serialization or dynamic coding.
  107961. * @returns "HDRCubeTexture"
  107962. */
  107963. getClassName(): string;
  107964. /**
  107965. * Occurs when the file is raw .hdr file.
  107966. */
  107967. private loadTexture;
  107968. clone(): HDRCubeTexture;
  107969. delayLoad(): void;
  107970. /**
  107971. * Get the texture reflection matrix used to rotate/transform the reflection.
  107972. * @returns the reflection matrix
  107973. */
  107974. getReflectionTextureMatrix(): Matrix;
  107975. /**
  107976. * Set the texture reflection matrix used to rotate/transform the reflection.
  107977. * @param value Define the reflection matrix to set
  107978. */
  107979. setReflectionTextureMatrix(value: Matrix): void;
  107980. /**
  107981. * Parses a JSON representation of an HDR Texture in order to create the texture
  107982. * @param parsedTexture Define the JSON representation
  107983. * @param scene Define the scene the texture should be created in
  107984. * @param rootUrl Define the root url in case we need to load relative dependencies
  107985. * @returns the newly created texture after parsing
  107986. */
  107987. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107988. serialize(): any;
  107989. }
  107990. }
  107991. declare module BABYLON {
  107992. /**
  107993. * Class used to control physics engine
  107994. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107995. */
  107996. export class PhysicsEngine implements IPhysicsEngine {
  107997. private _physicsPlugin;
  107998. /**
  107999. * Global value used to control the smallest number supported by the simulation
  108000. */
  108001. static Epsilon: number;
  108002. private _impostors;
  108003. private _joints;
  108004. /**
  108005. * Gets the gravity vector used by the simulation
  108006. */
  108007. gravity: Vector3;
  108008. /**
  108009. * Factory used to create the default physics plugin.
  108010. * @returns The default physics plugin
  108011. */
  108012. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108013. /**
  108014. * Creates a new Physics Engine
  108015. * @param gravity defines the gravity vector used by the simulation
  108016. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108017. */
  108018. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108019. /**
  108020. * Sets the gravity vector used by the simulation
  108021. * @param gravity defines the gravity vector to use
  108022. */
  108023. setGravity(gravity: Vector3): void;
  108024. /**
  108025. * Set the time step of the physics engine.
  108026. * Default is 1/60.
  108027. * To slow it down, enter 1/600 for example.
  108028. * To speed it up, 1/30
  108029. * @param newTimeStep defines the new timestep to apply to this world.
  108030. */
  108031. setTimeStep(newTimeStep?: number): void;
  108032. /**
  108033. * Get the time step of the physics engine.
  108034. * @returns the current time step
  108035. */
  108036. getTimeStep(): number;
  108037. /**
  108038. * Release all resources
  108039. */
  108040. dispose(): void;
  108041. /**
  108042. * Gets the name of the current physics plugin
  108043. * @returns the name of the plugin
  108044. */
  108045. getPhysicsPluginName(): string;
  108046. /**
  108047. * Adding a new impostor for the impostor tracking.
  108048. * This will be done by the impostor itself.
  108049. * @param impostor the impostor to add
  108050. */
  108051. addImpostor(impostor: PhysicsImpostor): void;
  108052. /**
  108053. * Remove an impostor from the engine.
  108054. * This impostor and its mesh will not longer be updated by the physics engine.
  108055. * @param impostor the impostor to remove
  108056. */
  108057. removeImpostor(impostor: PhysicsImpostor): void;
  108058. /**
  108059. * Add a joint to the physics engine
  108060. * @param mainImpostor defines the main impostor to which the joint is added.
  108061. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108062. * @param joint defines the joint that will connect both impostors.
  108063. */
  108064. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108065. /**
  108066. * Removes a joint from the simulation
  108067. * @param mainImpostor defines the impostor used with the joint
  108068. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108069. * @param joint defines the joint to remove
  108070. */
  108071. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108072. /**
  108073. * Called by the scene. No need to call it.
  108074. * @param delta defines the timespam between frames
  108075. */
  108076. _step(delta: number): void;
  108077. /**
  108078. * Gets the current plugin used to run the simulation
  108079. * @returns current plugin
  108080. */
  108081. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108082. /**
  108083. * Gets the list of physic impostors
  108084. * @returns an array of PhysicsImpostor
  108085. */
  108086. getImpostors(): Array<PhysicsImpostor>;
  108087. /**
  108088. * Gets the impostor for a physics enabled object
  108089. * @param object defines the object impersonated by the impostor
  108090. * @returns the PhysicsImpostor or null if not found
  108091. */
  108092. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108093. /**
  108094. * Gets the impostor for a physics body object
  108095. * @param body defines physics body used by the impostor
  108096. * @returns the PhysicsImpostor or null if not found
  108097. */
  108098. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108099. /**
  108100. * Does a raycast in the physics world
  108101. * @param from when should the ray start?
  108102. * @param to when should the ray end?
  108103. * @returns PhysicsRaycastResult
  108104. */
  108105. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108106. }
  108107. }
  108108. declare module BABYLON {
  108109. /** @hidden */
  108110. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108111. private _useDeltaForWorldStep;
  108112. world: any;
  108113. name: string;
  108114. private _physicsMaterials;
  108115. private _fixedTimeStep;
  108116. private _cannonRaycastResult;
  108117. private _raycastResult;
  108118. private _removeAfterStep;
  108119. BJSCANNON: any;
  108120. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108121. setGravity(gravity: Vector3): void;
  108122. setTimeStep(timeStep: number): void;
  108123. getTimeStep(): number;
  108124. executeStep(delta: number): void;
  108125. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108126. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108127. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108128. private _processChildMeshes;
  108129. removePhysicsBody(impostor: PhysicsImpostor): void;
  108130. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108131. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108132. private _addMaterial;
  108133. private _checkWithEpsilon;
  108134. private _createShape;
  108135. private _createHeightmap;
  108136. private _minus90X;
  108137. private _plus90X;
  108138. private _tmpPosition;
  108139. private _tmpDeltaPosition;
  108140. private _tmpUnityRotation;
  108141. private _updatePhysicsBodyTransformation;
  108142. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108143. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108144. isSupported(): boolean;
  108145. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108147. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108148. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108149. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108150. getBodyMass(impostor: PhysicsImpostor): number;
  108151. getBodyFriction(impostor: PhysicsImpostor): number;
  108152. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108153. getBodyRestitution(impostor: PhysicsImpostor): number;
  108154. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108155. sleepBody(impostor: PhysicsImpostor): void;
  108156. wakeUpBody(impostor: PhysicsImpostor): void;
  108157. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108158. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108159. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108160. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108161. getRadius(impostor: PhysicsImpostor): number;
  108162. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108163. dispose(): void;
  108164. private _extendNamespace;
  108165. /**
  108166. * Does a raycast in the physics world
  108167. * @param from when should the ray start?
  108168. * @param to when should the ray end?
  108169. * @returns PhysicsRaycastResult
  108170. */
  108171. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108172. }
  108173. }
  108174. declare module BABYLON {
  108175. /** @hidden */
  108176. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108177. world: any;
  108178. name: string;
  108179. BJSOIMO: any;
  108180. private _raycastResult;
  108181. constructor(iterations?: number, oimoInjection?: any);
  108182. setGravity(gravity: Vector3): void;
  108183. setTimeStep(timeStep: number): void;
  108184. getTimeStep(): number;
  108185. private _tmpImpostorsArray;
  108186. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108187. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108188. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108189. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108190. private _tmpPositionVector;
  108191. removePhysicsBody(impostor: PhysicsImpostor): void;
  108192. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108193. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108194. isSupported(): boolean;
  108195. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108196. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108197. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108198. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108199. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108200. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108201. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108202. getBodyMass(impostor: PhysicsImpostor): number;
  108203. getBodyFriction(impostor: PhysicsImpostor): number;
  108204. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108205. getBodyRestitution(impostor: PhysicsImpostor): number;
  108206. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108207. sleepBody(impostor: PhysicsImpostor): void;
  108208. wakeUpBody(impostor: PhysicsImpostor): void;
  108209. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108210. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108211. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108212. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108213. getRadius(impostor: PhysicsImpostor): number;
  108214. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108215. dispose(): void;
  108216. /**
  108217. * Does a raycast in the physics world
  108218. * @param from when should the ray start?
  108219. * @param to when should the ray end?
  108220. * @returns PhysicsRaycastResult
  108221. */
  108222. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108223. }
  108224. }
  108225. declare module BABYLON {
  108226. /**
  108227. * Class containing static functions to help procedurally build meshes
  108228. */
  108229. export class RibbonBuilder {
  108230. /**
  108231. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108232. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108233. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108234. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108235. * * 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
  108236. * * 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
  108237. * * 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
  108238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108241. * * 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
  108242. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108243. * * 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
  108244. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108246. * @param name defines the name of the mesh
  108247. * @param options defines the options used to create the mesh
  108248. * @param scene defines the hosting scene
  108249. * @returns the ribbon mesh
  108250. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108252. */
  108253. static CreateRibbon(name: string, options: {
  108254. pathArray: Vector3[][];
  108255. closeArray?: boolean;
  108256. closePath?: boolean;
  108257. offset?: number;
  108258. updatable?: boolean;
  108259. sideOrientation?: number;
  108260. frontUVs?: Vector4;
  108261. backUVs?: Vector4;
  108262. instance?: Mesh;
  108263. invertUV?: boolean;
  108264. uvs?: Vector2[];
  108265. colors?: Color4[];
  108266. }, scene?: Nullable<Scene>): Mesh;
  108267. }
  108268. }
  108269. declare module BABYLON {
  108270. /**
  108271. * Class containing static functions to help procedurally build meshes
  108272. */
  108273. export class ShapeBuilder {
  108274. /**
  108275. * 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.
  108276. * * 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.
  108277. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108278. * * 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.
  108279. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108280. * * 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
  108281. * * 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
  108282. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108287. * @param name defines the name of the mesh
  108288. * @param options defines the options used to create the mesh
  108289. * @param scene defines the hosting scene
  108290. * @returns the extruded shape mesh
  108291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108293. */
  108294. static ExtrudeShape(name: string, options: {
  108295. shape: Vector3[];
  108296. path: Vector3[];
  108297. scale?: number;
  108298. rotation?: number;
  108299. cap?: number;
  108300. updatable?: boolean;
  108301. sideOrientation?: number;
  108302. frontUVs?: Vector4;
  108303. backUVs?: Vector4;
  108304. instance?: Mesh;
  108305. invertUV?: boolean;
  108306. }, scene?: Nullable<Scene>): Mesh;
  108307. /**
  108308. * Creates an custom extruded shape mesh.
  108309. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108310. * * 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.
  108311. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108312. * * 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
  108313. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108314. * * 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
  108315. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108316. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108317. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108318. * * 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
  108319. * * 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
  108320. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108325. * @param name defines the name of the mesh
  108326. * @param options defines the options used to create the mesh
  108327. * @param scene defines the hosting scene
  108328. * @returns the custom extruded shape mesh
  108329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108332. */
  108333. static ExtrudeShapeCustom(name: string, options: {
  108334. shape: Vector3[];
  108335. path: Vector3[];
  108336. scaleFunction?: any;
  108337. rotationFunction?: any;
  108338. ribbonCloseArray?: boolean;
  108339. ribbonClosePath?: boolean;
  108340. cap?: number;
  108341. updatable?: boolean;
  108342. sideOrientation?: number;
  108343. frontUVs?: Vector4;
  108344. backUVs?: Vector4;
  108345. instance?: Mesh;
  108346. invertUV?: boolean;
  108347. }, scene?: Nullable<Scene>): Mesh;
  108348. private static _ExtrudeShapeGeneric;
  108349. }
  108350. }
  108351. declare module BABYLON {
  108352. /**
  108353. * AmmoJS Physics plugin
  108354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108355. * @see https://github.com/kripken/ammo.js/
  108356. */
  108357. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108358. private _useDeltaForWorldStep;
  108359. /**
  108360. * Reference to the Ammo library
  108361. */
  108362. bjsAMMO: any;
  108363. /**
  108364. * Created ammoJS world which physics bodies are added to
  108365. */
  108366. world: any;
  108367. /**
  108368. * Name of the plugin
  108369. */
  108370. name: string;
  108371. private _timeStep;
  108372. private _fixedTimeStep;
  108373. private _maxSteps;
  108374. private _tmpQuaternion;
  108375. private _tmpAmmoTransform;
  108376. private _tmpAmmoQuaternion;
  108377. private _tmpAmmoConcreteContactResultCallback;
  108378. private _collisionConfiguration;
  108379. private _dispatcher;
  108380. private _overlappingPairCache;
  108381. private _solver;
  108382. private _softBodySolver;
  108383. private _tmpAmmoVectorA;
  108384. private _tmpAmmoVectorB;
  108385. private _tmpAmmoVectorC;
  108386. private _tmpAmmoVectorD;
  108387. private _tmpContactCallbackResult;
  108388. private _tmpAmmoVectorRCA;
  108389. private _tmpAmmoVectorRCB;
  108390. private _raycastResult;
  108391. private static readonly DISABLE_COLLISION_FLAG;
  108392. private static readonly KINEMATIC_FLAG;
  108393. private static readonly DISABLE_DEACTIVATION_FLAG;
  108394. /**
  108395. * Initializes the ammoJS plugin
  108396. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108397. * @param ammoInjection can be used to inject your own ammo reference
  108398. */
  108399. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108400. /**
  108401. * Sets the gravity of the physics world (m/(s^2))
  108402. * @param gravity Gravity to set
  108403. */
  108404. setGravity(gravity: Vector3): void;
  108405. /**
  108406. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108407. * @param timeStep timestep to use in seconds
  108408. */
  108409. setTimeStep(timeStep: number): void;
  108410. /**
  108411. * 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)
  108412. * @param fixedTimeStep fixedTimeStep to use in seconds
  108413. */
  108414. setFixedTimeStep(fixedTimeStep: number): void;
  108415. /**
  108416. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108417. * @param maxSteps the maximum number of steps by the physics engine per frame
  108418. */
  108419. setMaxSteps(maxSteps: number): void;
  108420. /**
  108421. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108422. * @returns the current timestep in seconds
  108423. */
  108424. getTimeStep(): number;
  108425. private _isImpostorInContact;
  108426. private _isImpostorPairInContact;
  108427. private _stepSimulation;
  108428. /**
  108429. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108430. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108431. * After the step the babylon meshes are set to the position of the physics imposters
  108432. * @param delta amount of time to step forward
  108433. * @param impostors array of imposters to update before/after the step
  108434. */
  108435. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108436. /**
  108437. * Update babylon mesh to match physics world object
  108438. * @param impostor imposter to match
  108439. */
  108440. private _afterSoftStep;
  108441. /**
  108442. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108443. * @param impostor imposter to match
  108444. */
  108445. private _ropeStep;
  108446. /**
  108447. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108448. * @param impostor imposter to match
  108449. */
  108450. private _softbodyOrClothStep;
  108451. private _tmpVector;
  108452. private _tmpMatrix;
  108453. /**
  108454. * Applies an impulse on the imposter
  108455. * @param impostor imposter to apply impulse to
  108456. * @param force amount of force to be applied to the imposter
  108457. * @param contactPoint the location to apply the impulse on the imposter
  108458. */
  108459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108460. /**
  108461. * Applies a force on the imposter
  108462. * @param impostor imposter to apply force
  108463. * @param force amount of force to be applied to the imposter
  108464. * @param contactPoint the location to apply the force on the imposter
  108465. */
  108466. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108467. /**
  108468. * Creates a physics body using the plugin
  108469. * @param impostor the imposter to create the physics body on
  108470. */
  108471. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108472. /**
  108473. * Removes the physics body from the imposter and disposes of the body's memory
  108474. * @param impostor imposter to remove the physics body from
  108475. */
  108476. removePhysicsBody(impostor: PhysicsImpostor): void;
  108477. /**
  108478. * Generates a joint
  108479. * @param impostorJoint the imposter joint to create the joint with
  108480. */
  108481. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108482. /**
  108483. * Removes a joint
  108484. * @param impostorJoint the imposter joint to remove the joint from
  108485. */
  108486. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108487. private _addMeshVerts;
  108488. /**
  108489. * Initialise the soft body vertices to match its object's (mesh) vertices
  108490. * Softbody vertices (nodes) are in world space and to match this
  108491. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108492. * @param impostor to create the softbody for
  108493. */
  108494. private _softVertexData;
  108495. /**
  108496. * Create an impostor's soft body
  108497. * @param impostor to create the softbody for
  108498. */
  108499. private _createSoftbody;
  108500. /**
  108501. * Create cloth for an impostor
  108502. * @param impostor to create the softbody for
  108503. */
  108504. private _createCloth;
  108505. /**
  108506. * Create rope for an impostor
  108507. * @param impostor to create the softbody for
  108508. */
  108509. private _createRope;
  108510. private _addHullVerts;
  108511. private _createShape;
  108512. /**
  108513. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108514. * @param impostor imposter containing the physics body and babylon object
  108515. */
  108516. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108517. /**
  108518. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108519. * @param impostor imposter containing the physics body and babylon object
  108520. * @param newPosition new position
  108521. * @param newRotation new rotation
  108522. */
  108523. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108524. /**
  108525. * If this plugin is supported
  108526. * @returns true if its supported
  108527. */
  108528. isSupported(): boolean;
  108529. /**
  108530. * Sets the linear velocity of the physics body
  108531. * @param impostor imposter to set the velocity on
  108532. * @param velocity velocity to set
  108533. */
  108534. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108535. /**
  108536. * Sets the angular velocity of the physics body
  108537. * @param impostor imposter to set the velocity on
  108538. * @param velocity velocity to set
  108539. */
  108540. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108541. /**
  108542. * gets the linear velocity
  108543. * @param impostor imposter to get linear velocity from
  108544. * @returns linear velocity
  108545. */
  108546. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108547. /**
  108548. * gets the angular velocity
  108549. * @param impostor imposter to get angular velocity from
  108550. * @returns angular velocity
  108551. */
  108552. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108553. /**
  108554. * Sets the mass of physics body
  108555. * @param impostor imposter to set the mass on
  108556. * @param mass mass to set
  108557. */
  108558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108559. /**
  108560. * Gets the mass of the physics body
  108561. * @param impostor imposter to get the mass from
  108562. * @returns mass
  108563. */
  108564. getBodyMass(impostor: PhysicsImpostor): number;
  108565. /**
  108566. * Gets friction of the impostor
  108567. * @param impostor impostor to get friction from
  108568. * @returns friction value
  108569. */
  108570. getBodyFriction(impostor: PhysicsImpostor): number;
  108571. /**
  108572. * Sets friction of the impostor
  108573. * @param impostor impostor to set friction on
  108574. * @param friction friction value
  108575. */
  108576. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108577. /**
  108578. * Gets restitution of the impostor
  108579. * @param impostor impostor to get restitution from
  108580. * @returns restitution value
  108581. */
  108582. getBodyRestitution(impostor: PhysicsImpostor): number;
  108583. /**
  108584. * Sets resitution of the impostor
  108585. * @param impostor impostor to set resitution on
  108586. * @param restitution resitution value
  108587. */
  108588. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108589. /**
  108590. * Gets pressure inside the impostor
  108591. * @param impostor impostor to get pressure from
  108592. * @returns pressure value
  108593. */
  108594. getBodyPressure(impostor: PhysicsImpostor): number;
  108595. /**
  108596. * Sets pressure inside a soft body impostor
  108597. * Cloth and rope must remain 0 pressure
  108598. * @param impostor impostor to set pressure on
  108599. * @param pressure pressure value
  108600. */
  108601. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108602. /**
  108603. * Gets stiffness of the impostor
  108604. * @param impostor impostor to get stiffness from
  108605. * @returns pressure value
  108606. */
  108607. getBodyStiffness(impostor: PhysicsImpostor): number;
  108608. /**
  108609. * Sets stiffness of the impostor
  108610. * @param impostor impostor to set stiffness on
  108611. * @param stiffness stiffness value from 0 to 1
  108612. */
  108613. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108614. /**
  108615. * Gets velocityIterations of the impostor
  108616. * @param impostor impostor to get velocity iterations from
  108617. * @returns velocityIterations value
  108618. */
  108619. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108620. /**
  108621. * Sets velocityIterations of the impostor
  108622. * @param impostor impostor to set velocity iterations on
  108623. * @param velocityIterations velocityIterations value
  108624. */
  108625. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108626. /**
  108627. * Gets positionIterations of the impostor
  108628. * @param impostor impostor to get position iterations from
  108629. * @returns positionIterations value
  108630. */
  108631. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108632. /**
  108633. * Sets positionIterations of the impostor
  108634. * @param impostor impostor to set position on
  108635. * @param positionIterations positionIterations value
  108636. */
  108637. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108638. /**
  108639. * Append an anchor to a cloth object
  108640. * @param impostor is the cloth impostor to add anchor to
  108641. * @param otherImpostor is the rigid impostor to anchor to
  108642. * @param width ratio across width from 0 to 1
  108643. * @param height ratio up height from 0 to 1
  108644. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108645. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108646. */
  108647. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108648. /**
  108649. * Append an hook to a rope object
  108650. * @param impostor is the rope impostor to add hook to
  108651. * @param otherImpostor is the rigid impostor to hook to
  108652. * @param length ratio along the rope from 0 to 1
  108653. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108654. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108655. */
  108656. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108657. /**
  108658. * Sleeps the physics body and stops it from being active
  108659. * @param impostor impostor to sleep
  108660. */
  108661. sleepBody(impostor: PhysicsImpostor): void;
  108662. /**
  108663. * Activates the physics body
  108664. * @param impostor impostor to activate
  108665. */
  108666. wakeUpBody(impostor: PhysicsImpostor): void;
  108667. /**
  108668. * Updates the distance parameters of the joint
  108669. * @param joint joint to update
  108670. * @param maxDistance maximum distance of the joint
  108671. * @param minDistance minimum distance of the joint
  108672. */
  108673. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108674. /**
  108675. * Sets a motor on the joint
  108676. * @param joint joint to set motor on
  108677. * @param speed speed of the motor
  108678. * @param maxForce maximum force of the motor
  108679. * @param motorIndex index of the motor
  108680. */
  108681. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108682. /**
  108683. * Sets the motors limit
  108684. * @param joint joint to set limit on
  108685. * @param upperLimit upper limit
  108686. * @param lowerLimit lower limit
  108687. */
  108688. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108689. /**
  108690. * Syncs the position and rotation of a mesh with the impostor
  108691. * @param mesh mesh to sync
  108692. * @param impostor impostor to update the mesh with
  108693. */
  108694. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108695. /**
  108696. * Gets the radius of the impostor
  108697. * @param impostor impostor to get radius from
  108698. * @returns the radius
  108699. */
  108700. getRadius(impostor: PhysicsImpostor): number;
  108701. /**
  108702. * Gets the box size of the impostor
  108703. * @param impostor impostor to get box size from
  108704. * @param result the resulting box size
  108705. */
  108706. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108707. /**
  108708. * Disposes of the impostor
  108709. */
  108710. dispose(): void;
  108711. /**
  108712. * Does a raycast in the physics world
  108713. * @param from when should the ray start?
  108714. * @param to when should the ray end?
  108715. * @returns PhysicsRaycastResult
  108716. */
  108717. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108718. }
  108719. }
  108720. declare module BABYLON {
  108721. interface AbstractScene {
  108722. /**
  108723. * The list of reflection probes added to the scene
  108724. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108725. */
  108726. reflectionProbes: Array<ReflectionProbe>;
  108727. /**
  108728. * Removes the given reflection probe from this scene.
  108729. * @param toRemove The reflection probe to remove
  108730. * @returns The index of the removed reflection probe
  108731. */
  108732. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108733. /**
  108734. * Adds the given reflection probe to this scene.
  108735. * @param newReflectionProbe The reflection probe to add
  108736. */
  108737. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108738. }
  108739. /**
  108740. * Class used to generate realtime reflection / refraction cube textures
  108741. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108742. */
  108743. export class ReflectionProbe {
  108744. /** defines the name of the probe */
  108745. name: string;
  108746. private _scene;
  108747. private _renderTargetTexture;
  108748. private _projectionMatrix;
  108749. private _viewMatrix;
  108750. private _target;
  108751. private _add;
  108752. private _attachedMesh;
  108753. private _invertYAxis;
  108754. /** Gets or sets probe position (center of the cube map) */
  108755. position: Vector3;
  108756. /**
  108757. * Creates a new reflection probe
  108758. * @param name defines the name of the probe
  108759. * @param size defines the texture resolution (for each face)
  108760. * @param scene defines the hosting scene
  108761. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108762. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108763. */
  108764. constructor(
  108765. /** defines the name of the probe */
  108766. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108767. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108768. samples: number;
  108769. /** Gets or sets the refresh rate to use (on every frame by default) */
  108770. refreshRate: number;
  108771. /**
  108772. * Gets the hosting scene
  108773. * @returns a Scene
  108774. */
  108775. getScene(): Scene;
  108776. /** Gets the internal CubeTexture used to render to */
  108777. readonly cubeTexture: RenderTargetTexture;
  108778. /** Gets the list of meshes to render */
  108779. readonly renderList: Nullable<AbstractMesh[]>;
  108780. /**
  108781. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108782. * @param mesh defines the mesh to attach to
  108783. */
  108784. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108785. /**
  108786. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108787. * @param renderingGroupId The rendering group id corresponding to its index
  108788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108789. */
  108790. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108791. /**
  108792. * Clean all associated resources
  108793. */
  108794. dispose(): void;
  108795. /**
  108796. * Converts the reflection probe information to a readable string for debug purpose.
  108797. * @param fullDetails Supports for multiple levels of logging within scene loading
  108798. * @returns the human readable reflection probe info
  108799. */
  108800. toString(fullDetails?: boolean): string;
  108801. /**
  108802. * Get the class name of the relfection probe.
  108803. * @returns "ReflectionProbe"
  108804. */
  108805. getClassName(): string;
  108806. /**
  108807. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108808. * @returns The JSON representation of the texture
  108809. */
  108810. serialize(): any;
  108811. /**
  108812. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108813. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108814. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108815. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108816. * @returns The parsed reflection probe if successful
  108817. */
  108818. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108819. }
  108820. }
  108821. declare module BABYLON {
  108822. /** @hidden */
  108823. export var _BabylonLoaderRegistered: boolean;
  108824. }
  108825. declare module BABYLON {
  108826. /**
  108827. * The Physically based simple base material of BJS.
  108828. *
  108829. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108830. * It is used as the base class for both the specGloss and metalRough conventions.
  108831. */
  108832. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108833. /**
  108834. * Number of Simultaneous lights allowed on the material.
  108835. */
  108836. maxSimultaneousLights: number;
  108837. /**
  108838. * If sets to true, disables all the lights affecting the material.
  108839. */
  108840. disableLighting: boolean;
  108841. /**
  108842. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108843. */
  108844. environmentTexture: BaseTexture;
  108845. /**
  108846. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108847. */
  108848. invertNormalMapX: boolean;
  108849. /**
  108850. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108851. */
  108852. invertNormalMapY: boolean;
  108853. /**
  108854. * Normal map used in the model.
  108855. */
  108856. normalTexture: BaseTexture;
  108857. /**
  108858. * Emissivie color used to self-illuminate the model.
  108859. */
  108860. emissiveColor: Color3;
  108861. /**
  108862. * Emissivie texture used to self-illuminate the model.
  108863. */
  108864. emissiveTexture: BaseTexture;
  108865. /**
  108866. * Occlusion Channel Strenght.
  108867. */
  108868. occlusionStrength: number;
  108869. /**
  108870. * Occlusion Texture of the material (adding extra occlusion effects).
  108871. */
  108872. occlusionTexture: BaseTexture;
  108873. /**
  108874. * Defines the alpha limits in alpha test mode.
  108875. */
  108876. alphaCutOff: number;
  108877. /**
  108878. * Gets the current double sided mode.
  108879. */
  108880. /**
  108881. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108882. */
  108883. doubleSided: boolean;
  108884. /**
  108885. * Stores the pre-calculated light information of a mesh in a texture.
  108886. */
  108887. lightmapTexture: BaseTexture;
  108888. /**
  108889. * If true, the light map contains occlusion information instead of lighting info.
  108890. */
  108891. useLightmapAsShadowmap: boolean;
  108892. /**
  108893. * Instantiates a new PBRMaterial instance.
  108894. *
  108895. * @param name The material name
  108896. * @param scene The scene the material will be use in.
  108897. */
  108898. constructor(name: string, scene: Scene);
  108899. getClassName(): string;
  108900. }
  108901. }
  108902. declare module BABYLON {
  108903. /**
  108904. * The PBR material of BJS following the metal roughness convention.
  108905. *
  108906. * This fits to the PBR convention in the GLTF definition:
  108907. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108908. */
  108909. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108910. /**
  108911. * The base color has two different interpretations depending on the value of metalness.
  108912. * When the material is a metal, the base color is the specific measured reflectance value
  108913. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108914. * of the material.
  108915. */
  108916. baseColor: Color3;
  108917. /**
  108918. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108919. * well as opacity information in the alpha channel.
  108920. */
  108921. baseTexture: BaseTexture;
  108922. /**
  108923. * Specifies the metallic scalar value of the material.
  108924. * Can also be used to scale the metalness values of the metallic texture.
  108925. */
  108926. metallic: number;
  108927. /**
  108928. * Specifies the roughness scalar value of the material.
  108929. * Can also be used to scale the roughness values of the metallic texture.
  108930. */
  108931. roughness: number;
  108932. /**
  108933. * Texture containing both the metallic value in the B channel and the
  108934. * roughness value in the G channel to keep better precision.
  108935. */
  108936. metallicRoughnessTexture: BaseTexture;
  108937. /**
  108938. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108939. *
  108940. * @param name The material name
  108941. * @param scene The scene the material will be use in.
  108942. */
  108943. constructor(name: string, scene: Scene);
  108944. /**
  108945. * Return the currrent class name of the material.
  108946. */
  108947. getClassName(): string;
  108948. /**
  108949. * Makes a duplicate of the current material.
  108950. * @param name - name to use for the new material.
  108951. */
  108952. clone(name: string): PBRMetallicRoughnessMaterial;
  108953. /**
  108954. * Serialize the material to a parsable JSON object.
  108955. */
  108956. serialize(): any;
  108957. /**
  108958. * Parses a JSON object correponding to the serialize function.
  108959. */
  108960. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108961. }
  108962. }
  108963. declare module BABYLON {
  108964. /**
  108965. * The PBR material of BJS following the specular glossiness convention.
  108966. *
  108967. * This fits to the PBR convention in the GLTF definition:
  108968. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108969. */
  108970. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108971. /**
  108972. * Specifies the diffuse color of the material.
  108973. */
  108974. diffuseColor: Color3;
  108975. /**
  108976. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108977. * channel.
  108978. */
  108979. diffuseTexture: BaseTexture;
  108980. /**
  108981. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108982. */
  108983. specularColor: Color3;
  108984. /**
  108985. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108986. */
  108987. glossiness: number;
  108988. /**
  108989. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108990. */
  108991. specularGlossinessTexture: BaseTexture;
  108992. /**
  108993. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108994. *
  108995. * @param name The material name
  108996. * @param scene The scene the material will be use in.
  108997. */
  108998. constructor(name: string, scene: Scene);
  108999. /**
  109000. * Return the currrent class name of the material.
  109001. */
  109002. getClassName(): string;
  109003. /**
  109004. * Makes a duplicate of the current material.
  109005. * @param name - name to use for the new material.
  109006. */
  109007. clone(name: string): PBRSpecularGlossinessMaterial;
  109008. /**
  109009. * Serialize the material to a parsable JSON object.
  109010. */
  109011. serialize(): any;
  109012. /**
  109013. * Parses a JSON object correponding to the serialize function.
  109014. */
  109015. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109016. }
  109017. }
  109018. declare module BABYLON {
  109019. /**
  109020. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109021. * It can help converting any input color in a desired output one. This can then be used to create effects
  109022. * from sepia, black and white to sixties or futuristic rendering...
  109023. *
  109024. * The only supported format is currently 3dl.
  109025. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109026. */
  109027. export class ColorGradingTexture extends BaseTexture {
  109028. /**
  109029. * The current texture matrix. (will always be identity in color grading texture)
  109030. */
  109031. private _textureMatrix;
  109032. /**
  109033. * The texture URL.
  109034. */
  109035. url: string;
  109036. /**
  109037. * Empty line regex stored for GC.
  109038. */
  109039. private static _noneEmptyLineRegex;
  109040. private _engine;
  109041. /**
  109042. * Instantiates a ColorGradingTexture from the following parameters.
  109043. *
  109044. * @param url The location of the color gradind data (currently only supporting 3dl)
  109045. * @param scene The scene the texture will be used in
  109046. */
  109047. constructor(url: string, scene: Scene);
  109048. /**
  109049. * Returns the texture matrix used in most of the material.
  109050. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109051. */
  109052. getTextureMatrix(): Matrix;
  109053. /**
  109054. * Occurs when the file being loaded is a .3dl LUT file.
  109055. */
  109056. private load3dlTexture;
  109057. /**
  109058. * Starts the loading process of the texture.
  109059. */
  109060. private loadTexture;
  109061. /**
  109062. * Clones the color gradind texture.
  109063. */
  109064. clone(): ColorGradingTexture;
  109065. /**
  109066. * Called during delayed load for textures.
  109067. */
  109068. delayLoad(): void;
  109069. /**
  109070. * Parses a color grading texture serialized by Babylon.
  109071. * @param parsedTexture The texture information being parsedTexture
  109072. * @param scene The scene to load the texture in
  109073. * @param rootUrl The root url of the data assets to load
  109074. * @return A color gradind texture
  109075. */
  109076. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109077. /**
  109078. * Serializes the LUT texture to json format.
  109079. */
  109080. serialize(): any;
  109081. }
  109082. }
  109083. declare module BABYLON {
  109084. /**
  109085. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109086. */
  109087. export class EquiRectangularCubeTexture extends BaseTexture {
  109088. /** The six faces of the cube. */
  109089. private static _FacesMapping;
  109090. private _noMipmap;
  109091. private _onLoad;
  109092. private _onError;
  109093. /** The size of the cubemap. */
  109094. private _size;
  109095. /** The buffer of the image. */
  109096. private _buffer;
  109097. /** The width of the input image. */
  109098. private _width;
  109099. /** The height of the input image. */
  109100. private _height;
  109101. /** The URL to the image. */
  109102. url: string;
  109103. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109104. coordinatesMode: number;
  109105. /**
  109106. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109107. * @param url The location of the image
  109108. * @param scene The scene the texture will be used in
  109109. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109110. * @param noMipmap Forces to not generate the mipmap if true
  109111. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109112. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109113. * @param onLoad — defines a callback called when texture is loaded
  109114. * @param onError — defines a callback called if there is an error
  109115. */
  109116. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109117. /**
  109118. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109119. */
  109120. private loadImage;
  109121. /**
  109122. * Convert the image buffer into a cubemap and create a CubeTexture.
  109123. */
  109124. private loadTexture;
  109125. /**
  109126. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109127. * @param buffer The ArrayBuffer that should be converted.
  109128. * @returns The buffer as Float32Array.
  109129. */
  109130. private getFloat32ArrayFromArrayBuffer;
  109131. /**
  109132. * Get the current class name of the texture useful for serialization or dynamic coding.
  109133. * @returns "EquiRectangularCubeTexture"
  109134. */
  109135. getClassName(): string;
  109136. /**
  109137. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109138. * @returns A clone of the current EquiRectangularCubeTexture.
  109139. */
  109140. clone(): EquiRectangularCubeTexture;
  109141. }
  109142. }
  109143. declare module BABYLON {
  109144. /**
  109145. * Based on jsTGALoader - Javascript loader for TGA file
  109146. * By Vincent Thibault
  109147. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109148. */
  109149. export class TGATools {
  109150. private static _TYPE_INDEXED;
  109151. private static _TYPE_RGB;
  109152. private static _TYPE_GREY;
  109153. private static _TYPE_RLE_INDEXED;
  109154. private static _TYPE_RLE_RGB;
  109155. private static _TYPE_RLE_GREY;
  109156. private static _ORIGIN_MASK;
  109157. private static _ORIGIN_SHIFT;
  109158. private static _ORIGIN_BL;
  109159. private static _ORIGIN_BR;
  109160. private static _ORIGIN_UL;
  109161. private static _ORIGIN_UR;
  109162. /**
  109163. * Gets the header of a TGA file
  109164. * @param data defines the TGA data
  109165. * @returns the header
  109166. */
  109167. static GetTGAHeader(data: Uint8Array): any;
  109168. /**
  109169. * Uploads TGA content to a Babylon Texture
  109170. * @hidden
  109171. */
  109172. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109173. /** @hidden */
  109174. 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;
  109175. /** @hidden */
  109176. 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;
  109177. /** @hidden */
  109178. 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;
  109179. /** @hidden */
  109180. 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;
  109181. /** @hidden */
  109182. 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;
  109183. /** @hidden */
  109184. 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;
  109185. }
  109186. }
  109187. declare module BABYLON {
  109188. /**
  109189. * Implementation of the TGA Texture Loader.
  109190. * @hidden
  109191. */
  109192. export class _TGATextureLoader implements IInternalTextureLoader {
  109193. /**
  109194. * Defines wether the loader supports cascade loading the different faces.
  109195. */
  109196. readonly supportCascades: boolean;
  109197. /**
  109198. * This returns if the loader support the current file information.
  109199. * @param extension defines the file extension of the file being loaded
  109200. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109201. * @param fallback defines the fallback internal texture if any
  109202. * @param isBase64 defines whether the texture is encoded as a base64
  109203. * @param isBuffer defines whether the texture data are stored as a buffer
  109204. * @returns true if the loader can load the specified file
  109205. */
  109206. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109207. /**
  109208. * Transform the url before loading if required.
  109209. * @param rootUrl the url of the texture
  109210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109211. * @returns the transformed texture
  109212. */
  109213. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109214. /**
  109215. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109216. * @param rootUrl the url of the texture
  109217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109218. * @returns the fallback texture
  109219. */
  109220. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109221. /**
  109222. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109223. * @param data contains the texture data
  109224. * @param texture defines the BabylonJS internal texture
  109225. * @param createPolynomials will be true if polynomials have been requested
  109226. * @param onLoad defines the callback to trigger once the texture is ready
  109227. * @param onError defines the callback to trigger in case of error
  109228. */
  109229. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109230. /**
  109231. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109232. * @param data contains the texture data
  109233. * @param texture defines the BabylonJS internal texture
  109234. * @param callback defines the method to call once ready to upload
  109235. */
  109236. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109237. }
  109238. }
  109239. declare module BABYLON {
  109240. /**
  109241. * 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.
  109242. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109243. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109244. */
  109245. export class CustomProceduralTexture extends ProceduralTexture {
  109246. private _animate;
  109247. private _time;
  109248. private _config;
  109249. private _texturePath;
  109250. /**
  109251. * Instantiates a new Custom Procedural Texture.
  109252. * 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.
  109253. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109254. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109255. * @param name Define the name of the texture
  109256. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109257. * @param size Define the size of the texture to create
  109258. * @param scene Define the scene the texture belongs to
  109259. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109260. * @param generateMipMaps Define if the texture should creates mip maps or not
  109261. */
  109262. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109263. private _loadJson;
  109264. /**
  109265. * Is the texture ready to be used ? (rendered at least once)
  109266. * @returns true if ready, otherwise, false.
  109267. */
  109268. isReady(): boolean;
  109269. /**
  109270. * Render the texture to its associated render target.
  109271. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109272. */
  109273. render(useCameraPostProcess?: boolean): void;
  109274. /**
  109275. * Update the list of dependant textures samplers in the shader.
  109276. */
  109277. updateTextures(): void;
  109278. /**
  109279. * Update the uniform values of the procedural texture in the shader.
  109280. */
  109281. updateShaderUniforms(): void;
  109282. /**
  109283. * Define if the texture animates or not.
  109284. */
  109285. animate: boolean;
  109286. }
  109287. }
  109288. declare module BABYLON {
  109289. /** @hidden */
  109290. export var noisePixelShader: {
  109291. name: string;
  109292. shader: string;
  109293. };
  109294. }
  109295. declare module BABYLON {
  109296. /**
  109297. * Class used to generate noise procedural textures
  109298. */
  109299. export class NoiseProceduralTexture extends ProceduralTexture {
  109300. private _time;
  109301. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109302. brightness: number;
  109303. /** Defines the number of octaves to process */
  109304. octaves: number;
  109305. /** Defines the level of persistence (0.8 by default) */
  109306. persistence: number;
  109307. /** Gets or sets animation speed factor (default is 1) */
  109308. animationSpeedFactor: number;
  109309. /**
  109310. * Creates a new NoiseProceduralTexture
  109311. * @param name defines the name fo the texture
  109312. * @param size defines the size of the texture (default is 256)
  109313. * @param scene defines the hosting scene
  109314. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109315. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109316. */
  109317. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109318. private _updateShaderUniforms;
  109319. protected _getDefines(): string;
  109320. /** Generate the current state of the procedural texture */
  109321. render(useCameraPostProcess?: boolean): void;
  109322. /**
  109323. * Serializes this noise procedural texture
  109324. * @returns a serialized noise procedural texture object
  109325. */
  109326. serialize(): any;
  109327. /**
  109328. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109329. * @param parsedTexture defines parsed texture data
  109330. * @param scene defines the current scene
  109331. * @param rootUrl defines the root URL containing noise procedural texture information
  109332. * @returns a parsed NoiseProceduralTexture
  109333. */
  109334. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109335. }
  109336. }
  109337. declare module BABYLON {
  109338. /**
  109339. * Raw cube texture where the raw buffers are passed in
  109340. */
  109341. export class RawCubeTexture extends CubeTexture {
  109342. /**
  109343. * Creates a cube texture where the raw buffers are passed in.
  109344. * @param scene defines the scene the texture is attached to
  109345. * @param data defines the array of data to use to create each face
  109346. * @param size defines the size of the textures
  109347. * @param format defines the format of the data
  109348. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109349. * @param generateMipMaps defines if the engine should generate the mip levels
  109350. * @param invertY defines if data must be stored with Y axis inverted
  109351. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109352. * @param compression defines the compression used (null by default)
  109353. */
  109354. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109355. /**
  109356. * Updates the raw cube texture.
  109357. * @param data defines the data to store
  109358. * @param format defines the data format
  109359. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109360. * @param invertY defines if data must be stored with Y axis inverted
  109361. * @param compression defines the compression used (null by default)
  109362. * @param level defines which level of the texture to update
  109363. */
  109364. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109365. /**
  109366. * Updates a raw cube texture with RGBD encoded data.
  109367. * @param data defines the array of data [mipmap][face] to use to create each face
  109368. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109369. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109370. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109371. * @returns a promsie that resolves when the operation is complete
  109372. */
  109373. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109374. /**
  109375. * Clones the raw cube texture.
  109376. * @return a new cube texture
  109377. */
  109378. clone(): CubeTexture;
  109379. /** @hidden */
  109380. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109381. }
  109382. }
  109383. declare module BABYLON {
  109384. /**
  109385. * Class used to store 3D textures containing user data
  109386. */
  109387. export class RawTexture3D extends Texture {
  109388. /** Gets or sets the texture format to use */
  109389. format: number;
  109390. private _engine;
  109391. /**
  109392. * Create a new RawTexture3D
  109393. * @param data defines the data of the texture
  109394. * @param width defines the width of the texture
  109395. * @param height defines the height of the texture
  109396. * @param depth defines the depth of the texture
  109397. * @param format defines the texture format to use
  109398. * @param scene defines the hosting scene
  109399. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109400. * @param invertY defines if texture must be stored with Y axis inverted
  109401. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109402. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109403. */
  109404. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109405. /** Gets or sets the texture format to use */
  109406. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109407. /**
  109408. * Update the texture with new data
  109409. * @param data defines the data to store in the texture
  109410. */
  109411. update(data: ArrayBufferView): void;
  109412. }
  109413. }
  109414. declare module BABYLON {
  109415. /**
  109416. * Creates a refraction texture used by refraction channel of the standard material.
  109417. * It is like a mirror but to see through a material.
  109418. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109419. */
  109420. export class RefractionTexture extends RenderTargetTexture {
  109421. /**
  109422. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109423. * 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.
  109424. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109425. */
  109426. refractionPlane: Plane;
  109427. /**
  109428. * Define how deep under the surface we should see.
  109429. */
  109430. depth: number;
  109431. /**
  109432. * Creates a refraction texture used by refraction channel of the standard material.
  109433. * It is like a mirror but to see through a material.
  109434. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109435. * @param name Define the texture name
  109436. * @param size Define the size of the underlying texture
  109437. * @param scene Define the scene the refraction belongs to
  109438. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109439. */
  109440. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109441. /**
  109442. * Clone the refraction texture.
  109443. * @returns the cloned texture
  109444. */
  109445. clone(): RefractionTexture;
  109446. /**
  109447. * Serialize the texture to a JSON representation you could use in Parse later on
  109448. * @returns the serialized JSON representation
  109449. */
  109450. serialize(): any;
  109451. }
  109452. }
  109453. declare module BABYLON {
  109454. /**
  109455. * Defines the options related to the creation of an HtmlElementTexture
  109456. */
  109457. export interface IHtmlElementTextureOptions {
  109458. /**
  109459. * Defines wether mip maps should be created or not.
  109460. */
  109461. generateMipMaps?: boolean;
  109462. /**
  109463. * Defines the sampling mode of the texture.
  109464. */
  109465. samplingMode?: number;
  109466. /**
  109467. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109468. */
  109469. engine: Nullable<Engine>;
  109470. /**
  109471. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109472. */
  109473. scene: Nullable<Scene>;
  109474. }
  109475. /**
  109476. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109477. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109478. * is automatically managed.
  109479. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109480. * in your application.
  109481. *
  109482. * As the update is not automatic, you need to call them manually.
  109483. */
  109484. export class HtmlElementTexture extends BaseTexture {
  109485. /**
  109486. * The texture URL.
  109487. */
  109488. element: HTMLVideoElement | HTMLCanvasElement;
  109489. private static readonly DefaultOptions;
  109490. private _textureMatrix;
  109491. private _engine;
  109492. private _isVideo;
  109493. private _generateMipMaps;
  109494. private _samplingMode;
  109495. /**
  109496. * Instantiates a HtmlElementTexture from the following parameters.
  109497. *
  109498. * @param name Defines the name of the texture
  109499. * @param element Defines the video or canvas the texture is filled with
  109500. * @param options Defines the other none mandatory texture creation options
  109501. */
  109502. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109503. private _createInternalTexture;
  109504. /**
  109505. * Returns the texture matrix used in most of the material.
  109506. */
  109507. getTextureMatrix(): Matrix;
  109508. /**
  109509. * Updates the content of the texture.
  109510. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109511. */
  109512. update(invertY?: Nullable<boolean>): void;
  109513. }
  109514. }
  109515. declare module BABYLON {
  109516. /**
  109517. * Helper class to push actions to a pool of workers.
  109518. */
  109519. export class WorkerPool implements IDisposable {
  109520. private _workerInfos;
  109521. private _pendingActions;
  109522. /**
  109523. * Constructor
  109524. * @param workers Array of workers to use for actions
  109525. */
  109526. constructor(workers: Array<Worker>);
  109527. /**
  109528. * Terminates all workers and clears any pending actions.
  109529. */
  109530. dispose(): void;
  109531. /**
  109532. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109533. * pended until a worker has completed its action.
  109534. * @param action The action to perform. Call onComplete when the action is complete.
  109535. */
  109536. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109537. private _execute;
  109538. }
  109539. }
  109540. declare module BABYLON {
  109541. /**
  109542. * Configuration for Draco compression
  109543. */
  109544. export interface IDracoCompressionConfiguration {
  109545. /**
  109546. * Configuration for the decoder.
  109547. */
  109548. decoder?: {
  109549. /**
  109550. * The url to the WebAssembly module.
  109551. */
  109552. wasmUrl?: string;
  109553. /**
  109554. * The url to the WebAssembly binary.
  109555. */
  109556. wasmBinaryUrl?: string;
  109557. /**
  109558. * The url to the fallback JavaScript module.
  109559. */
  109560. fallbackUrl?: string;
  109561. };
  109562. }
  109563. /**
  109564. * Draco compression (https://google.github.io/draco/)
  109565. *
  109566. * This class wraps the Draco module.
  109567. *
  109568. * **Encoder**
  109569. *
  109570. * The encoder is not currently implemented.
  109571. *
  109572. * **Decoder**
  109573. *
  109574. * 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.
  109575. *
  109576. * To update the configuration, use the following code:
  109577. * ```javascript
  109578. * DracoCompression.Configuration = {
  109579. * decoder: {
  109580. * wasmUrl: "<url to the WebAssembly library>",
  109581. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109582. * fallbackUrl: "<url to the fallback JavaScript library>",
  109583. * }
  109584. * };
  109585. * ```
  109586. *
  109587. * 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.
  109588. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109589. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  109590. *
  109591. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  109592. * ```javascript
  109593. * var dracoCompression = new DracoCompression();
  109594. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  109595. * [VertexBuffer.PositionKind]: 0
  109596. * });
  109597. * ```
  109598. *
  109599. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109600. */
  109601. export class DracoCompression implements IDisposable {
  109602. private _workerPoolPromise;
  109603. /**
  109604. * The configuration. Defaults to the following urls:
  109605. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109606. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109607. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109608. */
  109609. static Configuration: IDracoCompressionConfiguration;
  109610. /**
  109611. * Returns true if the decoder is available.
  109612. */
  109613. static readonly DecoderAvailable: boolean;
  109614. /**
  109615. * Default number of workers to create when creating the draco compression object.
  109616. */
  109617. static DefaultNumWorkers: number;
  109618. private static GetDefaultNumWorkers;
  109619. /**
  109620. * Constructor
  109621. * @param numWorkers The number of workers for async operations
  109622. */
  109623. constructor(numWorkers?: number);
  109624. /**
  109625. * Stop all async operations and release resources.
  109626. */
  109627. dispose(): void;
  109628. /**
  109629. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109630. * @returns a promise that resolves when ready
  109631. */
  109632. whenReadyAsync(): Promise<void>;
  109633. /**
  109634. * Decode Draco compressed mesh data to vertex data.
  109635. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109636. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109637. * @returns A promise that resolves with the decoded vertex data
  109638. */
  109639. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109640. [kind: string]: number;
  109641. }): Promise<VertexData>;
  109642. /**
  109643. * The worker function that gets converted to a blob url to pass into a worker.
  109644. */
  109645. private static _Worker;
  109646. private _loadDecoderWasmBinaryAsync;
  109647. }
  109648. }
  109649. declare module BABYLON {
  109650. /**
  109651. * Class for building Constructive Solid Geometry
  109652. */
  109653. export class CSG {
  109654. private polygons;
  109655. /**
  109656. * The world matrix
  109657. */
  109658. matrix: Matrix;
  109659. /**
  109660. * Stores the position
  109661. */
  109662. position: Vector3;
  109663. /**
  109664. * Stores the rotation
  109665. */
  109666. rotation: Vector3;
  109667. /**
  109668. * Stores the rotation quaternion
  109669. */
  109670. rotationQuaternion: Nullable<Quaternion>;
  109671. /**
  109672. * Stores the scaling vector
  109673. */
  109674. scaling: Vector3;
  109675. /**
  109676. * Convert the Mesh to CSG
  109677. * @param mesh The Mesh to convert to CSG
  109678. * @returns A new CSG from the Mesh
  109679. */
  109680. static FromMesh(mesh: Mesh): CSG;
  109681. /**
  109682. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109683. * @param polygons Polygons used to construct a CSG solid
  109684. */
  109685. private static FromPolygons;
  109686. /**
  109687. * Clones, or makes a deep copy, of the CSG
  109688. * @returns A new CSG
  109689. */
  109690. clone(): CSG;
  109691. /**
  109692. * Unions this CSG with another CSG
  109693. * @param csg The CSG to union against this CSG
  109694. * @returns The unioned CSG
  109695. */
  109696. union(csg: CSG): CSG;
  109697. /**
  109698. * Unions this CSG with another CSG in place
  109699. * @param csg The CSG to union against this CSG
  109700. */
  109701. unionInPlace(csg: CSG): void;
  109702. /**
  109703. * Subtracts this CSG with another CSG
  109704. * @param csg The CSG to subtract against this CSG
  109705. * @returns A new CSG
  109706. */
  109707. subtract(csg: CSG): CSG;
  109708. /**
  109709. * Subtracts this CSG with another CSG in place
  109710. * @param csg The CSG to subtact against this CSG
  109711. */
  109712. subtractInPlace(csg: CSG): void;
  109713. /**
  109714. * Intersect this CSG with another CSG
  109715. * @param csg The CSG to intersect against this CSG
  109716. * @returns A new CSG
  109717. */
  109718. intersect(csg: CSG): CSG;
  109719. /**
  109720. * Intersects this CSG with another CSG in place
  109721. * @param csg The CSG to intersect against this CSG
  109722. */
  109723. intersectInPlace(csg: CSG): void;
  109724. /**
  109725. * Return a new CSG solid with solid and empty space switched. This solid is
  109726. * not modified.
  109727. * @returns A new CSG solid with solid and empty space switched
  109728. */
  109729. inverse(): CSG;
  109730. /**
  109731. * Inverses the CSG in place
  109732. */
  109733. inverseInPlace(): void;
  109734. /**
  109735. * This is used to keep meshes transformations so they can be restored
  109736. * when we build back a Babylon Mesh
  109737. * NB : All CSG operations are performed in world coordinates
  109738. * @param csg The CSG to copy the transform attributes from
  109739. * @returns This CSG
  109740. */
  109741. copyTransformAttributes(csg: CSG): CSG;
  109742. /**
  109743. * Build Raw mesh from CSG
  109744. * Coordinates here are in world space
  109745. * @param name The name of the mesh geometry
  109746. * @param scene The Scene
  109747. * @param keepSubMeshes Specifies if the submeshes should be kept
  109748. * @returns A new Mesh
  109749. */
  109750. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109751. /**
  109752. * Build Mesh from CSG taking material and transforms into account
  109753. * @param name The name of the Mesh
  109754. * @param material The material of the Mesh
  109755. * @param scene The Scene
  109756. * @param keepSubMeshes Specifies if submeshes should be kept
  109757. * @returns The new Mesh
  109758. */
  109759. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109760. }
  109761. }
  109762. declare module BABYLON {
  109763. /**
  109764. * Class used to create a trail following a mesh
  109765. */
  109766. export class TrailMesh extends Mesh {
  109767. private _generator;
  109768. private _autoStart;
  109769. private _running;
  109770. private _diameter;
  109771. private _length;
  109772. private _sectionPolygonPointsCount;
  109773. private _sectionVectors;
  109774. private _sectionNormalVectors;
  109775. private _beforeRenderObserver;
  109776. /**
  109777. * @constructor
  109778. * @param name The value used by scene.getMeshByName() to do a lookup.
  109779. * @param generator The mesh to generate a trail.
  109780. * @param scene The scene to add this mesh to.
  109781. * @param diameter Diameter of trailing mesh. Default is 1.
  109782. * @param length Length of trailing mesh. Default is 60.
  109783. * @param autoStart Automatically start trailing mesh. Default true.
  109784. */
  109785. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109786. /**
  109787. * "TrailMesh"
  109788. * @returns "TrailMesh"
  109789. */
  109790. getClassName(): string;
  109791. private _createMesh;
  109792. /**
  109793. * Start trailing mesh.
  109794. */
  109795. start(): void;
  109796. /**
  109797. * Stop trailing mesh.
  109798. */
  109799. stop(): void;
  109800. /**
  109801. * Update trailing mesh geometry.
  109802. */
  109803. update(): void;
  109804. /**
  109805. * Returns a new TrailMesh object.
  109806. * @param name is a string, the name given to the new mesh
  109807. * @param newGenerator use new generator object for cloned trail mesh
  109808. * @returns a new mesh
  109809. */
  109810. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109811. /**
  109812. * Serializes this trail mesh
  109813. * @param serializationObject object to write serialization to
  109814. */
  109815. serialize(serializationObject: any): void;
  109816. /**
  109817. * Parses a serialized trail mesh
  109818. * @param parsedMesh the serialized mesh
  109819. * @param scene the scene to create the trail mesh in
  109820. * @returns the created trail mesh
  109821. */
  109822. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109823. }
  109824. }
  109825. declare module BABYLON {
  109826. /**
  109827. * Class containing static functions to help procedurally build meshes
  109828. */
  109829. export class TorusKnotBuilder {
  109830. /**
  109831. * Creates a torus knot mesh
  109832. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109833. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109834. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109835. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109839. * @param name defines the name of the mesh
  109840. * @param options defines the options used to create the mesh
  109841. * @param scene defines the hosting scene
  109842. * @returns the torus knot mesh
  109843. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109844. */
  109845. static CreateTorusKnot(name: string, options: {
  109846. radius?: number;
  109847. tube?: number;
  109848. radialSegments?: number;
  109849. tubularSegments?: number;
  109850. p?: number;
  109851. q?: number;
  109852. updatable?: boolean;
  109853. sideOrientation?: number;
  109854. frontUVs?: Vector4;
  109855. backUVs?: Vector4;
  109856. }, scene: any): Mesh;
  109857. }
  109858. }
  109859. declare module BABYLON {
  109860. /**
  109861. * Polygon
  109862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109863. */
  109864. export class Polygon {
  109865. /**
  109866. * Creates a rectangle
  109867. * @param xmin bottom X coord
  109868. * @param ymin bottom Y coord
  109869. * @param xmax top X coord
  109870. * @param ymax top Y coord
  109871. * @returns points that make the resulting rectation
  109872. */
  109873. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109874. /**
  109875. * Creates a circle
  109876. * @param radius radius of circle
  109877. * @param cx scale in x
  109878. * @param cy scale in y
  109879. * @param numberOfSides number of sides that make up the circle
  109880. * @returns points that make the resulting circle
  109881. */
  109882. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109883. /**
  109884. * Creates a polygon from input string
  109885. * @param input Input polygon data
  109886. * @returns the parsed points
  109887. */
  109888. static Parse(input: string): Vector2[];
  109889. /**
  109890. * Starts building a polygon from x and y coordinates
  109891. * @param x x coordinate
  109892. * @param y y coordinate
  109893. * @returns the started path2
  109894. */
  109895. static StartingAt(x: number, y: number): Path2;
  109896. }
  109897. /**
  109898. * Builds a polygon
  109899. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109900. */
  109901. export class PolygonMeshBuilder {
  109902. private _points;
  109903. private _outlinepoints;
  109904. private _holes;
  109905. private _name;
  109906. private _scene;
  109907. private _epoints;
  109908. private _eholes;
  109909. private _addToepoint;
  109910. /**
  109911. * Babylon reference to the earcut plugin.
  109912. */
  109913. bjsEarcut: any;
  109914. /**
  109915. * Creates a PolygonMeshBuilder
  109916. * @param name name of the builder
  109917. * @param contours Path of the polygon
  109918. * @param scene scene to add to when creating the mesh
  109919. * @param earcutInjection can be used to inject your own earcut reference
  109920. */
  109921. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109922. /**
  109923. * Adds a whole within the polygon
  109924. * @param hole Array of points defining the hole
  109925. * @returns this
  109926. */
  109927. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109928. /**
  109929. * Creates the polygon
  109930. * @param updatable If the mesh should be updatable
  109931. * @param depth The depth of the mesh created
  109932. * @returns the created mesh
  109933. */
  109934. build(updatable?: boolean, depth?: number): Mesh;
  109935. /**
  109936. * Creates the polygon
  109937. * @param depth The depth of the mesh created
  109938. * @returns the created VertexData
  109939. */
  109940. buildVertexData(depth?: number): VertexData;
  109941. /**
  109942. * Adds a side to the polygon
  109943. * @param positions points that make the polygon
  109944. * @param normals normals of the polygon
  109945. * @param uvs uvs of the polygon
  109946. * @param indices indices of the polygon
  109947. * @param bounds bounds of the polygon
  109948. * @param points points of the polygon
  109949. * @param depth depth of the polygon
  109950. * @param flip flip of the polygon
  109951. */
  109952. private addSide;
  109953. }
  109954. }
  109955. declare module BABYLON {
  109956. /**
  109957. * Class containing static functions to help procedurally build meshes
  109958. */
  109959. export class PolygonBuilder {
  109960. /**
  109961. * Creates a polygon mesh
  109962. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109963. * * 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
  109964. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109967. * * Remember you can only change the shape positions, not their number when updating a polygon
  109968. * @param name defines the name of the mesh
  109969. * @param options defines the options used to create the mesh
  109970. * @param scene defines the hosting scene
  109971. * @param earcutInjection can be used to inject your own earcut reference
  109972. * @returns the polygon mesh
  109973. */
  109974. static CreatePolygon(name: string, options: {
  109975. shape: Vector3[];
  109976. holes?: Vector3[][];
  109977. depth?: number;
  109978. faceUV?: Vector4[];
  109979. faceColors?: Color4[];
  109980. updatable?: boolean;
  109981. sideOrientation?: number;
  109982. frontUVs?: Vector4;
  109983. backUVs?: Vector4;
  109984. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109985. /**
  109986. * Creates an extruded polygon mesh, with depth in the Y direction.
  109987. * * 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)
  109988. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109989. * @param name defines the name of the mesh
  109990. * @param options defines the options used to create the mesh
  109991. * @param scene defines the hosting scene
  109992. * @param earcutInjection can be used to inject your own earcut reference
  109993. * @returns the polygon mesh
  109994. */
  109995. static ExtrudePolygon(name: string, options: {
  109996. shape: Vector3[];
  109997. holes?: Vector3[][];
  109998. depth?: number;
  109999. faceUV?: Vector4[];
  110000. faceColors?: Color4[];
  110001. updatable?: boolean;
  110002. sideOrientation?: number;
  110003. frontUVs?: Vector4;
  110004. backUVs?: Vector4;
  110005. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110006. }
  110007. }
  110008. declare module BABYLON {
  110009. /**
  110010. * Class containing static functions to help procedurally build meshes
  110011. */
  110012. export class LatheBuilder {
  110013. /**
  110014. * Creates lathe mesh.
  110015. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110016. * * 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
  110017. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110018. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110019. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110020. * * 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
  110021. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110022. * * 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
  110023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110027. * @param name defines the name of the mesh
  110028. * @param options defines the options used to create the mesh
  110029. * @param scene defines the hosting scene
  110030. * @returns the lathe mesh
  110031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110032. */
  110033. static CreateLathe(name: string, options: {
  110034. shape: Vector3[];
  110035. radius?: number;
  110036. tessellation?: number;
  110037. clip?: number;
  110038. arc?: number;
  110039. closed?: boolean;
  110040. updatable?: boolean;
  110041. sideOrientation?: number;
  110042. frontUVs?: Vector4;
  110043. backUVs?: Vector4;
  110044. cap?: number;
  110045. invertUV?: boolean;
  110046. }, scene?: Nullable<Scene>): Mesh;
  110047. }
  110048. }
  110049. declare module BABYLON {
  110050. /**
  110051. * Class containing static functions to help procedurally build meshes
  110052. */
  110053. export class TubeBuilder {
  110054. /**
  110055. * Creates a tube mesh.
  110056. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110057. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110058. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110059. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110060. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110061. * * 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)
  110062. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110063. * * 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
  110064. * * 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
  110065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110069. * @param name defines the name of the mesh
  110070. * @param options defines the options used to create the mesh
  110071. * @param scene defines the hosting scene
  110072. * @returns the tube mesh
  110073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110074. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110075. */
  110076. static CreateTube(name: string, options: {
  110077. path: Vector3[];
  110078. radius?: number;
  110079. tessellation?: number;
  110080. radiusFunction?: {
  110081. (i: number, distance: number): number;
  110082. };
  110083. cap?: number;
  110084. arc?: number;
  110085. updatable?: boolean;
  110086. sideOrientation?: number;
  110087. frontUVs?: Vector4;
  110088. backUVs?: Vector4;
  110089. instance?: Mesh;
  110090. invertUV?: boolean;
  110091. }, scene?: Nullable<Scene>): Mesh;
  110092. }
  110093. }
  110094. declare module BABYLON {
  110095. /**
  110096. * Class containing static functions to help procedurally build meshes
  110097. */
  110098. export class IcoSphereBuilder {
  110099. /**
  110100. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110101. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110102. * * 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`)
  110103. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110104. * * 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
  110105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110108. * @param name defines the name of the mesh
  110109. * @param options defines the options used to create the mesh
  110110. * @param scene defines the hosting scene
  110111. * @returns the icosahedron mesh
  110112. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110113. */
  110114. static CreateIcoSphere(name: string, options: {
  110115. radius?: number;
  110116. radiusX?: number;
  110117. radiusY?: number;
  110118. radiusZ?: number;
  110119. flat?: boolean;
  110120. subdivisions?: number;
  110121. sideOrientation?: number;
  110122. frontUVs?: Vector4;
  110123. backUVs?: Vector4;
  110124. updatable?: boolean;
  110125. }, scene?: Nullable<Scene>): Mesh;
  110126. }
  110127. }
  110128. declare module BABYLON {
  110129. /**
  110130. * Class containing static functions to help procedurally build meshes
  110131. */
  110132. export class DecalBuilder {
  110133. /**
  110134. * Creates a decal mesh.
  110135. * 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
  110136. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110137. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110138. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110139. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110140. * @param name defines the name of the mesh
  110141. * @param sourceMesh defines the mesh where the decal must be applied
  110142. * @param options defines the options used to create the mesh
  110143. * @param scene defines the hosting scene
  110144. * @returns the decal mesh
  110145. * @see https://doc.babylonjs.com/how_to/decals
  110146. */
  110147. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110148. position?: Vector3;
  110149. normal?: Vector3;
  110150. size?: Vector3;
  110151. angle?: number;
  110152. }): Mesh;
  110153. }
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * Class containing static functions to help procedurally build meshes
  110158. */
  110159. export class MeshBuilder {
  110160. /**
  110161. * Creates a box mesh
  110162. * * The parameter `size` sets the size (float) of each box side (default 1)
  110163. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110164. * * 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)
  110165. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110169. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110170. * @param name defines the name of the mesh
  110171. * @param options defines the options used to create the mesh
  110172. * @param scene defines the hosting scene
  110173. * @returns the box mesh
  110174. */
  110175. static CreateBox(name: string, options: {
  110176. size?: number;
  110177. width?: number;
  110178. height?: number;
  110179. depth?: number;
  110180. faceUV?: Vector4[];
  110181. faceColors?: Color4[];
  110182. sideOrientation?: number;
  110183. frontUVs?: Vector4;
  110184. backUVs?: Vector4;
  110185. updatable?: boolean;
  110186. }, scene?: Nullable<Scene>): Mesh;
  110187. /**
  110188. * Creates a sphere mesh
  110189. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110190. * * 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`)
  110191. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110192. * * 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
  110193. * * 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)
  110194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110197. * @param name defines the name of the mesh
  110198. * @param options defines the options used to create the mesh
  110199. * @param scene defines the hosting scene
  110200. * @returns the sphere mesh
  110201. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110202. */
  110203. static CreateSphere(name: string, options: {
  110204. segments?: number;
  110205. diameter?: number;
  110206. diameterX?: number;
  110207. diameterY?: number;
  110208. diameterZ?: number;
  110209. arc?: number;
  110210. slice?: number;
  110211. sideOrientation?: number;
  110212. frontUVs?: Vector4;
  110213. backUVs?: Vector4;
  110214. updatable?: boolean;
  110215. }, scene?: Nullable<Scene>): Mesh;
  110216. /**
  110217. * Creates a plane polygonal mesh. By default, this is a disc
  110218. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110219. * * 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
  110220. * * 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
  110221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110224. * @param name defines the name of the mesh
  110225. * @param options defines the options used to create the mesh
  110226. * @param scene defines the hosting scene
  110227. * @returns the plane polygonal mesh
  110228. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110229. */
  110230. static CreateDisc(name: string, options: {
  110231. radius?: number;
  110232. tessellation?: number;
  110233. arc?: number;
  110234. updatable?: boolean;
  110235. sideOrientation?: number;
  110236. frontUVs?: Vector4;
  110237. backUVs?: Vector4;
  110238. }, scene?: Nullable<Scene>): Mesh;
  110239. /**
  110240. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110241. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110242. * * 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`)
  110243. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110244. * * 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
  110245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110248. * @param name defines the name of the mesh
  110249. * @param options defines the options used to create the mesh
  110250. * @param scene defines the hosting scene
  110251. * @returns the icosahedron mesh
  110252. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110253. */
  110254. static CreateIcoSphere(name: string, options: {
  110255. radius?: number;
  110256. radiusX?: number;
  110257. radiusY?: number;
  110258. radiusZ?: number;
  110259. flat?: boolean;
  110260. subdivisions?: number;
  110261. sideOrientation?: number;
  110262. frontUVs?: Vector4;
  110263. backUVs?: Vector4;
  110264. updatable?: boolean;
  110265. }, scene?: Nullable<Scene>): Mesh;
  110266. /**
  110267. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110268. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110269. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110270. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110271. * * 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
  110272. * * 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
  110273. * * 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
  110274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110277. * * 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
  110278. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110279. * * 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
  110280. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110282. * @param name defines the name of the mesh
  110283. * @param options defines the options used to create the mesh
  110284. * @param scene defines the hosting scene
  110285. * @returns the ribbon mesh
  110286. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110287. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110288. */
  110289. static CreateRibbon(name: string, options: {
  110290. pathArray: Vector3[][];
  110291. closeArray?: boolean;
  110292. closePath?: boolean;
  110293. offset?: number;
  110294. updatable?: boolean;
  110295. sideOrientation?: number;
  110296. frontUVs?: Vector4;
  110297. backUVs?: Vector4;
  110298. instance?: Mesh;
  110299. invertUV?: boolean;
  110300. uvs?: Vector2[];
  110301. colors?: Color4[];
  110302. }, scene?: Nullable<Scene>): Mesh;
  110303. /**
  110304. * Creates a cylinder or a cone mesh
  110305. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110306. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110307. * * 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.
  110308. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110309. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110310. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110311. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110312. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110313. * * 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).
  110314. * * 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
  110315. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110316. * * 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
  110317. * * 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.
  110318. * * If `enclose` is false, a ring surface is one element.
  110319. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110320. * * 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
  110321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110324. * @param name defines the name of the mesh
  110325. * @param options defines the options used to create the mesh
  110326. * @param scene defines the hosting scene
  110327. * @returns the cylinder mesh
  110328. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110329. */
  110330. static CreateCylinder(name: string, options: {
  110331. height?: number;
  110332. diameterTop?: number;
  110333. diameterBottom?: number;
  110334. diameter?: number;
  110335. tessellation?: number;
  110336. subdivisions?: number;
  110337. arc?: number;
  110338. faceColors?: Color4[];
  110339. faceUV?: Vector4[];
  110340. updatable?: boolean;
  110341. hasRings?: boolean;
  110342. enclose?: boolean;
  110343. sideOrientation?: number;
  110344. frontUVs?: Vector4;
  110345. backUVs?: Vector4;
  110346. }, scene?: Nullable<Scene>): Mesh;
  110347. /**
  110348. * Creates a torus mesh
  110349. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110350. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110351. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110355. * @param name defines the name of the mesh
  110356. * @param options defines the options used to create the mesh
  110357. * @param scene defines the hosting scene
  110358. * @returns the torus mesh
  110359. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110360. */
  110361. static CreateTorus(name: string, options: {
  110362. diameter?: number;
  110363. thickness?: number;
  110364. tessellation?: number;
  110365. updatable?: boolean;
  110366. sideOrientation?: number;
  110367. frontUVs?: Vector4;
  110368. backUVs?: Vector4;
  110369. }, scene?: Nullable<Scene>): Mesh;
  110370. /**
  110371. * Creates a torus knot mesh
  110372. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110373. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110374. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110375. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110379. * @param name defines the name of the mesh
  110380. * @param options defines the options used to create the mesh
  110381. * @param scene defines the hosting scene
  110382. * @returns the torus knot mesh
  110383. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110384. */
  110385. static CreateTorusKnot(name: string, options: {
  110386. radius?: number;
  110387. tube?: number;
  110388. radialSegments?: number;
  110389. tubularSegments?: number;
  110390. p?: number;
  110391. q?: number;
  110392. updatable?: boolean;
  110393. sideOrientation?: number;
  110394. frontUVs?: Vector4;
  110395. backUVs?: Vector4;
  110396. }, scene?: Nullable<Scene>): Mesh;
  110397. /**
  110398. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110399. * * 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
  110400. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110401. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110402. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110403. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110404. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110405. * * 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
  110406. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110409. * @param name defines the name of the new line system
  110410. * @param options defines the options used to create the line system
  110411. * @param scene defines the hosting scene
  110412. * @returns a new line system mesh
  110413. */
  110414. static CreateLineSystem(name: string, options: {
  110415. lines: Vector3[][];
  110416. updatable?: boolean;
  110417. instance?: Nullable<LinesMesh>;
  110418. colors?: Nullable<Color4[][]>;
  110419. useVertexAlpha?: boolean;
  110420. }, scene: Nullable<Scene>): LinesMesh;
  110421. /**
  110422. * Creates a line mesh
  110423. * 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
  110424. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110425. * * The parameter `points` is an array successive Vector3
  110426. * * 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
  110427. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110428. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110429. * * When updating an instance, remember that only point positions can change, not the number of points
  110430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110432. * @param name defines the name of the new line system
  110433. * @param options defines the options used to create the line system
  110434. * @param scene defines the hosting scene
  110435. * @returns a new line mesh
  110436. */
  110437. static CreateLines(name: string, options: {
  110438. points: Vector3[];
  110439. updatable?: boolean;
  110440. instance?: Nullable<LinesMesh>;
  110441. colors?: Color4[];
  110442. useVertexAlpha?: boolean;
  110443. }, scene?: Nullable<Scene>): LinesMesh;
  110444. /**
  110445. * Creates a dashed line mesh
  110446. * * 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
  110447. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110448. * * The parameter `points` is an array successive Vector3
  110449. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110450. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110451. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110452. * * 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
  110453. * * When updating an instance, remember that only point positions can change, not the number of points
  110454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110455. * @param name defines the name of the mesh
  110456. * @param options defines the options used to create the mesh
  110457. * @param scene defines the hosting scene
  110458. * @returns the dashed line mesh
  110459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110460. */
  110461. static CreateDashedLines(name: string, options: {
  110462. points: Vector3[];
  110463. dashSize?: number;
  110464. gapSize?: number;
  110465. dashNb?: number;
  110466. updatable?: boolean;
  110467. instance?: LinesMesh;
  110468. }, scene?: Nullable<Scene>): LinesMesh;
  110469. /**
  110470. * 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.
  110471. * * 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.
  110472. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110473. * * 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.
  110474. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110475. * * 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
  110476. * * 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
  110477. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110482. * @param name defines the name of the mesh
  110483. * @param options defines the options used to create the mesh
  110484. * @param scene defines the hosting scene
  110485. * @returns the extruded shape mesh
  110486. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110488. */
  110489. static ExtrudeShape(name: string, options: {
  110490. shape: Vector3[];
  110491. path: Vector3[];
  110492. scale?: number;
  110493. rotation?: number;
  110494. cap?: number;
  110495. updatable?: boolean;
  110496. sideOrientation?: number;
  110497. frontUVs?: Vector4;
  110498. backUVs?: Vector4;
  110499. instance?: Mesh;
  110500. invertUV?: boolean;
  110501. }, scene?: Nullable<Scene>): Mesh;
  110502. /**
  110503. * Creates an custom extruded shape mesh.
  110504. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110505. * * 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.
  110506. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110507. * * 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
  110508. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110509. * * 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
  110510. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110511. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110512. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110513. * * 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
  110514. * * 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
  110515. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110520. * @param name defines the name of the mesh
  110521. * @param options defines the options used to create the mesh
  110522. * @param scene defines the hosting scene
  110523. * @returns the custom extruded shape mesh
  110524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110525. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110527. */
  110528. static ExtrudeShapeCustom(name: string, options: {
  110529. shape: Vector3[];
  110530. path: Vector3[];
  110531. scaleFunction?: any;
  110532. rotationFunction?: any;
  110533. ribbonCloseArray?: boolean;
  110534. ribbonClosePath?: boolean;
  110535. cap?: number;
  110536. updatable?: boolean;
  110537. sideOrientation?: number;
  110538. frontUVs?: Vector4;
  110539. backUVs?: Vector4;
  110540. instance?: Mesh;
  110541. invertUV?: boolean;
  110542. }, scene?: Nullable<Scene>): Mesh;
  110543. /**
  110544. * Creates lathe mesh.
  110545. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110546. * * 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
  110547. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110548. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110549. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110550. * * 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
  110551. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110552. * * 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
  110553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110555. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110557. * @param name defines the name of the mesh
  110558. * @param options defines the options used to create the mesh
  110559. * @param scene defines the hosting scene
  110560. * @returns the lathe mesh
  110561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110562. */
  110563. static CreateLathe(name: string, options: {
  110564. shape: Vector3[];
  110565. radius?: number;
  110566. tessellation?: number;
  110567. clip?: number;
  110568. arc?: number;
  110569. closed?: boolean;
  110570. updatable?: boolean;
  110571. sideOrientation?: number;
  110572. frontUVs?: Vector4;
  110573. backUVs?: Vector4;
  110574. cap?: number;
  110575. invertUV?: boolean;
  110576. }, scene?: Nullable<Scene>): Mesh;
  110577. /**
  110578. * Creates a plane mesh
  110579. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110580. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110581. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110585. * @param name defines the name of the mesh
  110586. * @param options defines the options used to create the mesh
  110587. * @param scene defines the hosting scene
  110588. * @returns the plane mesh
  110589. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110590. */
  110591. static CreatePlane(name: string, options: {
  110592. size?: number;
  110593. width?: number;
  110594. height?: number;
  110595. sideOrientation?: number;
  110596. frontUVs?: Vector4;
  110597. backUVs?: Vector4;
  110598. updatable?: boolean;
  110599. sourcePlane?: Plane;
  110600. }, scene?: Nullable<Scene>): Mesh;
  110601. /**
  110602. * Creates a ground mesh
  110603. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110604. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110606. * @param name defines the name of the mesh
  110607. * @param options defines the options used to create the mesh
  110608. * @param scene defines the hosting scene
  110609. * @returns the ground mesh
  110610. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110611. */
  110612. static CreateGround(name: string, options: {
  110613. width?: number;
  110614. height?: number;
  110615. subdivisions?: number;
  110616. subdivisionsX?: number;
  110617. subdivisionsY?: number;
  110618. updatable?: boolean;
  110619. }, scene?: Nullable<Scene>): Mesh;
  110620. /**
  110621. * Creates a tiled ground mesh
  110622. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110623. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110624. * * 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
  110625. * * 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
  110626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110627. * @param name defines the name of the mesh
  110628. * @param options defines the options used to create the mesh
  110629. * @param scene defines the hosting scene
  110630. * @returns the tiled ground mesh
  110631. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110632. */
  110633. static CreateTiledGround(name: string, options: {
  110634. xmin: number;
  110635. zmin: number;
  110636. xmax: number;
  110637. zmax: number;
  110638. subdivisions?: {
  110639. w: number;
  110640. h: number;
  110641. };
  110642. precision?: {
  110643. w: number;
  110644. h: number;
  110645. };
  110646. updatable?: boolean;
  110647. }, scene?: Nullable<Scene>): Mesh;
  110648. /**
  110649. * Creates a ground mesh from a height map
  110650. * * The parameter `url` sets the URL of the height map image resource.
  110651. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110652. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110653. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110654. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110655. * * 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.
  110656. * * 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).
  110657. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110659. * @param name defines the name of the mesh
  110660. * @param url defines the url to the height map
  110661. * @param options defines the options used to create the mesh
  110662. * @param scene defines the hosting scene
  110663. * @returns the ground mesh
  110664. * @see https://doc.babylonjs.com/babylon101/height_map
  110665. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110666. */
  110667. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110668. width?: number;
  110669. height?: number;
  110670. subdivisions?: number;
  110671. minHeight?: number;
  110672. maxHeight?: number;
  110673. colorFilter?: Color3;
  110674. alphaFilter?: number;
  110675. updatable?: boolean;
  110676. onReady?: (mesh: GroundMesh) => void;
  110677. }, scene?: Nullable<Scene>): GroundMesh;
  110678. /**
  110679. * Creates a polygon mesh
  110680. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110681. * * 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
  110682. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110685. * * Remember you can only change the shape positions, not their number when updating a polygon
  110686. * @param name defines the name of the mesh
  110687. * @param options defines the options used to create the mesh
  110688. * @param scene defines the hosting scene
  110689. * @param earcutInjection can be used to inject your own earcut reference
  110690. * @returns the polygon mesh
  110691. */
  110692. static CreatePolygon(name: string, options: {
  110693. shape: Vector3[];
  110694. holes?: Vector3[][];
  110695. depth?: number;
  110696. faceUV?: Vector4[];
  110697. faceColors?: Color4[];
  110698. updatable?: boolean;
  110699. sideOrientation?: number;
  110700. frontUVs?: Vector4;
  110701. backUVs?: Vector4;
  110702. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110703. /**
  110704. * Creates an extruded polygon mesh, with depth in the Y direction.
  110705. * * 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)
  110706. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110707. * @param name defines the name of the mesh
  110708. * @param options defines the options used to create the mesh
  110709. * @param scene defines the hosting scene
  110710. * @param earcutInjection can be used to inject your own earcut reference
  110711. * @returns the polygon mesh
  110712. */
  110713. static ExtrudePolygon(name: string, options: {
  110714. shape: Vector3[];
  110715. holes?: Vector3[][];
  110716. depth?: number;
  110717. faceUV?: Vector4[];
  110718. faceColors?: Color4[];
  110719. updatable?: boolean;
  110720. sideOrientation?: number;
  110721. frontUVs?: Vector4;
  110722. backUVs?: Vector4;
  110723. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110724. /**
  110725. * Creates a tube mesh.
  110726. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110727. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110728. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110729. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110730. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110731. * * 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)
  110732. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110733. * * 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
  110734. * * 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
  110735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110739. * @param name defines the name of the mesh
  110740. * @param options defines the options used to create the mesh
  110741. * @param scene defines the hosting scene
  110742. * @returns the tube mesh
  110743. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110744. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110745. */
  110746. static CreateTube(name: string, options: {
  110747. path: Vector3[];
  110748. radius?: number;
  110749. tessellation?: number;
  110750. radiusFunction?: {
  110751. (i: number, distance: number): number;
  110752. };
  110753. cap?: number;
  110754. arc?: number;
  110755. updatable?: boolean;
  110756. sideOrientation?: number;
  110757. frontUVs?: Vector4;
  110758. backUVs?: Vector4;
  110759. instance?: Mesh;
  110760. invertUV?: boolean;
  110761. }, scene?: Nullable<Scene>): Mesh;
  110762. /**
  110763. * Creates a polyhedron mesh
  110764. * * 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
  110765. * * The parameter `size` (positive float, default 1) sets the polygon size
  110766. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110767. * * 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`
  110768. * * 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
  110769. * * 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)`)
  110770. * * 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
  110771. * * 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
  110772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110775. * @param name defines the name of the mesh
  110776. * @param options defines the options used to create the mesh
  110777. * @param scene defines the hosting scene
  110778. * @returns the polyhedron mesh
  110779. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110780. */
  110781. static CreatePolyhedron(name: string, options: {
  110782. type?: number;
  110783. size?: number;
  110784. sizeX?: number;
  110785. sizeY?: number;
  110786. sizeZ?: number;
  110787. custom?: any;
  110788. faceUV?: Vector4[];
  110789. faceColors?: Color4[];
  110790. flat?: boolean;
  110791. updatable?: boolean;
  110792. sideOrientation?: number;
  110793. frontUVs?: Vector4;
  110794. backUVs?: Vector4;
  110795. }, scene?: Nullable<Scene>): Mesh;
  110796. /**
  110797. * Creates a decal mesh.
  110798. * 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
  110799. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110800. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110801. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110802. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110803. * @param name defines the name of the mesh
  110804. * @param sourceMesh defines the mesh where the decal must be applied
  110805. * @param options defines the options used to create the mesh
  110806. * @param scene defines the hosting scene
  110807. * @returns the decal mesh
  110808. * @see https://doc.babylonjs.com/how_to/decals
  110809. */
  110810. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110811. position?: Vector3;
  110812. normal?: Vector3;
  110813. size?: Vector3;
  110814. angle?: number;
  110815. }): Mesh;
  110816. }
  110817. }
  110818. declare module BABYLON {
  110819. /**
  110820. * A simplifier interface for future simplification implementations
  110821. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110822. */
  110823. export interface ISimplifier {
  110824. /**
  110825. * Simplification of a given mesh according to the given settings.
  110826. * Since this requires computation, it is assumed that the function runs async.
  110827. * @param settings The settings of the simplification, including quality and distance
  110828. * @param successCallback A callback that will be called after the mesh was simplified.
  110829. * @param errorCallback in case of an error, this callback will be called. optional.
  110830. */
  110831. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110832. }
  110833. /**
  110834. * Expected simplification settings.
  110835. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110836. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110837. */
  110838. export interface ISimplificationSettings {
  110839. /**
  110840. * Gets or sets the expected quality
  110841. */
  110842. quality: number;
  110843. /**
  110844. * Gets or sets the distance when this optimized version should be used
  110845. */
  110846. distance: number;
  110847. /**
  110848. * Gets an already optimized mesh
  110849. */
  110850. optimizeMesh?: boolean;
  110851. }
  110852. /**
  110853. * Class used to specify simplification options
  110854. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110855. */
  110856. export class SimplificationSettings implements ISimplificationSettings {
  110857. /** expected quality */
  110858. quality: number;
  110859. /** distance when this optimized version should be used */
  110860. distance: number;
  110861. /** already optimized mesh */
  110862. optimizeMesh?: boolean | undefined;
  110863. /**
  110864. * Creates a SimplificationSettings
  110865. * @param quality expected quality
  110866. * @param distance distance when this optimized version should be used
  110867. * @param optimizeMesh already optimized mesh
  110868. */
  110869. constructor(
  110870. /** expected quality */
  110871. quality: number,
  110872. /** distance when this optimized version should be used */
  110873. distance: number,
  110874. /** already optimized mesh */
  110875. optimizeMesh?: boolean | undefined);
  110876. }
  110877. /**
  110878. * Interface used to define a simplification task
  110879. */
  110880. export interface ISimplificationTask {
  110881. /**
  110882. * Array of settings
  110883. */
  110884. settings: Array<ISimplificationSettings>;
  110885. /**
  110886. * Simplification type
  110887. */
  110888. simplificationType: SimplificationType;
  110889. /**
  110890. * Mesh to simplify
  110891. */
  110892. mesh: Mesh;
  110893. /**
  110894. * Callback called on success
  110895. */
  110896. successCallback?: () => void;
  110897. /**
  110898. * Defines if parallel processing can be used
  110899. */
  110900. parallelProcessing: boolean;
  110901. }
  110902. /**
  110903. * Queue used to order the simplification tasks
  110904. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110905. */
  110906. export class SimplificationQueue {
  110907. private _simplificationArray;
  110908. /**
  110909. * Gets a boolean indicating that the process is still running
  110910. */
  110911. running: boolean;
  110912. /**
  110913. * Creates a new queue
  110914. */
  110915. constructor();
  110916. /**
  110917. * Adds a new simplification task
  110918. * @param task defines a task to add
  110919. */
  110920. addTask(task: ISimplificationTask): void;
  110921. /**
  110922. * Execute next task
  110923. */
  110924. executeNext(): void;
  110925. /**
  110926. * Execute a simplification task
  110927. * @param task defines the task to run
  110928. */
  110929. runSimplification(task: ISimplificationTask): void;
  110930. private getSimplifier;
  110931. }
  110932. /**
  110933. * The implemented types of simplification
  110934. * At the moment only Quadratic Error Decimation is implemented
  110935. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110936. */
  110937. export enum SimplificationType {
  110938. /** Quadratic error decimation */
  110939. QUADRATIC = 0
  110940. }
  110941. }
  110942. declare module BABYLON {
  110943. interface Scene {
  110944. /** @hidden (Backing field) */
  110945. _simplificationQueue: SimplificationQueue;
  110946. /**
  110947. * Gets or sets the simplification queue attached to the scene
  110948. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110949. */
  110950. simplificationQueue: SimplificationQueue;
  110951. }
  110952. interface Mesh {
  110953. /**
  110954. * Simplify the mesh according to the given array of settings.
  110955. * Function will return immediately and will simplify async
  110956. * @param settings a collection of simplification settings
  110957. * @param parallelProcessing should all levels calculate parallel or one after the other
  110958. * @param simplificationType the type of simplification to run
  110959. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110960. * @returns the current mesh
  110961. */
  110962. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110963. }
  110964. /**
  110965. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110966. * created in a scene
  110967. */
  110968. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110969. /**
  110970. * The component name helpfull to identify the component in the list of scene components.
  110971. */
  110972. readonly name: string;
  110973. /**
  110974. * The scene the component belongs to.
  110975. */
  110976. scene: Scene;
  110977. /**
  110978. * Creates a new instance of the component for the given scene
  110979. * @param scene Defines the scene to register the component in
  110980. */
  110981. constructor(scene: Scene);
  110982. /**
  110983. * Registers the component in a given scene
  110984. */
  110985. register(): void;
  110986. /**
  110987. * Rebuilds the elements related to this component in case of
  110988. * context lost for instance.
  110989. */
  110990. rebuild(): void;
  110991. /**
  110992. * Disposes the component and the associated ressources
  110993. */
  110994. dispose(): void;
  110995. private _beforeCameraUpdate;
  110996. }
  110997. }
  110998. declare module BABYLON {
  110999. /**
  111000. * Class used to enable access to IndexedDB
  111001. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111002. */
  111003. export class Database implements IOfflineProvider {
  111004. private _callbackManifestChecked;
  111005. private _currentSceneUrl;
  111006. private _db;
  111007. private _enableSceneOffline;
  111008. private _enableTexturesOffline;
  111009. private _manifestVersionFound;
  111010. private _mustUpdateRessources;
  111011. private _hasReachedQuota;
  111012. private _isSupported;
  111013. private _idbFactory;
  111014. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111015. private static IsUASupportingBlobStorage;
  111016. /**
  111017. * Gets a boolean indicating if Database storate is enabled (off by default)
  111018. */
  111019. static IDBStorageEnabled: boolean;
  111020. /**
  111021. * Gets a boolean indicating if scene must be saved in the database
  111022. */
  111023. readonly enableSceneOffline: boolean;
  111024. /**
  111025. * Gets a boolean indicating if textures must be saved in the database
  111026. */
  111027. readonly enableTexturesOffline: boolean;
  111028. /**
  111029. * Creates a new Database
  111030. * @param urlToScene defines the url to load the scene
  111031. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111032. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111033. */
  111034. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111035. private static _ParseURL;
  111036. private static _ReturnFullUrlLocation;
  111037. private _checkManifestFile;
  111038. /**
  111039. * Open the database and make it available
  111040. * @param successCallback defines the callback to call on success
  111041. * @param errorCallback defines the callback to call on error
  111042. */
  111043. open(successCallback: () => void, errorCallback: () => void): void;
  111044. /**
  111045. * Loads an image from the database
  111046. * @param url defines the url to load from
  111047. * @param image defines the target DOM image
  111048. */
  111049. loadImage(url: string, image: HTMLImageElement): void;
  111050. private _loadImageFromDBAsync;
  111051. private _saveImageIntoDBAsync;
  111052. private _checkVersionFromDB;
  111053. private _loadVersionFromDBAsync;
  111054. private _saveVersionIntoDBAsync;
  111055. /**
  111056. * Loads a file from database
  111057. * @param url defines the URL to load from
  111058. * @param sceneLoaded defines a callback to call on success
  111059. * @param progressCallBack defines a callback to call when progress changed
  111060. * @param errorCallback defines a callback to call on error
  111061. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111062. */
  111063. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111064. private _loadFileAsync;
  111065. private _saveFileAsync;
  111066. /**
  111067. * Validates if xhr data is correct
  111068. * @param xhr defines the request to validate
  111069. * @param dataType defines the expected data type
  111070. * @returns true if data is correct
  111071. */
  111072. private static _ValidateXHRData;
  111073. }
  111074. }
  111075. declare module BABYLON {
  111076. /** @hidden */
  111077. export var gpuUpdateParticlesPixelShader: {
  111078. name: string;
  111079. shader: string;
  111080. };
  111081. }
  111082. declare module BABYLON {
  111083. /** @hidden */
  111084. export var gpuUpdateParticlesVertexShader: {
  111085. name: string;
  111086. shader: string;
  111087. };
  111088. }
  111089. declare module BABYLON {
  111090. /** @hidden */
  111091. export var clipPlaneFragmentDeclaration2: {
  111092. name: string;
  111093. shader: string;
  111094. };
  111095. }
  111096. declare module BABYLON {
  111097. /** @hidden */
  111098. export var gpuRenderParticlesPixelShader: {
  111099. name: string;
  111100. shader: string;
  111101. };
  111102. }
  111103. declare module BABYLON {
  111104. /** @hidden */
  111105. export var clipPlaneVertexDeclaration2: {
  111106. name: string;
  111107. shader: string;
  111108. };
  111109. }
  111110. declare module BABYLON {
  111111. /** @hidden */
  111112. export var gpuRenderParticlesVertexShader: {
  111113. name: string;
  111114. shader: string;
  111115. };
  111116. }
  111117. declare module BABYLON {
  111118. /**
  111119. * This represents a GPU particle system in Babylon
  111120. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111121. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111122. */
  111123. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111124. /**
  111125. * The layer mask we are rendering the particles through.
  111126. */
  111127. layerMask: number;
  111128. private _capacity;
  111129. private _activeCount;
  111130. private _currentActiveCount;
  111131. private _accumulatedCount;
  111132. private _renderEffect;
  111133. private _updateEffect;
  111134. private _buffer0;
  111135. private _buffer1;
  111136. private _spriteBuffer;
  111137. private _updateVAO;
  111138. private _renderVAO;
  111139. private _targetIndex;
  111140. private _sourceBuffer;
  111141. private _targetBuffer;
  111142. private _engine;
  111143. private _currentRenderId;
  111144. private _started;
  111145. private _stopped;
  111146. private _timeDelta;
  111147. private _randomTexture;
  111148. private _randomTexture2;
  111149. private _attributesStrideSize;
  111150. private _updateEffectOptions;
  111151. private _randomTextureSize;
  111152. private _actualFrame;
  111153. private readonly _rawTextureWidth;
  111154. /**
  111155. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111156. */
  111157. static readonly IsSupported: boolean;
  111158. /**
  111159. * An event triggered when the system is disposed.
  111160. */
  111161. onDisposeObservable: Observable<GPUParticleSystem>;
  111162. /**
  111163. * Gets the maximum number of particles active at the same time.
  111164. * @returns The max number of active particles.
  111165. */
  111166. getCapacity(): number;
  111167. /**
  111168. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111169. * to override the particles.
  111170. */
  111171. forceDepthWrite: boolean;
  111172. /**
  111173. * Gets or set the number of active particles
  111174. */
  111175. activeParticleCount: number;
  111176. private _preWarmDone;
  111177. /**
  111178. * Is this system ready to be used/rendered
  111179. * @return true if the system is ready
  111180. */
  111181. isReady(): boolean;
  111182. /**
  111183. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111184. * @returns True if it has been started, otherwise false.
  111185. */
  111186. isStarted(): boolean;
  111187. /**
  111188. * Starts the particle system and begins to emit
  111189. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111190. */
  111191. start(delay?: number): void;
  111192. /**
  111193. * Stops the particle system.
  111194. */
  111195. stop(): void;
  111196. /**
  111197. * Remove all active particles
  111198. */
  111199. reset(): void;
  111200. /**
  111201. * Returns the string "GPUParticleSystem"
  111202. * @returns a string containing the class name
  111203. */
  111204. getClassName(): string;
  111205. private _colorGradientsTexture;
  111206. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111207. /**
  111208. * Adds a new color gradient
  111209. * @param gradient defines the gradient to use (between 0 and 1)
  111210. * @param color1 defines the color to affect to the specified gradient
  111211. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111212. * @returns the current particle system
  111213. */
  111214. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111215. /**
  111216. * Remove a specific color gradient
  111217. * @param gradient defines the gradient to remove
  111218. * @returns the current particle system
  111219. */
  111220. removeColorGradient(gradient: number): GPUParticleSystem;
  111221. private _angularSpeedGradientsTexture;
  111222. private _sizeGradientsTexture;
  111223. private _velocityGradientsTexture;
  111224. private _limitVelocityGradientsTexture;
  111225. private _dragGradientsTexture;
  111226. private _addFactorGradient;
  111227. /**
  111228. * Adds a new size gradient
  111229. * @param gradient defines the gradient to use (between 0 and 1)
  111230. * @param factor defines the size factor to affect to the specified gradient
  111231. * @returns the current particle system
  111232. */
  111233. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111234. /**
  111235. * Remove a specific size gradient
  111236. * @param gradient defines the gradient to remove
  111237. * @returns the current particle system
  111238. */
  111239. removeSizeGradient(gradient: number): GPUParticleSystem;
  111240. /**
  111241. * Adds a new angular speed gradient
  111242. * @param gradient defines the gradient to use (between 0 and 1)
  111243. * @param factor defines the angular speed to affect to the specified gradient
  111244. * @returns the current particle system
  111245. */
  111246. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111247. /**
  111248. * Remove a specific angular speed gradient
  111249. * @param gradient defines the gradient to remove
  111250. * @returns the current particle system
  111251. */
  111252. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111253. /**
  111254. * Adds a new velocity gradient
  111255. * @param gradient defines the gradient to use (between 0 and 1)
  111256. * @param factor defines the velocity to affect to the specified gradient
  111257. * @returns the current particle system
  111258. */
  111259. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111260. /**
  111261. * Remove a specific velocity gradient
  111262. * @param gradient defines the gradient to remove
  111263. * @returns the current particle system
  111264. */
  111265. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111266. /**
  111267. * Adds a new limit velocity gradient
  111268. * @param gradient defines the gradient to use (between 0 and 1)
  111269. * @param factor defines the limit velocity value to affect to the specified gradient
  111270. * @returns the current particle system
  111271. */
  111272. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111273. /**
  111274. * Remove a specific limit velocity gradient
  111275. * @param gradient defines the gradient to remove
  111276. * @returns the current particle system
  111277. */
  111278. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111279. /**
  111280. * Adds a new drag gradient
  111281. * @param gradient defines the gradient to use (between 0 and 1)
  111282. * @param factor defines the drag value to affect to the specified gradient
  111283. * @returns the current particle system
  111284. */
  111285. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111286. /**
  111287. * Remove a specific drag gradient
  111288. * @param gradient defines the gradient to remove
  111289. * @returns the current particle system
  111290. */
  111291. removeDragGradient(gradient: number): GPUParticleSystem;
  111292. /**
  111293. * Not supported by GPUParticleSystem
  111294. * @param gradient defines the gradient to use (between 0 and 1)
  111295. * @param factor defines the emit rate value to affect to the specified gradient
  111296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111297. * @returns the current particle system
  111298. */
  111299. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111300. /**
  111301. * Not supported by GPUParticleSystem
  111302. * @param gradient defines the gradient to remove
  111303. * @returns the current particle system
  111304. */
  111305. removeEmitRateGradient(gradient: number): IParticleSystem;
  111306. /**
  111307. * Not supported by GPUParticleSystem
  111308. * @param gradient defines the gradient to use (between 0 and 1)
  111309. * @param factor defines the start size value to affect to the specified gradient
  111310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111311. * @returns the current particle system
  111312. */
  111313. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111314. /**
  111315. * Not supported by GPUParticleSystem
  111316. * @param gradient defines the gradient to remove
  111317. * @returns the current particle system
  111318. */
  111319. removeStartSizeGradient(gradient: number): IParticleSystem;
  111320. /**
  111321. * Not supported by GPUParticleSystem
  111322. * @param gradient defines the gradient to use (between 0 and 1)
  111323. * @param min defines the color remap minimal range
  111324. * @param max defines the color remap maximal range
  111325. * @returns the current particle system
  111326. */
  111327. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111328. /**
  111329. * Not supported by GPUParticleSystem
  111330. * @param gradient defines the gradient to remove
  111331. * @returns the current particle system
  111332. */
  111333. removeColorRemapGradient(): IParticleSystem;
  111334. /**
  111335. * Not supported by GPUParticleSystem
  111336. * @param gradient defines the gradient to use (between 0 and 1)
  111337. * @param min defines the alpha remap minimal range
  111338. * @param max defines the alpha remap maximal range
  111339. * @returns the current particle system
  111340. */
  111341. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111342. /**
  111343. * Not supported by GPUParticleSystem
  111344. * @param gradient defines the gradient to remove
  111345. * @returns the current particle system
  111346. */
  111347. removeAlphaRemapGradient(): IParticleSystem;
  111348. /**
  111349. * Not supported by GPUParticleSystem
  111350. * @param gradient defines the gradient to use (between 0 and 1)
  111351. * @param color defines the color to affect to the specified gradient
  111352. * @returns the current particle system
  111353. */
  111354. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111355. /**
  111356. * Not supported by GPUParticleSystem
  111357. * @param gradient defines the gradient to remove
  111358. * @returns the current particle system
  111359. */
  111360. removeRampGradient(): IParticleSystem;
  111361. /**
  111362. * Not supported by GPUParticleSystem
  111363. * @returns the list of ramp gradients
  111364. */
  111365. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111366. /**
  111367. * Not supported by GPUParticleSystem
  111368. * Gets or sets a boolean indicating that ramp gradients must be used
  111369. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111370. */
  111371. useRampGradients: boolean;
  111372. /**
  111373. * Not supported by GPUParticleSystem
  111374. * @param gradient defines the gradient to use (between 0 and 1)
  111375. * @param factor defines the life time factor to affect to the specified gradient
  111376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111377. * @returns the current particle system
  111378. */
  111379. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111380. /**
  111381. * Not supported by GPUParticleSystem
  111382. * @param gradient defines the gradient to remove
  111383. * @returns the current particle system
  111384. */
  111385. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111386. /**
  111387. * Instantiates a GPU particle system.
  111388. * 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.
  111389. * @param name The name of the particle system
  111390. * @param options The options used to create the system
  111391. * @param scene The scene the particle system belongs to
  111392. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111393. */
  111394. constructor(name: string, options: Partial<{
  111395. capacity: number;
  111396. randomTextureSize: number;
  111397. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111398. protected _reset(): void;
  111399. private _createUpdateVAO;
  111400. private _createRenderVAO;
  111401. private _initialize;
  111402. /** @hidden */
  111403. _recreateUpdateEffect(): void;
  111404. /** @hidden */
  111405. _recreateRenderEffect(): void;
  111406. /**
  111407. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111408. * @param preWarm defines if we are in the pre-warmimg phase
  111409. */
  111410. animate(preWarm?: boolean): void;
  111411. private _createFactorGradientTexture;
  111412. private _createSizeGradientTexture;
  111413. private _createAngularSpeedGradientTexture;
  111414. private _createVelocityGradientTexture;
  111415. private _createLimitVelocityGradientTexture;
  111416. private _createDragGradientTexture;
  111417. private _createColorGradientTexture;
  111418. /**
  111419. * Renders the particle system in its current state
  111420. * @param preWarm defines if the system should only update the particles but not render them
  111421. * @returns the current number of particles
  111422. */
  111423. render(preWarm?: boolean): number;
  111424. /**
  111425. * Rebuilds the particle system
  111426. */
  111427. rebuild(): void;
  111428. private _releaseBuffers;
  111429. private _releaseVAOs;
  111430. /**
  111431. * Disposes the particle system and free the associated resources
  111432. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111433. */
  111434. dispose(disposeTexture?: boolean): void;
  111435. /**
  111436. * Clones the particle system.
  111437. * @param name The name of the cloned object
  111438. * @param newEmitter The new emitter to use
  111439. * @returns the cloned particle system
  111440. */
  111441. clone(name: string, newEmitter: any): GPUParticleSystem;
  111442. /**
  111443. * Serializes the particle system to a JSON object.
  111444. * @returns the JSON object
  111445. */
  111446. serialize(): any;
  111447. /**
  111448. * Parses a JSON object to create a GPU particle system.
  111449. * @param parsedParticleSystem The JSON object to parse
  111450. * @param scene The scene to create the particle system in
  111451. * @param rootUrl The root url to use to load external dependencies like texture
  111452. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111453. * @returns the parsed GPU particle system
  111454. */
  111455. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111456. }
  111457. }
  111458. declare module BABYLON {
  111459. /**
  111460. * Represents a set of particle systems working together to create a specific effect
  111461. */
  111462. export class ParticleSystemSet implements IDisposable {
  111463. private _emitterCreationOptions;
  111464. private _emitterNode;
  111465. /**
  111466. * Gets the particle system list
  111467. */
  111468. systems: IParticleSystem[];
  111469. /**
  111470. * Gets the emitter node used with this set
  111471. */
  111472. readonly emitterNode: Nullable<TransformNode>;
  111473. /**
  111474. * Creates a new emitter mesh as a sphere
  111475. * @param options defines the options used to create the sphere
  111476. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111477. * @param scene defines the hosting scene
  111478. */
  111479. setEmitterAsSphere(options: {
  111480. diameter: number;
  111481. segments: number;
  111482. color: Color3;
  111483. }, renderingGroupId: number, scene: Scene): void;
  111484. /**
  111485. * Starts all particle systems of the set
  111486. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111487. */
  111488. start(emitter?: AbstractMesh): void;
  111489. /**
  111490. * Release all associated resources
  111491. */
  111492. dispose(): void;
  111493. /**
  111494. * Serialize the set into a JSON compatible object
  111495. * @returns a JSON compatible representation of the set
  111496. */
  111497. serialize(): any;
  111498. /**
  111499. * Parse a new ParticleSystemSet from a serialized source
  111500. * @param data defines a JSON compatible representation of the set
  111501. * @param scene defines the hosting scene
  111502. * @param gpu defines if we want GPU particles or CPU particles
  111503. * @returns a new ParticleSystemSet
  111504. */
  111505. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111506. }
  111507. }
  111508. declare module BABYLON {
  111509. /**
  111510. * This class is made for on one-liner static method to help creating particle system set.
  111511. */
  111512. export class ParticleHelper {
  111513. /**
  111514. * Gets or sets base Assets URL
  111515. */
  111516. static BaseAssetsUrl: string;
  111517. /**
  111518. * Create a default particle system that you can tweak
  111519. * @param emitter defines the emitter to use
  111520. * @param capacity defines the system capacity (default is 500 particles)
  111521. * @param scene defines the hosting scene
  111522. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111523. * @returns the new Particle system
  111524. */
  111525. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111526. /**
  111527. * This is the main static method (one-liner) of this helper to create different particle systems
  111528. * @param type This string represents the type to the particle system to create
  111529. * @param scene The scene where the particle system should live
  111530. * @param gpu If the system will use gpu
  111531. * @returns the ParticleSystemSet created
  111532. */
  111533. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111534. /**
  111535. * Static function used to export a particle system to a ParticleSystemSet variable.
  111536. * Please note that the emitter shape is not exported
  111537. * @param systems defines the particle systems to export
  111538. * @returns the created particle system set
  111539. */
  111540. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111541. }
  111542. }
  111543. declare module BABYLON {
  111544. interface Engine {
  111545. /**
  111546. * Create an effect to use with particle systems.
  111547. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111548. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111549. * @param uniformsNames defines a list of attribute names
  111550. * @param samplers defines an array of string used to represent textures
  111551. * @param defines defines the string containing the defines to use to compile the shaders
  111552. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111553. * @param onCompiled defines a function to call when the effect creation is successful
  111554. * @param onError defines a function to call when the effect creation has failed
  111555. * @returns the new Effect
  111556. */
  111557. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111558. }
  111559. interface Mesh {
  111560. /**
  111561. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111562. * @returns an array of IParticleSystem
  111563. */
  111564. getEmittedParticleSystems(): IParticleSystem[];
  111565. /**
  111566. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111567. * @returns an array of IParticleSystem
  111568. */
  111569. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111570. }
  111571. /**
  111572. * @hidden
  111573. */
  111574. export var _IDoNeedToBeInTheBuild: number;
  111575. }
  111576. declare module BABYLON {
  111577. interface Scene {
  111578. /** @hidden (Backing field) */
  111579. _physicsEngine: Nullable<IPhysicsEngine>;
  111580. /**
  111581. * Gets the current physics engine
  111582. * @returns a IPhysicsEngine or null if none attached
  111583. */
  111584. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111585. /**
  111586. * Enables physics to the current scene
  111587. * @param gravity defines the scene's gravity for the physics engine
  111588. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111589. * @return a boolean indicating if the physics engine was initialized
  111590. */
  111591. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111592. /**
  111593. * Disables and disposes the physics engine associated with the scene
  111594. */
  111595. disablePhysicsEngine(): void;
  111596. /**
  111597. * Gets a boolean indicating if there is an active physics engine
  111598. * @returns a boolean indicating if there is an active physics engine
  111599. */
  111600. isPhysicsEnabled(): boolean;
  111601. /**
  111602. * Deletes a physics compound impostor
  111603. * @param compound defines the compound to delete
  111604. */
  111605. deleteCompoundImpostor(compound: any): void;
  111606. /**
  111607. * An event triggered when physic simulation is about to be run
  111608. */
  111609. onBeforePhysicsObservable: Observable<Scene>;
  111610. /**
  111611. * An event triggered when physic simulation has been done
  111612. */
  111613. onAfterPhysicsObservable: Observable<Scene>;
  111614. }
  111615. interface AbstractMesh {
  111616. /** @hidden */
  111617. _physicsImpostor: Nullable<PhysicsImpostor>;
  111618. /**
  111619. * Gets or sets impostor used for physic simulation
  111620. * @see http://doc.babylonjs.com/features/physics_engine
  111621. */
  111622. physicsImpostor: Nullable<PhysicsImpostor>;
  111623. /**
  111624. * Gets the current physics impostor
  111625. * @see http://doc.babylonjs.com/features/physics_engine
  111626. * @returns a physics impostor or null
  111627. */
  111628. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111629. /** Apply a physic impulse to the mesh
  111630. * @param force defines the force to apply
  111631. * @param contactPoint defines where to apply the force
  111632. * @returns the current mesh
  111633. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111634. */
  111635. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111636. /**
  111637. * Creates a physic joint between two meshes
  111638. * @param otherMesh defines the other mesh to use
  111639. * @param pivot1 defines the pivot to use on this mesh
  111640. * @param pivot2 defines the pivot to use on the other mesh
  111641. * @param options defines additional options (can be plugin dependent)
  111642. * @returns the current mesh
  111643. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111644. */
  111645. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111646. /** @hidden */
  111647. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111648. }
  111649. /**
  111650. * Defines the physics engine scene component responsible to manage a physics engine
  111651. */
  111652. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111653. /**
  111654. * The component name helpful to identify the component in the list of scene components.
  111655. */
  111656. readonly name: string;
  111657. /**
  111658. * The scene the component belongs to.
  111659. */
  111660. scene: Scene;
  111661. /**
  111662. * Creates a new instance of the component for the given scene
  111663. * @param scene Defines the scene to register the component in
  111664. */
  111665. constructor(scene: Scene);
  111666. /**
  111667. * Registers the component in a given scene
  111668. */
  111669. register(): void;
  111670. /**
  111671. * Rebuilds the elements related to this component in case of
  111672. * context lost for instance.
  111673. */
  111674. rebuild(): void;
  111675. /**
  111676. * Disposes the component and the associated ressources
  111677. */
  111678. dispose(): void;
  111679. }
  111680. }
  111681. declare module BABYLON {
  111682. /**
  111683. * A helper for physics simulations
  111684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111685. */
  111686. export class PhysicsHelper {
  111687. private _scene;
  111688. private _physicsEngine;
  111689. /**
  111690. * Initializes the Physics helper
  111691. * @param scene Babylon.js scene
  111692. */
  111693. constructor(scene: Scene);
  111694. /**
  111695. * Applies a radial explosion impulse
  111696. * @param origin the origin of the explosion
  111697. * @param radiusOrEventOptions the radius or the options of radial explosion
  111698. * @param strength the explosion strength
  111699. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111700. * @returns A physics radial explosion event, or null
  111701. */
  111702. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111703. /**
  111704. * Applies a radial explosion force
  111705. * @param origin the origin of the explosion
  111706. * @param radiusOrEventOptions the radius or the options of radial explosion
  111707. * @param strength the explosion strength
  111708. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111709. * @returns A physics radial explosion event, or null
  111710. */
  111711. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111712. /**
  111713. * Creates a gravitational field
  111714. * @param origin the origin of the explosion
  111715. * @param radiusOrEventOptions the radius or the options of radial explosion
  111716. * @param strength the explosion strength
  111717. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111718. * @returns A physics gravitational field event, or null
  111719. */
  111720. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111721. /**
  111722. * Creates a physics updraft event
  111723. * @param origin the origin of the updraft
  111724. * @param radiusOrEventOptions the radius or the options of the updraft
  111725. * @param strength the strength of the updraft
  111726. * @param height the height of the updraft
  111727. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111728. * @returns A physics updraft event, or null
  111729. */
  111730. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111731. /**
  111732. * Creates a physics vortex event
  111733. * @param origin the of the vortex
  111734. * @param radiusOrEventOptions the radius or the options of the vortex
  111735. * @param strength the strength of the vortex
  111736. * @param height the height of the vortex
  111737. * @returns a Physics vortex event, or null
  111738. * A physics vortex event or null
  111739. */
  111740. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111741. }
  111742. /**
  111743. * Represents a physics radial explosion event
  111744. */
  111745. class PhysicsRadialExplosionEvent {
  111746. private _scene;
  111747. private _options;
  111748. private _sphere;
  111749. private _dataFetched;
  111750. /**
  111751. * Initializes a radial explosioin event
  111752. * @param _scene BabylonJS scene
  111753. * @param _options The options for the vortex event
  111754. */
  111755. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111756. /**
  111757. * Returns the data related to the radial explosion event (sphere).
  111758. * @returns The radial explosion event data
  111759. */
  111760. getData(): PhysicsRadialExplosionEventData;
  111761. /**
  111762. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111763. * @param impostor A physics imposter
  111764. * @param origin the origin of the explosion
  111765. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111766. */
  111767. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111768. /**
  111769. * Triggers affecterd impostors callbacks
  111770. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111771. */
  111772. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111773. /**
  111774. * Disposes the sphere.
  111775. * @param force Specifies if the sphere should be disposed by force
  111776. */
  111777. dispose(force?: boolean): void;
  111778. /*** Helpers ***/
  111779. private _prepareSphere;
  111780. private _intersectsWithSphere;
  111781. }
  111782. /**
  111783. * Represents a gravitational field event
  111784. */
  111785. class PhysicsGravitationalFieldEvent {
  111786. private _physicsHelper;
  111787. private _scene;
  111788. private _origin;
  111789. private _options;
  111790. private _tickCallback;
  111791. private _sphere;
  111792. private _dataFetched;
  111793. /**
  111794. * Initializes the physics gravitational field event
  111795. * @param _physicsHelper A physics helper
  111796. * @param _scene BabylonJS scene
  111797. * @param _origin The origin position of the gravitational field event
  111798. * @param _options The options for the vortex event
  111799. */
  111800. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111801. /**
  111802. * Returns the data related to the gravitational field event (sphere).
  111803. * @returns A gravitational field event
  111804. */
  111805. getData(): PhysicsGravitationalFieldEventData;
  111806. /**
  111807. * Enables the gravitational field.
  111808. */
  111809. enable(): void;
  111810. /**
  111811. * Disables the gravitational field.
  111812. */
  111813. disable(): void;
  111814. /**
  111815. * Disposes the sphere.
  111816. * @param force The force to dispose from the gravitational field event
  111817. */
  111818. dispose(force?: boolean): void;
  111819. private _tick;
  111820. }
  111821. /**
  111822. * Represents a physics updraft event
  111823. */
  111824. class PhysicsUpdraftEvent {
  111825. private _scene;
  111826. private _origin;
  111827. private _options;
  111828. private _physicsEngine;
  111829. private _originTop;
  111830. private _originDirection;
  111831. private _tickCallback;
  111832. private _cylinder;
  111833. private _cylinderPosition;
  111834. private _dataFetched;
  111835. /**
  111836. * Initializes the physics updraft event
  111837. * @param _scene BabylonJS scene
  111838. * @param _origin The origin position of the updraft
  111839. * @param _options The options for the updraft event
  111840. */
  111841. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111842. /**
  111843. * Returns the data related to the updraft event (cylinder).
  111844. * @returns A physics updraft event
  111845. */
  111846. getData(): PhysicsUpdraftEventData;
  111847. /**
  111848. * Enables the updraft.
  111849. */
  111850. enable(): void;
  111851. /**
  111852. * Disables the updraft.
  111853. */
  111854. disable(): void;
  111855. /**
  111856. * Disposes the cylinder.
  111857. * @param force Specifies if the updraft should be disposed by force
  111858. */
  111859. dispose(force?: boolean): void;
  111860. private getImpostorHitData;
  111861. private _tick;
  111862. /*** Helpers ***/
  111863. private _prepareCylinder;
  111864. private _intersectsWithCylinder;
  111865. }
  111866. /**
  111867. * Represents a physics vortex event
  111868. */
  111869. class PhysicsVortexEvent {
  111870. private _scene;
  111871. private _origin;
  111872. private _options;
  111873. private _physicsEngine;
  111874. private _originTop;
  111875. private _tickCallback;
  111876. private _cylinder;
  111877. private _cylinderPosition;
  111878. private _dataFetched;
  111879. /**
  111880. * Initializes the physics vortex event
  111881. * @param _scene The BabylonJS scene
  111882. * @param _origin The origin position of the vortex
  111883. * @param _options The options for the vortex event
  111884. */
  111885. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111886. /**
  111887. * Returns the data related to the vortex event (cylinder).
  111888. * @returns The physics vortex event data
  111889. */
  111890. getData(): PhysicsVortexEventData;
  111891. /**
  111892. * Enables the vortex.
  111893. */
  111894. enable(): void;
  111895. /**
  111896. * Disables the cortex.
  111897. */
  111898. disable(): void;
  111899. /**
  111900. * Disposes the sphere.
  111901. * @param force
  111902. */
  111903. dispose(force?: boolean): void;
  111904. private getImpostorHitData;
  111905. private _tick;
  111906. /*** Helpers ***/
  111907. private _prepareCylinder;
  111908. private _intersectsWithCylinder;
  111909. }
  111910. /**
  111911. * Options fot the radial explosion event
  111912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111913. */
  111914. export class PhysicsRadialExplosionEventOptions {
  111915. /**
  111916. * The radius of the sphere for the radial explosion.
  111917. */
  111918. radius: number;
  111919. /**
  111920. * The strenth of the explosion.
  111921. */
  111922. strength: number;
  111923. /**
  111924. * The strenght of the force in correspondence to the distance of the affected object
  111925. */
  111926. falloff: PhysicsRadialImpulseFalloff;
  111927. /**
  111928. * Sphere options for the radial explosion.
  111929. */
  111930. sphere: {
  111931. segments: number;
  111932. diameter: number;
  111933. };
  111934. /**
  111935. * Sphere options for the radial explosion.
  111936. */
  111937. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  111938. }
  111939. /**
  111940. * Options fot the updraft event
  111941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111942. */
  111943. export class PhysicsUpdraftEventOptions {
  111944. /**
  111945. * The radius of the cylinder for the vortex
  111946. */
  111947. radius: number;
  111948. /**
  111949. * The strenth of the updraft.
  111950. */
  111951. strength: number;
  111952. /**
  111953. * The height of the cylinder for the updraft.
  111954. */
  111955. height: number;
  111956. /**
  111957. * The mode for the the updraft.
  111958. */
  111959. updraftMode: PhysicsUpdraftMode;
  111960. }
  111961. /**
  111962. * Options fot the vortex event
  111963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111964. */
  111965. export class PhysicsVortexEventOptions {
  111966. /**
  111967. * The radius of the cylinder for the vortex
  111968. */
  111969. radius: number;
  111970. /**
  111971. * The strenth of the vortex.
  111972. */
  111973. strength: number;
  111974. /**
  111975. * The height of the cylinder for the vortex.
  111976. */
  111977. height: number;
  111978. /**
  111979. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111980. */
  111981. centripetalForceThreshold: number;
  111982. /**
  111983. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111984. */
  111985. centripetalForceMultiplier: number;
  111986. /**
  111987. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111988. */
  111989. centrifugalForceMultiplier: number;
  111990. /**
  111991. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111992. */
  111993. updraftForceMultiplier: number;
  111994. }
  111995. /**
  111996. * The strenght of the force in correspondence to the distance of the affected object
  111997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111998. */
  111999. export enum PhysicsRadialImpulseFalloff {
  112000. /** Defines that impulse is constant in strength across it's whole radius */
  112001. Constant = 0,
  112002. /** Defines that impulse gets weaker if it's further from the origin */
  112003. Linear = 1
  112004. }
  112005. /**
  112006. * The strength of the force in correspondence to the distance of the affected object
  112007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112008. */
  112009. export enum PhysicsUpdraftMode {
  112010. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112011. Center = 0,
  112012. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112013. Perpendicular = 1
  112014. }
  112015. /**
  112016. * Interface for a physics hit data
  112017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112018. */
  112019. export interface PhysicsHitData {
  112020. /**
  112021. * The force applied at the contact point
  112022. */
  112023. force: Vector3;
  112024. /**
  112025. * The contact point
  112026. */
  112027. contactPoint: Vector3;
  112028. /**
  112029. * The distance from the origin to the contact point
  112030. */
  112031. distanceFromOrigin: number;
  112032. }
  112033. /**
  112034. * Interface for radial explosion event data
  112035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112036. */
  112037. export interface PhysicsRadialExplosionEventData {
  112038. /**
  112039. * A sphere used for the radial explosion event
  112040. */
  112041. sphere: Mesh;
  112042. }
  112043. /**
  112044. * Interface for gravitational field event data
  112045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112046. */
  112047. export interface PhysicsGravitationalFieldEventData {
  112048. /**
  112049. * A sphere mesh used for the gravitational field event
  112050. */
  112051. sphere: Mesh;
  112052. }
  112053. /**
  112054. * Interface for updraft event data
  112055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112056. */
  112057. export interface PhysicsUpdraftEventData {
  112058. /**
  112059. * A cylinder used for the updraft event
  112060. */
  112061. cylinder: Mesh;
  112062. }
  112063. /**
  112064. * Interface for vortex event data
  112065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112066. */
  112067. export interface PhysicsVortexEventData {
  112068. /**
  112069. * A cylinder used for the vortex event
  112070. */
  112071. cylinder: Mesh;
  112072. }
  112073. /**
  112074. * Interface for an affected physics impostor
  112075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112076. */
  112077. export interface PhysicsAffectedImpostorWithData {
  112078. /**
  112079. * The impostor affected by the effect
  112080. */
  112081. impostor: PhysicsImpostor;
  112082. /**
  112083. * The data about the hit/horce from the explosion
  112084. */
  112085. hitData: PhysicsHitData;
  112086. }
  112087. }
  112088. declare module BABYLON {
  112089. /** @hidden */
  112090. export var blackAndWhitePixelShader: {
  112091. name: string;
  112092. shader: string;
  112093. };
  112094. }
  112095. declare module BABYLON {
  112096. /**
  112097. * Post process used to render in black and white
  112098. */
  112099. export class BlackAndWhitePostProcess extends PostProcess {
  112100. /**
  112101. * Linear about to convert he result to black and white (default: 1)
  112102. */
  112103. degree: number;
  112104. /**
  112105. * Creates a black and white post process
  112106. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112107. * @param name The name of the effect.
  112108. * @param options The required width/height ratio to downsize to before computing the render pass.
  112109. * @param camera The camera to apply the render pass to.
  112110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112111. * @param engine The engine which the post process will be applied. (default: current engine)
  112112. * @param reusable If the post process can be reused on the same frame. (default: false)
  112113. */
  112114. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112115. }
  112116. }
  112117. declare module BABYLON {
  112118. /**
  112119. * This represents a set of one or more post processes in Babylon.
  112120. * A post process can be used to apply a shader to a texture after it is rendered.
  112121. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112122. */
  112123. export class PostProcessRenderEffect {
  112124. private _postProcesses;
  112125. private _getPostProcesses;
  112126. private _singleInstance;
  112127. private _cameras;
  112128. private _indicesForCamera;
  112129. /**
  112130. * Name of the effect
  112131. * @hidden
  112132. */
  112133. _name: string;
  112134. /**
  112135. * Instantiates a post process render effect.
  112136. * A post process can be used to apply a shader to a texture after it is rendered.
  112137. * @param engine The engine the effect is tied to
  112138. * @param name The name of the effect
  112139. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112140. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112141. */
  112142. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112143. /**
  112144. * Checks if all the post processes in the effect are supported.
  112145. */
  112146. readonly isSupported: boolean;
  112147. /**
  112148. * Updates the current state of the effect
  112149. * @hidden
  112150. */
  112151. _update(): void;
  112152. /**
  112153. * Attaches the effect on cameras
  112154. * @param cameras The camera to attach to.
  112155. * @hidden
  112156. */
  112157. _attachCameras(cameras: Camera): void;
  112158. /**
  112159. * Attaches the effect on cameras
  112160. * @param cameras The camera to attach to.
  112161. * @hidden
  112162. */
  112163. _attachCameras(cameras: Camera[]): void;
  112164. /**
  112165. * Detaches the effect on cameras
  112166. * @param cameras The camera to detatch from.
  112167. * @hidden
  112168. */
  112169. _detachCameras(cameras: Camera): void;
  112170. /**
  112171. * Detatches the effect on cameras
  112172. * @param cameras The camera to detatch from.
  112173. * @hidden
  112174. */
  112175. _detachCameras(cameras: Camera[]): void;
  112176. /**
  112177. * Enables the effect on given cameras
  112178. * @param cameras The camera to enable.
  112179. * @hidden
  112180. */
  112181. _enable(cameras: Camera): void;
  112182. /**
  112183. * Enables the effect on given cameras
  112184. * @param cameras The camera to enable.
  112185. * @hidden
  112186. */
  112187. _enable(cameras: Nullable<Camera[]>): void;
  112188. /**
  112189. * Disables the effect on the given cameras
  112190. * @param cameras The camera to disable.
  112191. * @hidden
  112192. */
  112193. _disable(cameras: Camera): void;
  112194. /**
  112195. * Disables the effect on the given cameras
  112196. * @param cameras The camera to disable.
  112197. * @hidden
  112198. */
  112199. _disable(cameras: Nullable<Camera[]>): void;
  112200. /**
  112201. * Gets a list of the post processes contained in the effect.
  112202. * @param camera The camera to get the post processes on.
  112203. * @returns The list of the post processes in the effect.
  112204. */
  112205. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112206. }
  112207. }
  112208. declare module BABYLON {
  112209. /** @hidden */
  112210. export var extractHighlightsPixelShader: {
  112211. name: string;
  112212. shader: string;
  112213. };
  112214. }
  112215. declare module BABYLON {
  112216. /**
  112217. * 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.
  112218. */
  112219. export class ExtractHighlightsPostProcess extends PostProcess {
  112220. /**
  112221. * The luminance threshold, pixels below this value will be set to black.
  112222. */
  112223. threshold: number;
  112224. /** @hidden */
  112225. _exposure: number;
  112226. /**
  112227. * Post process which has the input texture to be used when performing highlight extraction
  112228. * @hidden
  112229. */
  112230. _inputPostProcess: Nullable<PostProcess>;
  112231. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112232. }
  112233. }
  112234. declare module BABYLON {
  112235. /** @hidden */
  112236. export var bloomMergePixelShader: {
  112237. name: string;
  112238. shader: string;
  112239. };
  112240. }
  112241. declare module BABYLON {
  112242. /**
  112243. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112244. */
  112245. export class BloomMergePostProcess extends PostProcess {
  112246. /** Weight of the bloom to be added to the original input. */
  112247. weight: number;
  112248. /**
  112249. * Creates a new instance of @see BloomMergePostProcess
  112250. * @param name The name of the effect.
  112251. * @param originalFromInput Post process which's input will be used for the merge.
  112252. * @param blurred Blurred highlights post process which's output will be used.
  112253. * @param weight Weight of the bloom to be added to the original input.
  112254. * @param options The required width/height ratio to downsize to before computing the render pass.
  112255. * @param camera The camera to apply the render pass to.
  112256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112257. * @param engine The engine which the post process will be applied. (default: current engine)
  112258. * @param reusable If the post process can be reused on the same frame. (default: false)
  112259. * @param textureType Type of textures used when performing the post process. (default: 0)
  112260. * @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)
  112261. */
  112262. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112263. /** Weight of the bloom to be added to the original input. */
  112264. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112265. }
  112266. }
  112267. declare module BABYLON {
  112268. /**
  112269. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112270. */
  112271. export class BloomEffect extends PostProcessRenderEffect {
  112272. private bloomScale;
  112273. /**
  112274. * @hidden Internal
  112275. */
  112276. _effects: Array<PostProcess>;
  112277. /**
  112278. * @hidden Internal
  112279. */
  112280. _downscale: ExtractHighlightsPostProcess;
  112281. private _blurX;
  112282. private _blurY;
  112283. private _merge;
  112284. /**
  112285. * The luminance threshold to find bright areas of the image to bloom.
  112286. */
  112287. threshold: number;
  112288. /**
  112289. * The strength of the bloom.
  112290. */
  112291. weight: number;
  112292. /**
  112293. * Specifies the size of the bloom blur kernel, relative to the final output size
  112294. */
  112295. kernel: number;
  112296. /**
  112297. * Creates a new instance of @see BloomEffect
  112298. * @param scene The scene the effect belongs to.
  112299. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112300. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112301. * @param bloomWeight The the strength of bloom.
  112302. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112303. * @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)
  112304. */
  112305. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112306. /**
  112307. * Disposes each of the internal effects for a given camera.
  112308. * @param camera The camera to dispose the effect on.
  112309. */
  112310. disposeEffects(camera: Camera): void;
  112311. /**
  112312. * @hidden Internal
  112313. */
  112314. _updateEffects(): void;
  112315. /**
  112316. * Internal
  112317. * @returns if all the contained post processes are ready.
  112318. * @hidden
  112319. */
  112320. _isReady(): boolean;
  112321. }
  112322. }
  112323. declare module BABYLON {
  112324. /** @hidden */
  112325. export var chromaticAberrationPixelShader: {
  112326. name: string;
  112327. shader: string;
  112328. };
  112329. }
  112330. declare module BABYLON {
  112331. /**
  112332. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112333. */
  112334. export class ChromaticAberrationPostProcess extends PostProcess {
  112335. /**
  112336. * The amount of seperation of rgb channels (default: 30)
  112337. */
  112338. aberrationAmount: number;
  112339. /**
  112340. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112341. */
  112342. radialIntensity: number;
  112343. /**
  112344. * 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))
  112345. */
  112346. direction: Vector2;
  112347. /**
  112348. * 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))
  112349. */
  112350. centerPosition: Vector2;
  112351. /**
  112352. * Creates a new instance ChromaticAberrationPostProcess
  112353. * @param name The name of the effect.
  112354. * @param screenWidth The width of the screen to apply the effect on.
  112355. * @param screenHeight The height of the screen to apply the effect on.
  112356. * @param options The required width/height ratio to downsize to before computing the render pass.
  112357. * @param camera The camera to apply the render pass to.
  112358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112359. * @param engine The engine which the post process will be applied. (default: current engine)
  112360. * @param reusable If the post process can be reused on the same frame. (default: false)
  112361. * @param textureType Type of textures used when performing the post process. (default: 0)
  112362. * @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)
  112363. */
  112364. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112365. }
  112366. }
  112367. declare module BABYLON {
  112368. /** @hidden */
  112369. export var circleOfConfusionPixelShader: {
  112370. name: string;
  112371. shader: string;
  112372. };
  112373. }
  112374. declare module BABYLON {
  112375. /**
  112376. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112377. */
  112378. export class CircleOfConfusionPostProcess extends PostProcess {
  112379. /**
  112380. * 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.
  112381. */
  112382. lensSize: number;
  112383. /**
  112384. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112385. */
  112386. fStop: number;
  112387. /**
  112388. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112389. */
  112390. focusDistance: number;
  112391. /**
  112392. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112393. */
  112394. focalLength: number;
  112395. private _depthTexture;
  112396. /**
  112397. * Creates a new instance CircleOfConfusionPostProcess
  112398. * @param name The name of the effect.
  112399. * @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.
  112400. * @param options The required width/height ratio to downsize to before computing the render pass.
  112401. * @param camera The camera to apply the render pass to.
  112402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112403. * @param engine The engine which the post process will be applied. (default: current engine)
  112404. * @param reusable If the post process can be reused on the same frame. (default: false)
  112405. * @param textureType Type of textures used when performing the post process. (default: 0)
  112406. * @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)
  112407. */
  112408. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112409. /**
  112410. * 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.
  112411. */
  112412. depthTexture: RenderTargetTexture;
  112413. }
  112414. }
  112415. declare module BABYLON {
  112416. /** @hidden */
  112417. export var colorCorrectionPixelShader: {
  112418. name: string;
  112419. shader: string;
  112420. };
  112421. }
  112422. declare module BABYLON {
  112423. /**
  112424. *
  112425. * This post-process allows the modification of rendered colors by using
  112426. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112427. *
  112428. * The object needs to be provided an url to a texture containing the color
  112429. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112430. * Use an image editing software to tweak the LUT to match your needs.
  112431. *
  112432. * For an example of a color LUT, see here:
  112433. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112434. * For explanations on color grading, see here:
  112435. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112436. *
  112437. */
  112438. export class ColorCorrectionPostProcess extends PostProcess {
  112439. private _colorTableTexture;
  112440. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112441. }
  112442. }
  112443. declare module BABYLON {
  112444. /** @hidden */
  112445. export var convolutionPixelShader: {
  112446. name: string;
  112447. shader: string;
  112448. };
  112449. }
  112450. declare module BABYLON {
  112451. /**
  112452. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112453. * input texture to perform effects such as edge detection or sharpening
  112454. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112455. */
  112456. export class ConvolutionPostProcess extends PostProcess {
  112457. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112458. kernel: number[];
  112459. /**
  112460. * Creates a new instance ConvolutionPostProcess
  112461. * @param name The name of the effect.
  112462. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112463. * @param options The required width/height ratio to downsize to before computing the render pass.
  112464. * @param camera The camera to apply the render pass to.
  112465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112466. * @param engine The engine which the post process will be applied. (default: current engine)
  112467. * @param reusable If the post process can be reused on the same frame. (default: false)
  112468. * @param textureType Type of textures used when performing the post process. (default: 0)
  112469. */
  112470. constructor(name: string,
  112471. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112472. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112473. /**
  112474. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112475. */
  112476. static EdgeDetect0Kernel: number[];
  112477. /**
  112478. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112479. */
  112480. static EdgeDetect1Kernel: number[];
  112481. /**
  112482. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112483. */
  112484. static EdgeDetect2Kernel: number[];
  112485. /**
  112486. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112487. */
  112488. static SharpenKernel: number[];
  112489. /**
  112490. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112491. */
  112492. static EmbossKernel: number[];
  112493. /**
  112494. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112495. */
  112496. static GaussianKernel: number[];
  112497. }
  112498. }
  112499. declare module BABYLON {
  112500. /**
  112501. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112502. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112503. * based on samples that have a large difference in distance than the center pixel.
  112504. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112505. */
  112506. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112507. direction: Vector2;
  112508. /**
  112509. * Creates a new instance CircleOfConfusionPostProcess
  112510. * @param name The name of the effect.
  112511. * @param scene The scene the effect belongs to.
  112512. * @param direction The direction the blur should be applied.
  112513. * @param kernel The size of the kernel used to blur.
  112514. * @param options The required width/height ratio to downsize to before computing the render pass.
  112515. * @param camera The camera to apply the render pass to.
  112516. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112517. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112519. * @param engine The engine which the post process will be applied. (default: current engine)
  112520. * @param reusable If the post process can be reused on the same frame. (default: false)
  112521. * @param textureType Type of textures used when performing the post process. (default: 0)
  112522. * @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)
  112523. */
  112524. 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);
  112525. }
  112526. }
  112527. declare module BABYLON {
  112528. /** @hidden */
  112529. export var depthOfFieldMergePixelShader: {
  112530. name: string;
  112531. shader: string;
  112532. };
  112533. }
  112534. declare module BABYLON {
  112535. /**
  112536. * Options to be set when merging outputs from the default pipeline.
  112537. */
  112538. export class DepthOfFieldMergePostProcessOptions {
  112539. /**
  112540. * The original image to merge on top of
  112541. */
  112542. originalFromInput: PostProcess;
  112543. /**
  112544. * Parameters to perform the merge of the depth of field effect
  112545. */
  112546. depthOfField?: {
  112547. circleOfConfusion: PostProcess;
  112548. blurSteps: Array<PostProcess>;
  112549. };
  112550. /**
  112551. * Parameters to perform the merge of bloom effect
  112552. */
  112553. bloom?: {
  112554. blurred: PostProcess;
  112555. weight: number;
  112556. };
  112557. }
  112558. /**
  112559. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112560. */
  112561. export class DepthOfFieldMergePostProcess extends PostProcess {
  112562. private blurSteps;
  112563. /**
  112564. * Creates a new instance of DepthOfFieldMergePostProcess
  112565. * @param name The name of the effect.
  112566. * @param originalFromInput Post process which's input will be used for the merge.
  112567. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112568. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112569. * @param options The required width/height ratio to downsize to before computing the render pass.
  112570. * @param camera The camera to apply the render pass to.
  112571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112572. * @param engine The engine which the post process will be applied. (default: current engine)
  112573. * @param reusable If the post process can be reused on the same frame. (default: false)
  112574. * @param textureType Type of textures used when performing the post process. (default: 0)
  112575. * @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)
  112576. */
  112577. 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);
  112578. /**
  112579. * Updates the effect with the current post process compile time values and recompiles the shader.
  112580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112583. * @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
  112584. * @param onCompiled Called when the shader has been compiled.
  112585. * @param onError Called if there is an error when compiling a shader.
  112586. */
  112587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112588. }
  112589. }
  112590. declare module BABYLON {
  112591. /**
  112592. * Specifies the level of max blur that should be applied when using the depth of field effect
  112593. */
  112594. export enum DepthOfFieldEffectBlurLevel {
  112595. /**
  112596. * Subtle blur
  112597. */
  112598. Low = 0,
  112599. /**
  112600. * Medium blur
  112601. */
  112602. Medium = 1,
  112603. /**
  112604. * Large blur
  112605. */
  112606. High = 2
  112607. }
  112608. /**
  112609. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112610. */
  112611. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112612. private _circleOfConfusion;
  112613. /**
  112614. * @hidden Internal, blurs from high to low
  112615. */
  112616. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112617. private _depthOfFieldBlurY;
  112618. private _dofMerge;
  112619. /**
  112620. * @hidden Internal post processes in depth of field effect
  112621. */
  112622. _effects: Array<PostProcess>;
  112623. /**
  112624. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112625. */
  112626. focalLength: number;
  112627. /**
  112628. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112629. */
  112630. fStop: number;
  112631. /**
  112632. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112633. */
  112634. focusDistance: number;
  112635. /**
  112636. * 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.
  112637. */
  112638. lensSize: number;
  112639. /**
  112640. * Creates a new instance DepthOfFieldEffect
  112641. * @param scene The scene the effect belongs to.
  112642. * @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.
  112643. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112644. * @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)
  112645. */
  112646. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112647. /**
  112648. * Get the current class name of the current effet
  112649. * @returns "DepthOfFieldEffect"
  112650. */
  112651. getClassName(): string;
  112652. /**
  112653. * 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.
  112654. */
  112655. depthTexture: RenderTargetTexture;
  112656. /**
  112657. * Disposes each of the internal effects for a given camera.
  112658. * @param camera The camera to dispose the effect on.
  112659. */
  112660. disposeEffects(camera: Camera): void;
  112661. /**
  112662. * @hidden Internal
  112663. */
  112664. _updateEffects(): void;
  112665. /**
  112666. * Internal
  112667. * @returns if all the contained post processes are ready.
  112668. * @hidden
  112669. */
  112670. _isReady(): boolean;
  112671. }
  112672. }
  112673. declare module BABYLON {
  112674. /** @hidden */
  112675. export var displayPassPixelShader: {
  112676. name: string;
  112677. shader: string;
  112678. };
  112679. }
  112680. declare module BABYLON {
  112681. /**
  112682. * DisplayPassPostProcess which produces an output the same as it's input
  112683. */
  112684. export class DisplayPassPostProcess extends PostProcess {
  112685. /**
  112686. * Creates the DisplayPassPostProcess
  112687. * @param name The name of the effect.
  112688. * @param options The required width/height ratio to downsize to before computing the render pass.
  112689. * @param camera The camera to apply the render pass to.
  112690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112691. * @param engine The engine which the post process will be applied. (default: current engine)
  112692. * @param reusable If the post process can be reused on the same frame. (default: false)
  112693. */
  112694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112695. }
  112696. }
  112697. declare module BABYLON {
  112698. /** @hidden */
  112699. export var filterPixelShader: {
  112700. name: string;
  112701. shader: string;
  112702. };
  112703. }
  112704. declare module BABYLON {
  112705. /**
  112706. * Applies a kernel filter to the image
  112707. */
  112708. export class FilterPostProcess extends PostProcess {
  112709. /** The matrix to be applied to the image */
  112710. kernelMatrix: Matrix;
  112711. /**
  112712. *
  112713. * @param name The name of the effect.
  112714. * @param kernelMatrix The matrix to be applied to the image
  112715. * @param options The required width/height ratio to downsize to before computing the render pass.
  112716. * @param camera The camera to apply the render pass to.
  112717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112718. * @param engine The engine which the post process will be applied. (default: current engine)
  112719. * @param reusable If the post process can be reused on the same frame. (default: false)
  112720. */
  112721. constructor(name: string,
  112722. /** The matrix to be applied to the image */
  112723. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112724. }
  112725. }
  112726. declare module BABYLON {
  112727. /** @hidden */
  112728. export var fxaaPixelShader: {
  112729. name: string;
  112730. shader: string;
  112731. };
  112732. }
  112733. declare module BABYLON {
  112734. /** @hidden */
  112735. export var fxaaVertexShader: {
  112736. name: string;
  112737. shader: string;
  112738. };
  112739. }
  112740. declare module BABYLON {
  112741. /**
  112742. * Fxaa post process
  112743. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112744. */
  112745. export class FxaaPostProcess extends PostProcess {
  112746. /** @hidden */
  112747. texelWidth: number;
  112748. /** @hidden */
  112749. texelHeight: number;
  112750. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112751. private _getDefines;
  112752. }
  112753. }
  112754. declare module BABYLON {
  112755. /** @hidden */
  112756. export var grainPixelShader: {
  112757. name: string;
  112758. shader: string;
  112759. };
  112760. }
  112761. declare module BABYLON {
  112762. /**
  112763. * The GrainPostProcess adds noise to the image at mid luminance levels
  112764. */
  112765. export class GrainPostProcess extends PostProcess {
  112766. /**
  112767. * The intensity of the grain added (default: 30)
  112768. */
  112769. intensity: number;
  112770. /**
  112771. * If the grain should be randomized on every frame
  112772. */
  112773. animated: boolean;
  112774. /**
  112775. * Creates a new instance of @see GrainPostProcess
  112776. * @param name The name of the effect.
  112777. * @param options The required width/height ratio to downsize to before computing the render pass.
  112778. * @param camera The camera to apply the render pass to.
  112779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112780. * @param engine The engine which the post process will be applied. (default: current engine)
  112781. * @param reusable If the post process can be reused on the same frame. (default: false)
  112782. * @param textureType Type of textures used when performing the post process. (default: 0)
  112783. * @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)
  112784. */
  112785. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112786. }
  112787. }
  112788. declare module BABYLON {
  112789. /** @hidden */
  112790. export var highlightsPixelShader: {
  112791. name: string;
  112792. shader: string;
  112793. };
  112794. }
  112795. declare module BABYLON {
  112796. /**
  112797. * Extracts highlights from the image
  112798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112799. */
  112800. export class HighlightsPostProcess extends PostProcess {
  112801. /**
  112802. * Extracts highlights from the image
  112803. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112804. * @param name The name of the effect.
  112805. * @param options The required width/height ratio to downsize to before computing the render pass.
  112806. * @param camera The camera to apply the render pass to.
  112807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112808. * @param engine The engine which the post process will be applied. (default: current engine)
  112809. * @param reusable If the post process can be reused on the same frame. (default: false)
  112810. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112811. */
  112812. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112813. }
  112814. }
  112815. declare module BABYLON {
  112816. /** @hidden */
  112817. export var mrtFragmentDeclaration: {
  112818. name: string;
  112819. shader: string;
  112820. };
  112821. }
  112822. declare module BABYLON {
  112823. /** @hidden */
  112824. export var geometryPixelShader: {
  112825. name: string;
  112826. shader: string;
  112827. };
  112828. }
  112829. declare module BABYLON {
  112830. /** @hidden */
  112831. export var geometryVertexShader: {
  112832. name: string;
  112833. shader: string;
  112834. };
  112835. }
  112836. declare module BABYLON {
  112837. /**
  112838. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112839. */
  112840. export class GeometryBufferRenderer {
  112841. /**
  112842. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112843. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112844. */
  112845. static readonly POSITION_TEXTURE_TYPE: number;
  112846. /**
  112847. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112848. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112849. */
  112850. static readonly VELOCITY_TEXTURE_TYPE: number;
  112851. /**
  112852. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112853. * in order to compute objects velocities when enableVelocity is set to "true"
  112854. * @hidden
  112855. */
  112856. _previousTransformationMatrices: {
  112857. [index: number]: Matrix;
  112858. };
  112859. private _scene;
  112860. private _multiRenderTarget;
  112861. private _ratio;
  112862. private _enablePosition;
  112863. private _enableVelocity;
  112864. private _positionIndex;
  112865. private _velocityIndex;
  112866. protected _effect: Effect;
  112867. protected _cachedDefines: string;
  112868. /**
  112869. * Set the render list (meshes to be rendered) used in the G buffer.
  112870. */
  112871. renderList: Mesh[];
  112872. /**
  112873. * Gets wether or not G buffer are supported by the running hardware.
  112874. * This requires draw buffer supports
  112875. */
  112876. readonly isSupported: boolean;
  112877. /**
  112878. * Returns the index of the given texture type in the G-Buffer textures array
  112879. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112880. * @returns the index of the given texture type in the G-Buffer textures array
  112881. */
  112882. getTextureIndex(textureType: number): number;
  112883. /**
  112884. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112885. */
  112886. /**
  112887. * Sets whether or not objects positions are enabled for the G buffer.
  112888. */
  112889. enablePosition: boolean;
  112890. /**
  112891. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112892. */
  112893. /**
  112894. * Sets wether or not objects velocities are enabled for the G buffer.
  112895. */
  112896. enableVelocity: boolean;
  112897. /**
  112898. * Gets the scene associated with the buffer.
  112899. */
  112900. readonly scene: Scene;
  112901. /**
  112902. * Gets the ratio used by the buffer during its creation.
  112903. * How big is the buffer related to the main canvas.
  112904. */
  112905. readonly ratio: number;
  112906. /** @hidden */
  112907. static _SceneComponentInitialization: (scene: Scene) => void;
  112908. /**
  112909. * Creates a new G Buffer for the scene
  112910. * @param scene The scene the buffer belongs to
  112911. * @param ratio How big is the buffer related to the main canvas.
  112912. */
  112913. constructor(scene: Scene, ratio?: number);
  112914. /**
  112915. * Checks wether everything is ready to render a submesh to the G buffer.
  112916. * @param subMesh the submesh to check readiness for
  112917. * @param useInstances is the mesh drawn using instance or not
  112918. * @returns true if ready otherwise false
  112919. */
  112920. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112921. /**
  112922. * Gets the current underlying G Buffer.
  112923. * @returns the buffer
  112924. */
  112925. getGBuffer(): MultiRenderTarget;
  112926. /**
  112927. * Gets the number of samples used to render the buffer (anti aliasing).
  112928. */
  112929. /**
  112930. * Sets the number of samples used to render the buffer (anti aliasing).
  112931. */
  112932. samples: number;
  112933. /**
  112934. * Disposes the renderer and frees up associated resources.
  112935. */
  112936. dispose(): void;
  112937. protected _createRenderTargets(): void;
  112938. }
  112939. }
  112940. declare module BABYLON {
  112941. interface Scene {
  112942. /** @hidden (Backing field) */
  112943. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112944. /**
  112945. * Gets or Sets the current geometry buffer associated to the scene.
  112946. */
  112947. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112948. /**
  112949. * Enables a GeometryBufferRender and associates it with the scene
  112950. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  112951. * @returns the GeometryBufferRenderer
  112952. */
  112953. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112954. /**
  112955. * Disables the GeometryBufferRender associated with the scene
  112956. */
  112957. disableGeometryBufferRenderer(): void;
  112958. }
  112959. /**
  112960. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112961. * in several rendering techniques.
  112962. */
  112963. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112964. /**
  112965. * The component name helpful to identify the component in the list of scene components.
  112966. */
  112967. readonly name: string;
  112968. /**
  112969. * The scene the component belongs to.
  112970. */
  112971. scene: Scene;
  112972. /**
  112973. * Creates a new instance of the component for the given scene
  112974. * @param scene Defines the scene to register the component in
  112975. */
  112976. constructor(scene: Scene);
  112977. /**
  112978. * Registers the component in a given scene
  112979. */
  112980. register(): void;
  112981. /**
  112982. * Rebuilds the elements related to this component in case of
  112983. * context lost for instance.
  112984. */
  112985. rebuild(): void;
  112986. /**
  112987. * Disposes the component and the associated ressources
  112988. */
  112989. dispose(): void;
  112990. private _gatherRenderTargets;
  112991. }
  112992. }
  112993. declare module BABYLON {
  112994. /** @hidden */
  112995. export var motionBlurPixelShader: {
  112996. name: string;
  112997. shader: string;
  112998. };
  112999. }
  113000. declare module BABYLON {
  113001. /**
  113002. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113003. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113004. * As an example, all you have to do is to create the post-process:
  113005. * var mb = new BABYLON.MotionBlurPostProcess(
  113006. * 'mb', // The name of the effect.
  113007. * scene, // The scene containing the objects to blur according to their velocity.
  113008. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113009. * camera // The camera to apply the render pass to.
  113010. * );
  113011. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113012. */
  113013. export class MotionBlurPostProcess extends PostProcess {
  113014. /**
  113015. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113016. */
  113017. motionStrength: number;
  113018. /**
  113019. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113020. */
  113021. /**
  113022. * Sets the number of iterations to be used for motion blur quality
  113023. */
  113024. motionBlurSamples: number;
  113025. private _motionBlurSamples;
  113026. private _geometryBufferRenderer;
  113027. /**
  113028. * Creates a new instance MotionBlurPostProcess
  113029. * @param name The name of the effect.
  113030. * @param scene The scene containing the objects to blur according to their velocity.
  113031. * @param options The required width/height ratio to downsize to before computing the render pass.
  113032. * @param camera The camera to apply the render pass to.
  113033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113034. * @param engine The engine which the post process will be applied. (default: current engine)
  113035. * @param reusable If the post process can be reused on the same frame. (default: false)
  113036. * @param textureType Type of textures used when performing the post process. (default: 0)
  113037. * @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)
  113038. */
  113039. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113040. /**
  113041. * Disposes the post process.
  113042. * @param camera The camera to dispose the post process on.
  113043. */
  113044. dispose(camera?: Camera): void;
  113045. }
  113046. }
  113047. declare module BABYLON {
  113048. /** @hidden */
  113049. export var refractionPixelShader: {
  113050. name: string;
  113051. shader: string;
  113052. };
  113053. }
  113054. declare module BABYLON {
  113055. /**
  113056. * Post process which applies a refractin texture
  113057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113058. */
  113059. export class RefractionPostProcess extends PostProcess {
  113060. /** the base color of the refraction (used to taint the rendering) */
  113061. color: Color3;
  113062. /** simulated refraction depth */
  113063. depth: number;
  113064. /** the coefficient of the base color (0 to remove base color tainting) */
  113065. colorLevel: number;
  113066. private _refTexture;
  113067. private _ownRefractionTexture;
  113068. /**
  113069. * Gets or sets the refraction texture
  113070. * Please note that you are responsible for disposing the texture if you set it manually
  113071. */
  113072. refractionTexture: Texture;
  113073. /**
  113074. * Initializes the RefractionPostProcess
  113075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113076. * @param name The name of the effect.
  113077. * @param refractionTextureUrl Url of the refraction texture to use
  113078. * @param color the base color of the refraction (used to taint the rendering)
  113079. * @param depth simulated refraction depth
  113080. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113081. * @param camera The camera to apply the render pass to.
  113082. * @param options The required width/height ratio to downsize to before computing the render pass.
  113083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113084. * @param engine The engine which the post process will be applied. (default: current engine)
  113085. * @param reusable If the post process can be reused on the same frame. (default: false)
  113086. */
  113087. constructor(name: string, refractionTextureUrl: string,
  113088. /** the base color of the refraction (used to taint the rendering) */
  113089. color: Color3,
  113090. /** simulated refraction depth */
  113091. depth: number,
  113092. /** the coefficient of the base color (0 to remove base color tainting) */
  113093. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113094. /**
  113095. * Disposes of the post process
  113096. * @param camera Camera to dispose post process on
  113097. */
  113098. dispose(camera: Camera): void;
  113099. }
  113100. }
  113101. declare module BABYLON {
  113102. /** @hidden */
  113103. export var sharpenPixelShader: {
  113104. name: string;
  113105. shader: string;
  113106. };
  113107. }
  113108. declare module BABYLON {
  113109. /**
  113110. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113111. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113112. */
  113113. export class SharpenPostProcess extends PostProcess {
  113114. /**
  113115. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113116. */
  113117. colorAmount: number;
  113118. /**
  113119. * How much sharpness should be applied (default: 0.3)
  113120. */
  113121. edgeAmount: number;
  113122. /**
  113123. * Creates a new instance ConvolutionPostProcess
  113124. * @param name The name of the effect.
  113125. * @param options The required width/height ratio to downsize to before computing the render pass.
  113126. * @param camera The camera to apply the render pass to.
  113127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113128. * @param engine The engine which the post process will be applied. (default: current engine)
  113129. * @param reusable If the post process can be reused on the same frame. (default: false)
  113130. * @param textureType Type of textures used when performing the post process. (default: 0)
  113131. * @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)
  113132. */
  113133. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113134. }
  113135. }
  113136. declare module BABYLON {
  113137. /**
  113138. * PostProcessRenderPipeline
  113139. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113140. */
  113141. export class PostProcessRenderPipeline {
  113142. private engine;
  113143. private _renderEffects;
  113144. private _renderEffectsForIsolatedPass;
  113145. /**
  113146. * List of inspectable custom properties (used by the Inspector)
  113147. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113148. */
  113149. inspectableCustomProperties: IInspectable[];
  113150. /**
  113151. * @hidden
  113152. */
  113153. protected _cameras: Camera[];
  113154. /** @hidden */
  113155. _name: string;
  113156. /**
  113157. * Gets pipeline name
  113158. */
  113159. readonly name: string;
  113160. /**
  113161. * Initializes a PostProcessRenderPipeline
  113162. * @param engine engine to add the pipeline to
  113163. * @param name name of the pipeline
  113164. */
  113165. constructor(engine: Engine, name: string);
  113166. /**
  113167. * Gets the class name
  113168. * @returns "PostProcessRenderPipeline"
  113169. */
  113170. getClassName(): string;
  113171. /**
  113172. * If all the render effects in the pipeline are supported
  113173. */
  113174. readonly isSupported: boolean;
  113175. /**
  113176. * Adds an effect to the pipeline
  113177. * @param renderEffect the effect to add
  113178. */
  113179. addEffect(renderEffect: PostProcessRenderEffect): void;
  113180. /** @hidden */
  113181. _rebuild(): void;
  113182. /** @hidden */
  113183. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113184. /** @hidden */
  113185. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113186. /** @hidden */
  113187. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113188. /** @hidden */
  113189. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113190. /** @hidden */
  113191. _attachCameras(cameras: Camera, unique: boolean): void;
  113192. /** @hidden */
  113193. _attachCameras(cameras: Camera[], unique: boolean): void;
  113194. /** @hidden */
  113195. _detachCameras(cameras: Camera): void;
  113196. /** @hidden */
  113197. _detachCameras(cameras: Nullable<Camera[]>): void;
  113198. /** @hidden */
  113199. _update(): void;
  113200. /** @hidden */
  113201. _reset(): void;
  113202. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113203. /**
  113204. * Disposes of the pipeline
  113205. */
  113206. dispose(): void;
  113207. }
  113208. }
  113209. declare module BABYLON {
  113210. /**
  113211. * PostProcessRenderPipelineManager class
  113212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113213. */
  113214. export class PostProcessRenderPipelineManager {
  113215. private _renderPipelines;
  113216. /**
  113217. * Initializes a PostProcessRenderPipelineManager
  113218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113219. */
  113220. constructor();
  113221. /**
  113222. * Gets the list of supported render pipelines
  113223. */
  113224. readonly supportedPipelines: PostProcessRenderPipeline[];
  113225. /**
  113226. * Adds a pipeline to the manager
  113227. * @param renderPipeline The pipeline to add
  113228. */
  113229. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113230. /**
  113231. * Attaches a camera to the pipeline
  113232. * @param renderPipelineName The name of the pipeline to attach to
  113233. * @param cameras the camera to attach
  113234. * @param unique if the camera can be attached multiple times to the pipeline
  113235. */
  113236. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113237. /**
  113238. * Detaches a camera from the pipeline
  113239. * @param renderPipelineName The name of the pipeline to detach from
  113240. * @param cameras the camera to detach
  113241. */
  113242. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113243. /**
  113244. * Enables an effect by name on a pipeline
  113245. * @param renderPipelineName the name of the pipeline to enable the effect in
  113246. * @param renderEffectName the name of the effect to enable
  113247. * @param cameras the cameras that the effect should be enabled on
  113248. */
  113249. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113250. /**
  113251. * Disables an effect by name on a pipeline
  113252. * @param renderPipelineName the name of the pipeline to disable the effect in
  113253. * @param renderEffectName the name of the effect to disable
  113254. * @param cameras the cameras that the effect should be disabled on
  113255. */
  113256. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113257. /**
  113258. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113259. */
  113260. update(): void;
  113261. /** @hidden */
  113262. _rebuild(): void;
  113263. /**
  113264. * Disposes of the manager and pipelines
  113265. */
  113266. dispose(): void;
  113267. }
  113268. }
  113269. declare module BABYLON {
  113270. interface Scene {
  113271. /** @hidden (Backing field) */
  113272. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113273. /**
  113274. * Gets the postprocess render pipeline manager
  113275. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113276. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113277. */
  113278. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113279. }
  113280. /**
  113281. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113282. */
  113283. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113284. /**
  113285. * The component name helpfull to identify the component in the list of scene components.
  113286. */
  113287. readonly name: string;
  113288. /**
  113289. * The scene the component belongs to.
  113290. */
  113291. scene: Scene;
  113292. /**
  113293. * Creates a new instance of the component for the given scene
  113294. * @param scene Defines the scene to register the component in
  113295. */
  113296. constructor(scene: Scene);
  113297. /**
  113298. * Registers the component in a given scene
  113299. */
  113300. register(): void;
  113301. /**
  113302. * Rebuilds the elements related to this component in case of
  113303. * context lost for instance.
  113304. */
  113305. rebuild(): void;
  113306. /**
  113307. * Disposes the component and the associated ressources
  113308. */
  113309. dispose(): void;
  113310. private _gatherRenderTargets;
  113311. }
  113312. }
  113313. declare module BABYLON {
  113314. /**
  113315. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113316. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113317. */
  113318. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113319. private _scene;
  113320. private _camerasToBeAttached;
  113321. /**
  113322. * ID of the sharpen post process,
  113323. */
  113324. private readonly SharpenPostProcessId;
  113325. /**
  113326. * @ignore
  113327. * ID of the image processing post process;
  113328. */
  113329. readonly ImageProcessingPostProcessId: string;
  113330. /**
  113331. * @ignore
  113332. * ID of the Fast Approximate Anti-Aliasing post process;
  113333. */
  113334. readonly FxaaPostProcessId: string;
  113335. /**
  113336. * ID of the chromatic aberration post process,
  113337. */
  113338. private readonly ChromaticAberrationPostProcessId;
  113339. /**
  113340. * ID of the grain post process
  113341. */
  113342. private readonly GrainPostProcessId;
  113343. /**
  113344. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113345. */
  113346. sharpen: SharpenPostProcess;
  113347. private _sharpenEffect;
  113348. private bloom;
  113349. /**
  113350. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113351. */
  113352. depthOfField: DepthOfFieldEffect;
  113353. /**
  113354. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113355. */
  113356. fxaa: FxaaPostProcess;
  113357. /**
  113358. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113359. */
  113360. imageProcessing: ImageProcessingPostProcess;
  113361. /**
  113362. * Chromatic aberration post process which will shift rgb colors in the image
  113363. */
  113364. chromaticAberration: ChromaticAberrationPostProcess;
  113365. private _chromaticAberrationEffect;
  113366. /**
  113367. * Grain post process which add noise to the image
  113368. */
  113369. grain: GrainPostProcess;
  113370. private _grainEffect;
  113371. /**
  113372. * Glow post process which adds a glow to emissive areas of the image
  113373. */
  113374. private _glowLayer;
  113375. /**
  113376. * Animations which can be used to tweak settings over a period of time
  113377. */
  113378. animations: Animation[];
  113379. private _imageProcessingConfigurationObserver;
  113380. private _sharpenEnabled;
  113381. private _bloomEnabled;
  113382. private _depthOfFieldEnabled;
  113383. private _depthOfFieldBlurLevel;
  113384. private _fxaaEnabled;
  113385. private _imageProcessingEnabled;
  113386. private _defaultPipelineTextureType;
  113387. private _bloomScale;
  113388. private _chromaticAberrationEnabled;
  113389. private _grainEnabled;
  113390. private _buildAllowed;
  113391. /**
  113392. * Gets active scene
  113393. */
  113394. readonly scene: Scene;
  113395. /**
  113396. * Enable or disable the sharpen process from the pipeline
  113397. */
  113398. sharpenEnabled: boolean;
  113399. private _resizeObserver;
  113400. private _hardwareScaleLevel;
  113401. private _bloomKernel;
  113402. /**
  113403. * Specifies the size of the bloom blur kernel, relative to the final output size
  113404. */
  113405. bloomKernel: number;
  113406. /**
  113407. * Specifies the weight of the bloom in the final rendering
  113408. */
  113409. private _bloomWeight;
  113410. /**
  113411. * Specifies the luma threshold for the area that will be blurred by the bloom
  113412. */
  113413. private _bloomThreshold;
  113414. private _hdr;
  113415. /**
  113416. * The strength of the bloom.
  113417. */
  113418. bloomWeight: number;
  113419. /**
  113420. * The strength of the bloom.
  113421. */
  113422. bloomThreshold: number;
  113423. /**
  113424. * The scale of the bloom, lower value will provide better performance.
  113425. */
  113426. bloomScale: number;
  113427. /**
  113428. * Enable or disable the bloom from the pipeline
  113429. */
  113430. bloomEnabled: boolean;
  113431. private _rebuildBloom;
  113432. /**
  113433. * If the depth of field is enabled.
  113434. */
  113435. depthOfFieldEnabled: boolean;
  113436. /**
  113437. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113438. */
  113439. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113440. /**
  113441. * If the anti aliasing is enabled.
  113442. */
  113443. fxaaEnabled: boolean;
  113444. private _samples;
  113445. /**
  113446. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113447. */
  113448. samples: number;
  113449. /**
  113450. * If image processing is enabled.
  113451. */
  113452. imageProcessingEnabled: boolean;
  113453. /**
  113454. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113455. */
  113456. glowLayerEnabled: boolean;
  113457. /**
  113458. * Enable or disable the chromaticAberration process from the pipeline
  113459. */
  113460. chromaticAberrationEnabled: boolean;
  113461. /**
  113462. * Enable or disable the grain process from the pipeline
  113463. */
  113464. grainEnabled: boolean;
  113465. /**
  113466. * @constructor
  113467. * @param name - The rendering pipeline name (default: "")
  113468. * @param hdr - If high dynamic range textures should be used (default: true)
  113469. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113470. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113471. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113472. */
  113473. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113474. /**
  113475. * Get the class name
  113476. * @returns "DefaultRenderingPipeline"
  113477. */
  113478. getClassName(): string;
  113479. /**
  113480. * Force the compilation of the entire pipeline.
  113481. */
  113482. prepare(): void;
  113483. private _hasCleared;
  113484. private _prevPostProcess;
  113485. private _prevPrevPostProcess;
  113486. private _setAutoClearAndTextureSharing;
  113487. private _depthOfFieldSceneObserver;
  113488. private _buildPipeline;
  113489. private _disposePostProcesses;
  113490. /**
  113491. * Adds a camera to the pipeline
  113492. * @param camera the camera to be added
  113493. */
  113494. addCamera(camera: Camera): void;
  113495. /**
  113496. * Removes a camera from the pipeline
  113497. * @param camera the camera to remove
  113498. */
  113499. removeCamera(camera: Camera): void;
  113500. /**
  113501. * Dispose of the pipeline and stop all post processes
  113502. */
  113503. dispose(): void;
  113504. /**
  113505. * Serialize the rendering pipeline (Used when exporting)
  113506. * @returns the serialized object
  113507. */
  113508. serialize(): any;
  113509. /**
  113510. * Parse the serialized pipeline
  113511. * @param source Source pipeline.
  113512. * @param scene The scene to load the pipeline to.
  113513. * @param rootUrl The URL of the serialized pipeline.
  113514. * @returns An instantiated pipeline from the serialized object.
  113515. */
  113516. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113517. }
  113518. }
  113519. declare module BABYLON {
  113520. /** @hidden */
  113521. export var lensHighlightsPixelShader: {
  113522. name: string;
  113523. shader: string;
  113524. };
  113525. }
  113526. declare module BABYLON {
  113527. /** @hidden */
  113528. export var depthOfFieldPixelShader: {
  113529. name: string;
  113530. shader: string;
  113531. };
  113532. }
  113533. declare module BABYLON {
  113534. /**
  113535. * BABYLON.JS Chromatic Aberration GLSL Shader
  113536. * Author: Olivier Guyot
  113537. * Separates very slightly R, G and B colors on the edges of the screen
  113538. * Inspired by Francois Tarlier & Martins Upitis
  113539. */
  113540. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113541. /**
  113542. * @ignore
  113543. * The chromatic aberration PostProcess id in the pipeline
  113544. */
  113545. LensChromaticAberrationEffect: string;
  113546. /**
  113547. * @ignore
  113548. * The highlights enhancing PostProcess id in the pipeline
  113549. */
  113550. HighlightsEnhancingEffect: string;
  113551. /**
  113552. * @ignore
  113553. * The depth-of-field PostProcess id in the pipeline
  113554. */
  113555. LensDepthOfFieldEffect: string;
  113556. private _scene;
  113557. private _depthTexture;
  113558. private _grainTexture;
  113559. private _chromaticAberrationPostProcess;
  113560. private _highlightsPostProcess;
  113561. private _depthOfFieldPostProcess;
  113562. private _edgeBlur;
  113563. private _grainAmount;
  113564. private _chromaticAberration;
  113565. private _distortion;
  113566. private _highlightsGain;
  113567. private _highlightsThreshold;
  113568. private _dofDistance;
  113569. private _dofAperture;
  113570. private _dofDarken;
  113571. private _dofPentagon;
  113572. private _blurNoise;
  113573. /**
  113574. * @constructor
  113575. *
  113576. * Effect parameters are as follow:
  113577. * {
  113578. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113579. * edge_blur: number; // from 0 to x (1 for realism)
  113580. * distortion: number; // from 0 to x (1 for realism)
  113581. * grain_amount: number; // from 0 to 1
  113582. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113583. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113584. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113585. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113586. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113587. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113588. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113589. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113590. * }
  113591. * Note: if an effect parameter is unset, effect is disabled
  113592. *
  113593. * @param name The rendering pipeline name
  113594. * @param parameters - An object containing all parameters (see above)
  113595. * @param scene The scene linked to this pipeline
  113596. * @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)
  113597. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113598. */
  113599. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113600. /**
  113601. * Get the class name
  113602. * @returns "LensRenderingPipeline"
  113603. */
  113604. getClassName(): string;
  113605. /**
  113606. * Gets associated scene
  113607. */
  113608. readonly scene: Scene;
  113609. /**
  113610. * Gets or sets the edge blur
  113611. */
  113612. edgeBlur: number;
  113613. /**
  113614. * Gets or sets the grain amount
  113615. */
  113616. grainAmount: number;
  113617. /**
  113618. * Gets or sets the chromatic aberration amount
  113619. */
  113620. chromaticAberration: number;
  113621. /**
  113622. * Gets or sets the depth of field aperture
  113623. */
  113624. dofAperture: number;
  113625. /**
  113626. * Gets or sets the edge distortion
  113627. */
  113628. edgeDistortion: number;
  113629. /**
  113630. * Gets or sets the depth of field distortion
  113631. */
  113632. dofDistortion: number;
  113633. /**
  113634. * Gets or sets the darken out of focus amount
  113635. */
  113636. darkenOutOfFocus: number;
  113637. /**
  113638. * Gets or sets a boolean indicating if blur noise is enabled
  113639. */
  113640. blurNoise: boolean;
  113641. /**
  113642. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113643. */
  113644. pentagonBokeh: boolean;
  113645. /**
  113646. * Gets or sets the highlight grain amount
  113647. */
  113648. highlightsGain: number;
  113649. /**
  113650. * Gets or sets the highlight threshold
  113651. */
  113652. highlightsThreshold: number;
  113653. /**
  113654. * Sets the amount of blur at the edges
  113655. * @param amount blur amount
  113656. */
  113657. setEdgeBlur(amount: number): void;
  113658. /**
  113659. * Sets edge blur to 0
  113660. */
  113661. disableEdgeBlur(): void;
  113662. /**
  113663. * Sets the amout of grain
  113664. * @param amount Amount of grain
  113665. */
  113666. setGrainAmount(amount: number): void;
  113667. /**
  113668. * Set grain amount to 0
  113669. */
  113670. disableGrain(): void;
  113671. /**
  113672. * Sets the chromatic aberration amount
  113673. * @param amount amount of chromatic aberration
  113674. */
  113675. setChromaticAberration(amount: number): void;
  113676. /**
  113677. * Sets chromatic aberration amount to 0
  113678. */
  113679. disableChromaticAberration(): void;
  113680. /**
  113681. * Sets the EdgeDistortion amount
  113682. * @param amount amount of EdgeDistortion
  113683. */
  113684. setEdgeDistortion(amount: number): void;
  113685. /**
  113686. * Sets edge distortion to 0
  113687. */
  113688. disableEdgeDistortion(): void;
  113689. /**
  113690. * Sets the FocusDistance amount
  113691. * @param amount amount of FocusDistance
  113692. */
  113693. setFocusDistance(amount: number): void;
  113694. /**
  113695. * Disables depth of field
  113696. */
  113697. disableDepthOfField(): void;
  113698. /**
  113699. * Sets the Aperture amount
  113700. * @param amount amount of Aperture
  113701. */
  113702. setAperture(amount: number): void;
  113703. /**
  113704. * Sets the DarkenOutOfFocus amount
  113705. * @param amount amount of DarkenOutOfFocus
  113706. */
  113707. setDarkenOutOfFocus(amount: number): void;
  113708. private _pentagonBokehIsEnabled;
  113709. /**
  113710. * Creates a pentagon bokeh effect
  113711. */
  113712. enablePentagonBokeh(): void;
  113713. /**
  113714. * Disables the pentagon bokeh effect
  113715. */
  113716. disablePentagonBokeh(): void;
  113717. /**
  113718. * Enables noise blur
  113719. */
  113720. enableNoiseBlur(): void;
  113721. /**
  113722. * Disables noise blur
  113723. */
  113724. disableNoiseBlur(): void;
  113725. /**
  113726. * Sets the HighlightsGain amount
  113727. * @param amount amount of HighlightsGain
  113728. */
  113729. setHighlightsGain(amount: number): void;
  113730. /**
  113731. * Sets the HighlightsThreshold amount
  113732. * @param amount amount of HighlightsThreshold
  113733. */
  113734. setHighlightsThreshold(amount: number): void;
  113735. /**
  113736. * Disables highlights
  113737. */
  113738. disableHighlights(): void;
  113739. /**
  113740. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113741. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113742. */
  113743. dispose(disableDepthRender?: boolean): void;
  113744. private _createChromaticAberrationPostProcess;
  113745. private _createHighlightsPostProcess;
  113746. private _createDepthOfFieldPostProcess;
  113747. private _createGrainTexture;
  113748. }
  113749. }
  113750. declare module BABYLON {
  113751. /** @hidden */
  113752. export var ssao2PixelShader: {
  113753. name: string;
  113754. shader: string;
  113755. };
  113756. }
  113757. declare module BABYLON {
  113758. /** @hidden */
  113759. export var ssaoCombinePixelShader: {
  113760. name: string;
  113761. shader: string;
  113762. };
  113763. }
  113764. declare module BABYLON {
  113765. /**
  113766. * Render pipeline to produce ssao effect
  113767. */
  113768. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113769. /**
  113770. * @ignore
  113771. * The PassPostProcess id in the pipeline that contains the original scene color
  113772. */
  113773. SSAOOriginalSceneColorEffect: string;
  113774. /**
  113775. * @ignore
  113776. * The SSAO PostProcess id in the pipeline
  113777. */
  113778. SSAORenderEffect: string;
  113779. /**
  113780. * @ignore
  113781. * The horizontal blur PostProcess id in the pipeline
  113782. */
  113783. SSAOBlurHRenderEffect: string;
  113784. /**
  113785. * @ignore
  113786. * The vertical blur PostProcess id in the pipeline
  113787. */
  113788. SSAOBlurVRenderEffect: string;
  113789. /**
  113790. * @ignore
  113791. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113792. */
  113793. SSAOCombineRenderEffect: string;
  113794. /**
  113795. * The output strength of the SSAO post-process. Default value is 1.0.
  113796. */
  113797. totalStrength: number;
  113798. /**
  113799. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113800. */
  113801. maxZ: number;
  113802. /**
  113803. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113804. */
  113805. minZAspect: number;
  113806. private _samples;
  113807. /**
  113808. * Number of samples used for the SSAO calculations. Default value is 8
  113809. */
  113810. samples: number;
  113811. private _textureSamples;
  113812. /**
  113813. * Number of samples to use for antialiasing
  113814. */
  113815. textureSamples: number;
  113816. /**
  113817. * Ratio object used for SSAO ratio and blur ratio
  113818. */
  113819. private _ratio;
  113820. /**
  113821. * Dynamically generated sphere sampler.
  113822. */
  113823. private _sampleSphere;
  113824. /**
  113825. * Blur filter offsets
  113826. */
  113827. private _samplerOffsets;
  113828. private _expensiveBlur;
  113829. /**
  113830. * If bilateral blur should be used
  113831. */
  113832. expensiveBlur: boolean;
  113833. /**
  113834. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113835. */
  113836. radius: number;
  113837. /**
  113838. * The base color of the SSAO post-process
  113839. * The final result is "base + ssao" between [0, 1]
  113840. */
  113841. base: number;
  113842. /**
  113843. * Support test.
  113844. */
  113845. static readonly IsSupported: boolean;
  113846. private _scene;
  113847. private _depthTexture;
  113848. private _normalTexture;
  113849. private _randomTexture;
  113850. private _originalColorPostProcess;
  113851. private _ssaoPostProcess;
  113852. private _blurHPostProcess;
  113853. private _blurVPostProcess;
  113854. private _ssaoCombinePostProcess;
  113855. private _firstUpdate;
  113856. /**
  113857. * Gets active scene
  113858. */
  113859. readonly scene: Scene;
  113860. /**
  113861. * @constructor
  113862. * @param name The rendering pipeline name
  113863. * @param scene The scene linked to this pipeline
  113864. * @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 }
  113865. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113866. */
  113867. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113868. /**
  113869. * Get the class name
  113870. * @returns "SSAO2RenderingPipeline"
  113871. */
  113872. getClassName(): string;
  113873. /**
  113874. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113875. */
  113876. dispose(disableGeometryBufferRenderer?: boolean): void;
  113877. private _createBlurPostProcess;
  113878. /** @hidden */
  113879. _rebuild(): void;
  113880. private _bits;
  113881. private _radicalInverse_VdC;
  113882. private _hammersley;
  113883. private _hemisphereSample_uniform;
  113884. private _generateHemisphere;
  113885. private _createSSAOPostProcess;
  113886. private _createSSAOCombinePostProcess;
  113887. private _createRandomTexture;
  113888. /**
  113889. * Serialize the rendering pipeline (Used when exporting)
  113890. * @returns the serialized object
  113891. */
  113892. serialize(): any;
  113893. /**
  113894. * Parse the serialized pipeline
  113895. * @param source Source pipeline.
  113896. * @param scene The scene to load the pipeline to.
  113897. * @param rootUrl The URL of the serialized pipeline.
  113898. * @returns An instantiated pipeline from the serialized object.
  113899. */
  113900. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113901. }
  113902. }
  113903. declare module BABYLON {
  113904. /** @hidden */
  113905. export var ssaoPixelShader: {
  113906. name: string;
  113907. shader: string;
  113908. };
  113909. }
  113910. declare module BABYLON {
  113911. /**
  113912. * Render pipeline to produce ssao effect
  113913. */
  113914. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113915. /**
  113916. * @ignore
  113917. * The PassPostProcess id in the pipeline that contains the original scene color
  113918. */
  113919. SSAOOriginalSceneColorEffect: string;
  113920. /**
  113921. * @ignore
  113922. * The SSAO PostProcess id in the pipeline
  113923. */
  113924. SSAORenderEffect: string;
  113925. /**
  113926. * @ignore
  113927. * The horizontal blur PostProcess id in the pipeline
  113928. */
  113929. SSAOBlurHRenderEffect: string;
  113930. /**
  113931. * @ignore
  113932. * The vertical blur PostProcess id in the pipeline
  113933. */
  113934. SSAOBlurVRenderEffect: string;
  113935. /**
  113936. * @ignore
  113937. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113938. */
  113939. SSAOCombineRenderEffect: string;
  113940. /**
  113941. * The output strength of the SSAO post-process. Default value is 1.0.
  113942. */
  113943. totalStrength: number;
  113944. /**
  113945. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113946. */
  113947. radius: number;
  113948. /**
  113949. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113950. * Must not be equal to fallOff and superior to fallOff.
  113951. * Default value is 0.0075
  113952. */
  113953. area: number;
  113954. /**
  113955. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113956. * Must not be equal to area and inferior to area.
  113957. * Default value is 0.000001
  113958. */
  113959. fallOff: number;
  113960. /**
  113961. * The base color of the SSAO post-process
  113962. * The final result is "base + ssao" between [0, 1]
  113963. */
  113964. base: number;
  113965. private _scene;
  113966. private _depthTexture;
  113967. private _randomTexture;
  113968. private _originalColorPostProcess;
  113969. private _ssaoPostProcess;
  113970. private _blurHPostProcess;
  113971. private _blurVPostProcess;
  113972. private _ssaoCombinePostProcess;
  113973. private _firstUpdate;
  113974. /**
  113975. * Gets active scene
  113976. */
  113977. readonly scene: Scene;
  113978. /**
  113979. * @constructor
  113980. * @param name - The rendering pipeline name
  113981. * @param scene - The scene linked to this pipeline
  113982. * @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 }
  113983. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113984. */
  113985. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113986. /**
  113987. * Get the class name
  113988. * @returns "SSAORenderingPipeline"
  113989. */
  113990. getClassName(): string;
  113991. /**
  113992. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113993. */
  113994. dispose(disableDepthRender?: boolean): void;
  113995. private _createBlurPostProcess;
  113996. /** @hidden */
  113997. _rebuild(): void;
  113998. private _createSSAOPostProcess;
  113999. private _createSSAOCombinePostProcess;
  114000. private _createRandomTexture;
  114001. }
  114002. }
  114003. declare module BABYLON {
  114004. /** @hidden */
  114005. export var standardPixelShader: {
  114006. name: string;
  114007. shader: string;
  114008. };
  114009. }
  114010. declare module BABYLON {
  114011. /**
  114012. * Standard rendering pipeline
  114013. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114014. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114015. */
  114016. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114017. /**
  114018. * Public members
  114019. */
  114020. /**
  114021. * Post-process which contains the original scene color before the pipeline applies all the effects
  114022. */
  114023. originalPostProcess: Nullable<PostProcess>;
  114024. /**
  114025. * Post-process used to down scale an image x4
  114026. */
  114027. downSampleX4PostProcess: Nullable<PostProcess>;
  114028. /**
  114029. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114030. */
  114031. brightPassPostProcess: Nullable<PostProcess>;
  114032. /**
  114033. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114034. */
  114035. blurHPostProcesses: PostProcess[];
  114036. /**
  114037. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114038. */
  114039. blurVPostProcesses: PostProcess[];
  114040. /**
  114041. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114042. */
  114043. textureAdderPostProcess: Nullable<PostProcess>;
  114044. /**
  114045. * Post-process used to create volumetric lighting effect
  114046. */
  114047. volumetricLightPostProcess: Nullable<PostProcess>;
  114048. /**
  114049. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114050. */
  114051. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114052. /**
  114053. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114054. */
  114055. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114056. /**
  114057. * Post-process used to merge the volumetric light effect and the real scene color
  114058. */
  114059. volumetricLightMergePostProces: Nullable<PostProcess>;
  114060. /**
  114061. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114062. */
  114063. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114064. /**
  114065. * Base post-process used to calculate the average luminance of the final image for HDR
  114066. */
  114067. luminancePostProcess: Nullable<PostProcess>;
  114068. /**
  114069. * Post-processes used to create down sample post-processes in order to get
  114070. * the average luminance of the final image for HDR
  114071. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114072. */
  114073. luminanceDownSamplePostProcesses: PostProcess[];
  114074. /**
  114075. * Post-process used to create a HDR effect (light adaptation)
  114076. */
  114077. hdrPostProcess: Nullable<PostProcess>;
  114078. /**
  114079. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114080. */
  114081. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114082. /**
  114083. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114084. */
  114085. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114086. /**
  114087. * Post-process used to merge the final HDR post-process and the real scene color
  114088. */
  114089. hdrFinalPostProcess: Nullable<PostProcess>;
  114090. /**
  114091. * Post-process used to create a lens flare effect
  114092. */
  114093. lensFlarePostProcess: Nullable<PostProcess>;
  114094. /**
  114095. * Post-process that merges the result of the lens flare post-process and the real scene color
  114096. */
  114097. lensFlareComposePostProcess: Nullable<PostProcess>;
  114098. /**
  114099. * Post-process used to create a motion blur effect
  114100. */
  114101. motionBlurPostProcess: Nullable<PostProcess>;
  114102. /**
  114103. * Post-process used to create a depth of field effect
  114104. */
  114105. depthOfFieldPostProcess: Nullable<PostProcess>;
  114106. /**
  114107. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114108. */
  114109. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114110. /**
  114111. * Represents the brightness threshold in order to configure the illuminated surfaces
  114112. */
  114113. brightThreshold: number;
  114114. /**
  114115. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114116. */
  114117. blurWidth: number;
  114118. /**
  114119. * Sets if the blur for highlighted surfaces must be only horizontal
  114120. */
  114121. horizontalBlur: boolean;
  114122. /**
  114123. * Gets the overall exposure used by the pipeline
  114124. */
  114125. /**
  114126. * Sets the overall exposure used by the pipeline
  114127. */
  114128. exposure: number;
  114129. /**
  114130. * Texture used typically to simulate "dirty" on camera lens
  114131. */
  114132. lensTexture: Nullable<Texture>;
  114133. /**
  114134. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114135. */
  114136. volumetricLightCoefficient: number;
  114137. /**
  114138. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114139. */
  114140. volumetricLightPower: number;
  114141. /**
  114142. * Used the set the blur intensity to smooth the volumetric lights
  114143. */
  114144. volumetricLightBlurScale: number;
  114145. /**
  114146. * Light (spot or directional) used to generate the volumetric lights rays
  114147. * The source light must have a shadow generate so the pipeline can get its
  114148. * depth map
  114149. */
  114150. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114151. /**
  114152. * For eye adaptation, represents the minimum luminance the eye can see
  114153. */
  114154. hdrMinimumLuminance: number;
  114155. /**
  114156. * For eye adaptation, represents the decrease luminance speed
  114157. */
  114158. hdrDecreaseRate: number;
  114159. /**
  114160. * For eye adaptation, represents the increase luminance speed
  114161. */
  114162. hdrIncreaseRate: number;
  114163. /**
  114164. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114165. */
  114166. /**
  114167. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114168. */
  114169. hdrAutoExposure: boolean;
  114170. /**
  114171. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114172. */
  114173. lensColorTexture: Nullable<Texture>;
  114174. /**
  114175. * The overall strengh for the lens flare effect
  114176. */
  114177. lensFlareStrength: number;
  114178. /**
  114179. * Dispersion coefficient for lens flare ghosts
  114180. */
  114181. lensFlareGhostDispersal: number;
  114182. /**
  114183. * Main lens flare halo width
  114184. */
  114185. lensFlareHaloWidth: number;
  114186. /**
  114187. * Based on the lens distortion effect, defines how much the lens flare result
  114188. * is distorted
  114189. */
  114190. lensFlareDistortionStrength: number;
  114191. /**
  114192. * Lens star texture must be used to simulate rays on the flares and is available
  114193. * in the documentation
  114194. */
  114195. lensStarTexture: Nullable<Texture>;
  114196. /**
  114197. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114198. * flare effect by taking account of the dirt texture
  114199. */
  114200. lensFlareDirtTexture: Nullable<Texture>;
  114201. /**
  114202. * Represents the focal length for the depth of field effect
  114203. */
  114204. depthOfFieldDistance: number;
  114205. /**
  114206. * Represents the blur intensity for the blurred part of the depth of field effect
  114207. */
  114208. depthOfFieldBlurWidth: number;
  114209. /**
  114210. * For motion blur, defines how much the image is blurred by the movement
  114211. */
  114212. motionStrength: number;
  114213. /**
  114214. * List of animations for the pipeline (IAnimatable implementation)
  114215. */
  114216. animations: Animation[];
  114217. /**
  114218. * Private members
  114219. */
  114220. private _scene;
  114221. private _currentDepthOfFieldSource;
  114222. private _basePostProcess;
  114223. private _fixedExposure;
  114224. private _currentExposure;
  114225. private _hdrAutoExposure;
  114226. private _hdrCurrentLuminance;
  114227. private _floatTextureType;
  114228. private _ratio;
  114229. private _bloomEnabled;
  114230. private _depthOfFieldEnabled;
  114231. private _vlsEnabled;
  114232. private _lensFlareEnabled;
  114233. private _hdrEnabled;
  114234. private _motionBlurEnabled;
  114235. private _fxaaEnabled;
  114236. private _motionBlurSamples;
  114237. private _volumetricLightStepsCount;
  114238. private _samples;
  114239. /**
  114240. * @ignore
  114241. * Specifies if the bloom pipeline is enabled
  114242. */
  114243. BloomEnabled: boolean;
  114244. /**
  114245. * @ignore
  114246. * Specifies if the depth of field pipeline is enabed
  114247. */
  114248. DepthOfFieldEnabled: boolean;
  114249. /**
  114250. * @ignore
  114251. * Specifies if the lens flare pipeline is enabed
  114252. */
  114253. LensFlareEnabled: boolean;
  114254. /**
  114255. * @ignore
  114256. * Specifies if the HDR pipeline is enabled
  114257. */
  114258. HDREnabled: boolean;
  114259. /**
  114260. * @ignore
  114261. * Specifies if the volumetric lights scattering effect is enabled
  114262. */
  114263. VLSEnabled: boolean;
  114264. /**
  114265. * @ignore
  114266. * Specifies if the motion blur effect is enabled
  114267. */
  114268. MotionBlurEnabled: boolean;
  114269. /**
  114270. * Specifies if anti-aliasing is enabled
  114271. */
  114272. fxaaEnabled: boolean;
  114273. /**
  114274. * Specifies the number of steps used to calculate the volumetric lights
  114275. * Typically in interval [50, 200]
  114276. */
  114277. volumetricLightStepsCount: number;
  114278. /**
  114279. * Specifies the number of samples used for the motion blur effect
  114280. * Typically in interval [16, 64]
  114281. */
  114282. motionBlurSamples: number;
  114283. /**
  114284. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114285. */
  114286. samples: number;
  114287. /**
  114288. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114289. * @constructor
  114290. * @param name The rendering pipeline name
  114291. * @param scene The scene linked to this pipeline
  114292. * @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)
  114293. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114294. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114295. */
  114296. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114297. private _buildPipeline;
  114298. private _createDownSampleX4PostProcess;
  114299. private _createBrightPassPostProcess;
  114300. private _createBlurPostProcesses;
  114301. private _createTextureAdderPostProcess;
  114302. private _createVolumetricLightPostProcess;
  114303. private _createLuminancePostProcesses;
  114304. private _createHdrPostProcess;
  114305. private _createLensFlarePostProcess;
  114306. private _createDepthOfFieldPostProcess;
  114307. private _createMotionBlurPostProcess;
  114308. private _getDepthTexture;
  114309. private _disposePostProcesses;
  114310. /**
  114311. * Dispose of the pipeline and stop all post processes
  114312. */
  114313. dispose(): void;
  114314. /**
  114315. * Serialize the rendering pipeline (Used when exporting)
  114316. * @returns the serialized object
  114317. */
  114318. serialize(): any;
  114319. /**
  114320. * Parse the serialized pipeline
  114321. * @param source Source pipeline.
  114322. * @param scene The scene to load the pipeline to.
  114323. * @param rootUrl The URL of the serialized pipeline.
  114324. * @returns An instantiated pipeline from the serialized object.
  114325. */
  114326. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114327. /**
  114328. * Luminance steps
  114329. */
  114330. static LuminanceSteps: number;
  114331. }
  114332. }
  114333. declare module BABYLON {
  114334. /** @hidden */
  114335. export var tonemapPixelShader: {
  114336. name: string;
  114337. shader: string;
  114338. };
  114339. }
  114340. declare module BABYLON {
  114341. /** Defines operator used for tonemapping */
  114342. export enum TonemappingOperator {
  114343. /** Hable */
  114344. Hable = 0,
  114345. /** Reinhard */
  114346. Reinhard = 1,
  114347. /** HejiDawson */
  114348. HejiDawson = 2,
  114349. /** Photographic */
  114350. Photographic = 3
  114351. }
  114352. /**
  114353. * Defines a post process to apply tone mapping
  114354. */
  114355. export class TonemapPostProcess extends PostProcess {
  114356. private _operator;
  114357. /** Defines the required exposure adjustement */
  114358. exposureAdjustment: number;
  114359. /**
  114360. * Creates a new TonemapPostProcess
  114361. * @param name defines the name of the postprocess
  114362. * @param _operator defines the operator to use
  114363. * @param exposureAdjustment defines the required exposure adjustement
  114364. * @param camera defines the camera to use (can be null)
  114365. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114366. * @param engine defines the hosting engine (can be ignore if camera is set)
  114367. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114368. */
  114369. constructor(name: string, _operator: TonemappingOperator,
  114370. /** Defines the required exposure adjustement */
  114371. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114372. }
  114373. }
  114374. declare module BABYLON {
  114375. /** @hidden */
  114376. export var depthVertexShader: {
  114377. name: string;
  114378. shader: string;
  114379. };
  114380. }
  114381. declare module BABYLON {
  114382. /** @hidden */
  114383. export var volumetricLightScatteringPixelShader: {
  114384. name: string;
  114385. shader: string;
  114386. };
  114387. }
  114388. declare module BABYLON {
  114389. /** @hidden */
  114390. export var volumetricLightScatteringPassPixelShader: {
  114391. name: string;
  114392. shader: string;
  114393. };
  114394. }
  114395. declare module BABYLON {
  114396. /**
  114397. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114398. */
  114399. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114400. private _volumetricLightScatteringPass;
  114401. private _volumetricLightScatteringRTT;
  114402. private _viewPort;
  114403. private _screenCoordinates;
  114404. private _cachedDefines;
  114405. /**
  114406. * If not undefined, the mesh position is computed from the attached node position
  114407. */
  114408. attachedNode: {
  114409. position: Vector3;
  114410. };
  114411. /**
  114412. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114413. */
  114414. customMeshPosition: Vector3;
  114415. /**
  114416. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114417. */
  114418. useCustomMeshPosition: boolean;
  114419. /**
  114420. * If the post-process should inverse the light scattering direction
  114421. */
  114422. invert: boolean;
  114423. /**
  114424. * The internal mesh used by the post-process
  114425. */
  114426. mesh: Mesh;
  114427. /**
  114428. * @hidden
  114429. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114430. */
  114431. useDiffuseColor: boolean;
  114432. /**
  114433. * Array containing the excluded meshes not rendered in the internal pass
  114434. */
  114435. excludedMeshes: AbstractMesh[];
  114436. /**
  114437. * Controls the overall intensity of the post-process
  114438. */
  114439. exposure: number;
  114440. /**
  114441. * Dissipates each sample's contribution in range [0, 1]
  114442. */
  114443. decay: number;
  114444. /**
  114445. * Controls the overall intensity of each sample
  114446. */
  114447. weight: number;
  114448. /**
  114449. * Controls the density of each sample
  114450. */
  114451. density: number;
  114452. /**
  114453. * @constructor
  114454. * @param name The post-process name
  114455. * @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)
  114456. * @param camera The camera that the post-process will be attached to
  114457. * @param mesh The mesh used to create the light scattering
  114458. * @param samples The post-process quality, default 100
  114459. * @param samplingModeThe post-process filtering mode
  114460. * @param engine The babylon engine
  114461. * @param reusable If the post-process is reusable
  114462. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114463. */
  114464. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114465. /**
  114466. * Returns the string "VolumetricLightScatteringPostProcess"
  114467. * @returns "VolumetricLightScatteringPostProcess"
  114468. */
  114469. getClassName(): string;
  114470. private _isReady;
  114471. /**
  114472. * Sets the new light position for light scattering effect
  114473. * @param position The new custom light position
  114474. */
  114475. setCustomMeshPosition(position: Vector3): void;
  114476. /**
  114477. * Returns the light position for light scattering effect
  114478. * @return Vector3 The custom light position
  114479. */
  114480. getCustomMeshPosition(): Vector3;
  114481. /**
  114482. * Disposes the internal assets and detaches the post-process from the camera
  114483. */
  114484. dispose(camera: Camera): void;
  114485. /**
  114486. * Returns the render target texture used by the post-process
  114487. * @return the render target texture used by the post-process
  114488. */
  114489. getPass(): RenderTargetTexture;
  114490. private _meshExcluded;
  114491. private _createPass;
  114492. private _updateMeshScreenCoordinates;
  114493. /**
  114494. * Creates a default mesh for the Volumeric Light Scattering post-process
  114495. * @param name The mesh name
  114496. * @param scene The scene where to create the mesh
  114497. * @return the default mesh
  114498. */
  114499. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114500. }
  114501. }
  114502. declare module BABYLON {
  114503. interface Scene {
  114504. /** @hidden (Backing field) */
  114505. _boundingBoxRenderer: BoundingBoxRenderer;
  114506. /** @hidden (Backing field) */
  114507. _forceShowBoundingBoxes: boolean;
  114508. /**
  114509. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114510. */
  114511. forceShowBoundingBoxes: boolean;
  114512. /**
  114513. * Gets the bounding box renderer associated with the scene
  114514. * @returns a BoundingBoxRenderer
  114515. */
  114516. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114517. }
  114518. interface AbstractMesh {
  114519. /** @hidden (Backing field) */
  114520. _showBoundingBox: boolean;
  114521. /**
  114522. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114523. */
  114524. showBoundingBox: boolean;
  114525. }
  114526. /**
  114527. * Component responsible of rendering the bounding box of the meshes in a scene.
  114528. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114529. */
  114530. export class BoundingBoxRenderer implements ISceneComponent {
  114531. /**
  114532. * The component name helpfull to identify the component in the list of scene components.
  114533. */
  114534. readonly name: string;
  114535. /**
  114536. * The scene the component belongs to.
  114537. */
  114538. scene: Scene;
  114539. /**
  114540. * Color of the bounding box lines placed in front of an object
  114541. */
  114542. frontColor: Color3;
  114543. /**
  114544. * Color of the bounding box lines placed behind an object
  114545. */
  114546. backColor: Color3;
  114547. /**
  114548. * Defines if the renderer should show the back lines or not
  114549. */
  114550. showBackLines: boolean;
  114551. /**
  114552. * @hidden
  114553. */
  114554. renderList: SmartArray<BoundingBox>;
  114555. private _colorShader;
  114556. private _vertexBuffers;
  114557. private _indexBuffer;
  114558. /**
  114559. * Instantiates a new bounding box renderer in a scene.
  114560. * @param scene the scene the renderer renders in
  114561. */
  114562. constructor(scene: Scene);
  114563. /**
  114564. * Registers the component in a given scene
  114565. */
  114566. register(): void;
  114567. private _evaluateSubMesh;
  114568. private _activeMesh;
  114569. private _prepareRessources;
  114570. private _createIndexBuffer;
  114571. /**
  114572. * Rebuilds the elements related to this component in case of
  114573. * context lost for instance.
  114574. */
  114575. rebuild(): void;
  114576. /**
  114577. * @hidden
  114578. */
  114579. reset(): void;
  114580. /**
  114581. * Render the bounding boxes of a specific rendering group
  114582. * @param renderingGroupId defines the rendering group to render
  114583. */
  114584. render(renderingGroupId: number): void;
  114585. /**
  114586. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114587. * @param mesh Define the mesh to render the occlusion bounding box for
  114588. */
  114589. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114590. /**
  114591. * Dispose and release the resources attached to this renderer.
  114592. */
  114593. dispose(): void;
  114594. }
  114595. }
  114596. declare module BABYLON {
  114597. /** @hidden */
  114598. export var depthPixelShader: {
  114599. name: string;
  114600. shader: string;
  114601. };
  114602. }
  114603. declare module BABYLON {
  114604. /**
  114605. * This represents a depth renderer in Babylon.
  114606. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114607. */
  114608. export class DepthRenderer {
  114609. private _scene;
  114610. private _depthMap;
  114611. private _effect;
  114612. private _cachedDefines;
  114613. private _camera;
  114614. /**
  114615. * Specifiess that the depth renderer will only be used within
  114616. * the camera it is created for.
  114617. * This can help forcing its rendering during the camera processing.
  114618. */
  114619. useOnlyInActiveCamera: boolean;
  114620. /** @hidden */
  114621. static _SceneComponentInitialization: (scene: Scene) => void;
  114622. /**
  114623. * Instantiates a depth renderer
  114624. * @param scene The scene the renderer belongs to
  114625. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114626. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114627. */
  114628. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114629. /**
  114630. * Creates the depth rendering effect and checks if the effect is ready.
  114631. * @param subMesh The submesh to be used to render the depth map of
  114632. * @param useInstances If multiple world instances should be used
  114633. * @returns if the depth renderer is ready to render the depth map
  114634. */
  114635. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114636. /**
  114637. * Gets the texture which the depth map will be written to.
  114638. * @returns The depth map texture
  114639. */
  114640. getDepthMap(): RenderTargetTexture;
  114641. /**
  114642. * Disposes of the depth renderer.
  114643. */
  114644. dispose(): void;
  114645. }
  114646. }
  114647. declare module BABYLON {
  114648. interface Scene {
  114649. /** @hidden (Backing field) */
  114650. _depthRenderer: {
  114651. [id: string]: DepthRenderer;
  114652. };
  114653. /**
  114654. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114655. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114656. * @returns the created depth renderer
  114657. */
  114658. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114659. /**
  114660. * Disables a depth renderer for a given camera
  114661. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114662. */
  114663. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114664. }
  114665. /**
  114666. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114667. * in several rendering techniques.
  114668. */
  114669. export class DepthRendererSceneComponent implements ISceneComponent {
  114670. /**
  114671. * The component name helpfull to identify the component in the list of scene components.
  114672. */
  114673. readonly name: string;
  114674. /**
  114675. * The scene the component belongs to.
  114676. */
  114677. scene: Scene;
  114678. /**
  114679. * Creates a new instance of the component for the given scene
  114680. * @param scene Defines the scene to register the component in
  114681. */
  114682. constructor(scene: Scene);
  114683. /**
  114684. * Registers the component in a given scene
  114685. */
  114686. register(): void;
  114687. /**
  114688. * Rebuilds the elements related to this component in case of
  114689. * context lost for instance.
  114690. */
  114691. rebuild(): void;
  114692. /**
  114693. * Disposes the component and the associated ressources
  114694. */
  114695. dispose(): void;
  114696. private _gatherRenderTargets;
  114697. private _gatherActiveCameraRenderTargets;
  114698. }
  114699. }
  114700. declare module BABYLON {
  114701. /** @hidden */
  114702. export var outlinePixelShader: {
  114703. name: string;
  114704. shader: string;
  114705. };
  114706. }
  114707. declare module BABYLON {
  114708. /** @hidden */
  114709. export var outlineVertexShader: {
  114710. name: string;
  114711. shader: string;
  114712. };
  114713. }
  114714. declare module BABYLON {
  114715. interface Scene {
  114716. /** @hidden */
  114717. _outlineRenderer: OutlineRenderer;
  114718. /**
  114719. * Gets the outline renderer associated with the scene
  114720. * @returns a OutlineRenderer
  114721. */
  114722. getOutlineRenderer(): OutlineRenderer;
  114723. }
  114724. interface AbstractMesh {
  114725. /** @hidden (Backing field) */
  114726. _renderOutline: boolean;
  114727. /**
  114728. * Gets or sets a boolean indicating if the outline must be rendered as well
  114729. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114730. */
  114731. renderOutline: boolean;
  114732. /** @hidden (Backing field) */
  114733. _renderOverlay: boolean;
  114734. /**
  114735. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114736. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114737. */
  114738. renderOverlay: boolean;
  114739. }
  114740. /**
  114741. * This class is responsible to draw bothe outline/overlay of meshes.
  114742. * It should not be used directly but through the available method on mesh.
  114743. */
  114744. export class OutlineRenderer implements ISceneComponent {
  114745. /**
  114746. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114747. */
  114748. private static _StencilReference;
  114749. /**
  114750. * The name of the component. Each component must have a unique name.
  114751. */
  114752. name: string;
  114753. /**
  114754. * The scene the component belongs to.
  114755. */
  114756. scene: Scene;
  114757. /**
  114758. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114759. */
  114760. zOffset: number;
  114761. private _engine;
  114762. private _effect;
  114763. private _cachedDefines;
  114764. private _savedDepthWrite;
  114765. /**
  114766. * Instantiates a new outline renderer. (There could be only one per scene).
  114767. * @param scene Defines the scene it belongs to
  114768. */
  114769. constructor(scene: Scene);
  114770. /**
  114771. * Register the component to one instance of a scene.
  114772. */
  114773. register(): void;
  114774. /**
  114775. * Rebuilds the elements related to this component in case of
  114776. * context lost for instance.
  114777. */
  114778. rebuild(): void;
  114779. /**
  114780. * Disposes the component and the associated ressources.
  114781. */
  114782. dispose(): void;
  114783. /**
  114784. * Renders the outline in the canvas.
  114785. * @param subMesh Defines the sumesh to render
  114786. * @param batch Defines the batch of meshes in case of instances
  114787. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114788. */
  114789. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114790. /**
  114791. * Returns whether or not the outline renderer is ready for a given submesh.
  114792. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114793. * @param subMesh Defines the submesh to check readyness for
  114794. * @param useInstances Defines wheter wee are trying to render instances or not
  114795. * @returns true if ready otherwise false
  114796. */
  114797. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114798. private _beforeRenderingMesh;
  114799. private _afterRenderingMesh;
  114800. }
  114801. }
  114802. declare module BABYLON {
  114803. /**
  114804. * Defines the list of states available for a task inside a AssetsManager
  114805. */
  114806. export enum AssetTaskState {
  114807. /**
  114808. * Initialization
  114809. */
  114810. INIT = 0,
  114811. /**
  114812. * Running
  114813. */
  114814. RUNNING = 1,
  114815. /**
  114816. * Done
  114817. */
  114818. DONE = 2,
  114819. /**
  114820. * Error
  114821. */
  114822. ERROR = 3
  114823. }
  114824. /**
  114825. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114826. */
  114827. export abstract class AbstractAssetTask {
  114828. /**
  114829. * Task name
  114830. */ name: string;
  114831. /**
  114832. * Callback called when the task is successful
  114833. */
  114834. onSuccess: (task: any) => void;
  114835. /**
  114836. * Callback called when the task is not successful
  114837. */
  114838. onError: (task: any, message?: string, exception?: any) => void;
  114839. /**
  114840. * Creates a new AssetsManager
  114841. * @param name defines the name of the task
  114842. */
  114843. constructor(
  114844. /**
  114845. * Task name
  114846. */ name: string);
  114847. private _isCompleted;
  114848. private _taskState;
  114849. private _errorObject;
  114850. /**
  114851. * Get if the task is completed
  114852. */
  114853. readonly isCompleted: boolean;
  114854. /**
  114855. * Gets the current state of the task
  114856. */
  114857. readonly taskState: AssetTaskState;
  114858. /**
  114859. * Gets the current error object (if task is in error)
  114860. */
  114861. readonly errorObject: {
  114862. message?: string;
  114863. exception?: any;
  114864. };
  114865. /**
  114866. * Internal only
  114867. * @hidden
  114868. */
  114869. _setErrorObject(message?: string, exception?: any): void;
  114870. /**
  114871. * Execute the current task
  114872. * @param scene defines the scene where you want your assets to be loaded
  114873. * @param onSuccess is a callback called when the task is successfully executed
  114874. * @param onError is a callback called if an error occurs
  114875. */
  114876. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114877. /**
  114878. * Execute the current task
  114879. * @param scene defines the scene where you want your assets to be loaded
  114880. * @param onSuccess is a callback called when the task is successfully executed
  114881. * @param onError is a callback called if an error occurs
  114882. */
  114883. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114884. /**
  114885. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114886. * This can be used with failed tasks that have the reason for failure fixed.
  114887. */
  114888. reset(): void;
  114889. private onErrorCallback;
  114890. private onDoneCallback;
  114891. }
  114892. /**
  114893. * Define the interface used by progress events raised during assets loading
  114894. */
  114895. export interface IAssetsProgressEvent {
  114896. /**
  114897. * Defines the number of remaining tasks to process
  114898. */
  114899. remainingCount: number;
  114900. /**
  114901. * Defines the total number of tasks
  114902. */
  114903. totalCount: number;
  114904. /**
  114905. * Defines the task that was just processed
  114906. */
  114907. task: AbstractAssetTask;
  114908. }
  114909. /**
  114910. * Class used to share progress information about assets loading
  114911. */
  114912. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114913. /**
  114914. * Defines the number of remaining tasks to process
  114915. */
  114916. remainingCount: number;
  114917. /**
  114918. * Defines the total number of tasks
  114919. */
  114920. totalCount: number;
  114921. /**
  114922. * Defines the task that was just processed
  114923. */
  114924. task: AbstractAssetTask;
  114925. /**
  114926. * Creates a AssetsProgressEvent
  114927. * @param remainingCount defines the number of remaining tasks to process
  114928. * @param totalCount defines the total number of tasks
  114929. * @param task defines the task that was just processed
  114930. */
  114931. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  114932. }
  114933. /**
  114934. * Define a task used by AssetsManager to load meshes
  114935. */
  114936. export class MeshAssetTask extends AbstractAssetTask {
  114937. /**
  114938. * Defines the name of the task
  114939. */
  114940. name: string;
  114941. /**
  114942. * Defines the list of mesh's names you want to load
  114943. */
  114944. meshesNames: any;
  114945. /**
  114946. * Defines the root url to use as a base to load your meshes and associated resources
  114947. */
  114948. rootUrl: string;
  114949. /**
  114950. * Defines the filename of the scene to load from
  114951. */
  114952. sceneFilename: string;
  114953. /**
  114954. * Gets the list of loaded meshes
  114955. */
  114956. loadedMeshes: Array<AbstractMesh>;
  114957. /**
  114958. * Gets the list of loaded particle systems
  114959. */
  114960. loadedParticleSystems: Array<IParticleSystem>;
  114961. /**
  114962. * Gets the list of loaded skeletons
  114963. */
  114964. loadedSkeletons: Array<Skeleton>;
  114965. /**
  114966. * Gets the list of loaded animation groups
  114967. */
  114968. loadedAnimationGroups: Array<AnimationGroup>;
  114969. /**
  114970. * Callback called when the task is successful
  114971. */
  114972. onSuccess: (task: MeshAssetTask) => void;
  114973. /**
  114974. * Callback called when the task is successful
  114975. */
  114976. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114977. /**
  114978. * Creates a new MeshAssetTask
  114979. * @param name defines the name of the task
  114980. * @param meshesNames defines the list of mesh's names you want to load
  114981. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114982. * @param sceneFilename defines the filename of the scene to load from
  114983. */
  114984. constructor(
  114985. /**
  114986. * Defines the name of the task
  114987. */
  114988. name: string,
  114989. /**
  114990. * Defines the list of mesh's names you want to load
  114991. */
  114992. meshesNames: any,
  114993. /**
  114994. * Defines the root url to use as a base to load your meshes and associated resources
  114995. */
  114996. rootUrl: string,
  114997. /**
  114998. * Defines the filename of the scene to load from
  114999. */
  115000. sceneFilename: string);
  115001. /**
  115002. * Execute the current task
  115003. * @param scene defines the scene where you want your assets to be loaded
  115004. * @param onSuccess is a callback called when the task is successfully executed
  115005. * @param onError is a callback called if an error occurs
  115006. */
  115007. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115008. }
  115009. /**
  115010. * Define a task used by AssetsManager to load text content
  115011. */
  115012. export class TextFileAssetTask extends AbstractAssetTask {
  115013. /**
  115014. * Defines the name of the task
  115015. */
  115016. name: string;
  115017. /**
  115018. * Defines the location of the file to load
  115019. */
  115020. url: string;
  115021. /**
  115022. * Gets the loaded text string
  115023. */
  115024. text: string;
  115025. /**
  115026. * Callback called when the task is successful
  115027. */
  115028. onSuccess: (task: TextFileAssetTask) => void;
  115029. /**
  115030. * Callback called when the task is successful
  115031. */
  115032. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115033. /**
  115034. * Creates a new TextFileAssetTask object
  115035. * @param name defines the name of the task
  115036. * @param url defines the location of the file to load
  115037. */
  115038. constructor(
  115039. /**
  115040. * Defines the name of the task
  115041. */
  115042. name: string,
  115043. /**
  115044. * Defines the location of the file to load
  115045. */
  115046. url: string);
  115047. /**
  115048. * Execute the current task
  115049. * @param scene defines the scene where you want your assets to be loaded
  115050. * @param onSuccess is a callback called when the task is successfully executed
  115051. * @param onError is a callback called if an error occurs
  115052. */
  115053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115054. }
  115055. /**
  115056. * Define a task used by AssetsManager to load binary data
  115057. */
  115058. export class BinaryFileAssetTask extends AbstractAssetTask {
  115059. /**
  115060. * Defines the name of the task
  115061. */
  115062. name: string;
  115063. /**
  115064. * Defines the location of the file to load
  115065. */
  115066. url: string;
  115067. /**
  115068. * Gets the lodaded data (as an array buffer)
  115069. */
  115070. data: ArrayBuffer;
  115071. /**
  115072. * Callback called when the task is successful
  115073. */
  115074. onSuccess: (task: BinaryFileAssetTask) => void;
  115075. /**
  115076. * Callback called when the task is successful
  115077. */
  115078. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115079. /**
  115080. * Creates a new BinaryFileAssetTask object
  115081. * @param name defines the name of the new task
  115082. * @param url defines the location of the file to load
  115083. */
  115084. constructor(
  115085. /**
  115086. * Defines the name of the task
  115087. */
  115088. name: string,
  115089. /**
  115090. * Defines the location of the file to load
  115091. */
  115092. url: string);
  115093. /**
  115094. * Execute the current task
  115095. * @param scene defines the scene where you want your assets to be loaded
  115096. * @param onSuccess is a callback called when the task is successfully executed
  115097. * @param onError is a callback called if an error occurs
  115098. */
  115099. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115100. }
  115101. /**
  115102. * Define a task used by AssetsManager to load images
  115103. */
  115104. export class ImageAssetTask extends AbstractAssetTask {
  115105. /**
  115106. * Defines the name of the task
  115107. */
  115108. name: string;
  115109. /**
  115110. * Defines the location of the image to load
  115111. */
  115112. url: string;
  115113. /**
  115114. * Gets the loaded images
  115115. */
  115116. image: HTMLImageElement;
  115117. /**
  115118. * Callback called when the task is successful
  115119. */
  115120. onSuccess: (task: ImageAssetTask) => void;
  115121. /**
  115122. * Callback called when the task is successful
  115123. */
  115124. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115125. /**
  115126. * Creates a new ImageAssetTask
  115127. * @param name defines the name of the task
  115128. * @param url defines the location of the image to load
  115129. */
  115130. constructor(
  115131. /**
  115132. * Defines the name of the task
  115133. */
  115134. name: string,
  115135. /**
  115136. * Defines the location of the image to load
  115137. */
  115138. url: string);
  115139. /**
  115140. * Execute the current task
  115141. * @param scene defines the scene where you want your assets to be loaded
  115142. * @param onSuccess is a callback called when the task is successfully executed
  115143. * @param onError is a callback called if an error occurs
  115144. */
  115145. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115146. }
  115147. /**
  115148. * Defines the interface used by texture loading tasks
  115149. */
  115150. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115151. /**
  115152. * Gets the loaded texture
  115153. */
  115154. texture: TEX;
  115155. }
  115156. /**
  115157. * Define a task used by AssetsManager to load 2D textures
  115158. */
  115159. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115160. /**
  115161. * Defines the name of the task
  115162. */
  115163. name: string;
  115164. /**
  115165. * Defines the location of the file to load
  115166. */
  115167. url: string;
  115168. /**
  115169. * Defines if mipmap should not be generated (default is false)
  115170. */
  115171. noMipmap?: boolean | undefined;
  115172. /**
  115173. * Defines if texture must be inverted on Y axis (default is false)
  115174. */
  115175. invertY?: boolean | undefined;
  115176. /**
  115177. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115178. */
  115179. samplingMode: number;
  115180. /**
  115181. * Gets the loaded texture
  115182. */
  115183. texture: Texture;
  115184. /**
  115185. * Callback called when the task is successful
  115186. */
  115187. onSuccess: (task: TextureAssetTask) => void;
  115188. /**
  115189. * Callback called when the task is successful
  115190. */
  115191. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115192. /**
  115193. * Creates a new TextureAssetTask object
  115194. * @param name defines the name of the task
  115195. * @param url defines the location of the file to load
  115196. * @param noMipmap defines if mipmap should not be generated (default is false)
  115197. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115198. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115199. */
  115200. constructor(
  115201. /**
  115202. * Defines the name of the task
  115203. */
  115204. name: string,
  115205. /**
  115206. * Defines the location of the file to load
  115207. */
  115208. url: string,
  115209. /**
  115210. * Defines if mipmap should not be generated (default is false)
  115211. */
  115212. noMipmap?: boolean | undefined,
  115213. /**
  115214. * Defines if texture must be inverted on Y axis (default is false)
  115215. */
  115216. invertY?: boolean | undefined,
  115217. /**
  115218. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115219. */
  115220. samplingMode?: number);
  115221. /**
  115222. * Execute the current task
  115223. * @param scene defines the scene where you want your assets to be loaded
  115224. * @param onSuccess is a callback called when the task is successfully executed
  115225. * @param onError is a callback called if an error occurs
  115226. */
  115227. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115228. }
  115229. /**
  115230. * Define a task used by AssetsManager to load cube textures
  115231. */
  115232. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115233. /**
  115234. * Defines the name of the task
  115235. */
  115236. name: string;
  115237. /**
  115238. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115239. */
  115240. url: string;
  115241. /**
  115242. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115243. */
  115244. extensions?: string[] | undefined;
  115245. /**
  115246. * Defines if mipmaps should not be generated (default is false)
  115247. */
  115248. noMipmap?: boolean | undefined;
  115249. /**
  115250. * Defines the explicit list of files (undefined by default)
  115251. */
  115252. files?: string[] | undefined;
  115253. /**
  115254. * Gets the loaded texture
  115255. */
  115256. texture: CubeTexture;
  115257. /**
  115258. * Callback called when the task is successful
  115259. */
  115260. onSuccess: (task: CubeTextureAssetTask) => void;
  115261. /**
  115262. * Callback called when the task is successful
  115263. */
  115264. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115265. /**
  115266. * Creates a new CubeTextureAssetTask
  115267. * @param name defines the name of the task
  115268. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115269. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115270. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115271. * @param files defines the explicit list of files (undefined by default)
  115272. */
  115273. constructor(
  115274. /**
  115275. * Defines the name of the task
  115276. */
  115277. name: string,
  115278. /**
  115279. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115280. */
  115281. url: string,
  115282. /**
  115283. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115284. */
  115285. extensions?: string[] | undefined,
  115286. /**
  115287. * Defines if mipmaps should not be generated (default is false)
  115288. */
  115289. noMipmap?: boolean | undefined,
  115290. /**
  115291. * Defines the explicit list of files (undefined by default)
  115292. */
  115293. files?: string[] | undefined);
  115294. /**
  115295. * Execute the current task
  115296. * @param scene defines the scene where you want your assets to be loaded
  115297. * @param onSuccess is a callback called when the task is successfully executed
  115298. * @param onError is a callback called if an error occurs
  115299. */
  115300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115301. }
  115302. /**
  115303. * Define a task used by AssetsManager to load HDR cube textures
  115304. */
  115305. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115306. /**
  115307. * Defines the name of the task
  115308. */
  115309. name: string;
  115310. /**
  115311. * Defines the location of the file to load
  115312. */
  115313. url: string;
  115314. /**
  115315. * Defines the desired size (the more it increases the longer the generation will be)
  115316. */
  115317. size: number;
  115318. /**
  115319. * Defines if mipmaps should not be generated (default is false)
  115320. */
  115321. noMipmap: boolean;
  115322. /**
  115323. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115324. */
  115325. generateHarmonics: boolean;
  115326. /**
  115327. * 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)
  115328. */
  115329. gammaSpace: boolean;
  115330. /**
  115331. * Internal Use Only
  115332. */
  115333. reserved: boolean;
  115334. /**
  115335. * Gets the loaded texture
  115336. */
  115337. texture: HDRCubeTexture;
  115338. /**
  115339. * Callback called when the task is successful
  115340. */
  115341. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115342. /**
  115343. * Callback called when the task is successful
  115344. */
  115345. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115346. /**
  115347. * Creates a new HDRCubeTextureAssetTask object
  115348. * @param name defines the name of the task
  115349. * @param url defines the location of the file to load
  115350. * @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.
  115351. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115352. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115353. * @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)
  115354. * @param reserved Internal use only
  115355. */
  115356. constructor(
  115357. /**
  115358. * Defines the name of the task
  115359. */
  115360. name: string,
  115361. /**
  115362. * Defines the location of the file to load
  115363. */
  115364. url: string,
  115365. /**
  115366. * Defines the desired size (the more it increases the longer the generation will be)
  115367. */
  115368. size: number,
  115369. /**
  115370. * Defines if mipmaps should not be generated (default is false)
  115371. */
  115372. noMipmap?: boolean,
  115373. /**
  115374. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115375. */
  115376. generateHarmonics?: boolean,
  115377. /**
  115378. * 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)
  115379. */
  115380. gammaSpace?: boolean,
  115381. /**
  115382. * Internal Use Only
  115383. */
  115384. reserved?: boolean);
  115385. /**
  115386. * Execute the current task
  115387. * @param scene defines the scene where you want your assets to be loaded
  115388. * @param onSuccess is a callback called when the task is successfully executed
  115389. * @param onError is a callback called if an error occurs
  115390. */
  115391. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115392. }
  115393. /**
  115394. * Define a task used by AssetsManager to load Equirectangular cube textures
  115395. */
  115396. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115397. /**
  115398. * Defines the name of the task
  115399. */
  115400. name: string;
  115401. /**
  115402. * Defines the location of the file to load
  115403. */
  115404. url: string;
  115405. /**
  115406. * Defines the desired size (the more it increases the longer the generation will be)
  115407. */
  115408. size: number;
  115409. /**
  115410. * Defines if mipmaps should not be generated (default is false)
  115411. */
  115412. noMipmap: boolean;
  115413. /**
  115414. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115415. * but the standard material would require them in Gamma space) (default is true)
  115416. */
  115417. gammaSpace: boolean;
  115418. /**
  115419. * Gets the loaded texture
  115420. */
  115421. texture: EquiRectangularCubeTexture;
  115422. /**
  115423. * Callback called when the task is successful
  115424. */
  115425. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115426. /**
  115427. * Callback called when the task is successful
  115428. */
  115429. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115430. /**
  115431. * Creates a new EquiRectangularCubeTextureAssetTask 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)
  115435. * If the size is omitted this implies you are using a preprocessed cubemap.
  115436. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115437. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115438. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115439. * (default is true)
  115440. */
  115441. constructor(
  115442. /**
  115443. * Defines the name of the task
  115444. */
  115445. name: string,
  115446. /**
  115447. * Defines the location of the file to load
  115448. */
  115449. url: string,
  115450. /**
  115451. * Defines the desired size (the more it increases the longer the generation will be)
  115452. */
  115453. size: number,
  115454. /**
  115455. * Defines if mipmaps should not be generated (default is false)
  115456. */
  115457. noMipmap?: boolean,
  115458. /**
  115459. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115460. * but the standard material would require them in Gamma space) (default is true)
  115461. */
  115462. gammaSpace?: boolean);
  115463. /**
  115464. * Execute the current task
  115465. * @param scene defines the scene where you want your assets to be loaded
  115466. * @param onSuccess is a callback called when the task is successfully executed
  115467. * @param onError is a callback called if an error occurs
  115468. */
  115469. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115470. }
  115471. /**
  115472. * This class can be used to easily import assets into a scene
  115473. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115474. */
  115475. export class AssetsManager {
  115476. private _scene;
  115477. private _isLoading;
  115478. protected _tasks: AbstractAssetTask[];
  115479. protected _waitingTasksCount: number;
  115480. protected _totalTasksCount: number;
  115481. /**
  115482. * Callback called when all tasks are processed
  115483. */
  115484. onFinish: (tasks: AbstractAssetTask[]) => void;
  115485. /**
  115486. * Callback called when a task is successful
  115487. */
  115488. onTaskSuccess: (task: AbstractAssetTask) => void;
  115489. /**
  115490. * Callback called when a task had an error
  115491. */
  115492. onTaskError: (task: AbstractAssetTask) => void;
  115493. /**
  115494. * Callback called when a task is done (whatever the result is)
  115495. */
  115496. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115497. /**
  115498. * Observable called when all tasks are processed
  115499. */
  115500. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115501. /**
  115502. * Observable called when a task had an error
  115503. */
  115504. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115505. /**
  115506. * Observable called when all tasks were executed
  115507. */
  115508. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115509. /**
  115510. * Observable called when a task is done (whatever the result is)
  115511. */
  115512. onProgressObservable: Observable<IAssetsProgressEvent>;
  115513. /**
  115514. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115515. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115516. */
  115517. useDefaultLoadingScreen: boolean;
  115518. /**
  115519. * Creates a new AssetsManager
  115520. * @param scene defines the scene to work on
  115521. */
  115522. constructor(scene: Scene);
  115523. /**
  115524. * Add a MeshAssetTask to the list of active tasks
  115525. * @param taskName defines the name of the new task
  115526. * @param meshesNames defines the name of meshes to load
  115527. * @param rootUrl defines the root url to use to locate files
  115528. * @param sceneFilename defines the filename of the scene file
  115529. * @returns a new MeshAssetTask object
  115530. */
  115531. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115532. /**
  115533. * Add a TextFileAssetTask to the list of active tasks
  115534. * @param taskName defines the name of the new task
  115535. * @param url defines the url of the file to load
  115536. * @returns a new TextFileAssetTask object
  115537. */
  115538. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115539. /**
  115540. * Add a BinaryFileAssetTask to the list of active tasks
  115541. * @param taskName defines the name of the new task
  115542. * @param url defines the url of the file to load
  115543. * @returns a new BinaryFileAssetTask object
  115544. */
  115545. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115546. /**
  115547. * Add a ImageAssetTask to the list of active tasks
  115548. * @param taskName defines the name of the new task
  115549. * @param url defines the url of the file to load
  115550. * @returns a new ImageAssetTask object
  115551. */
  115552. addImageTask(taskName: string, url: string): ImageAssetTask;
  115553. /**
  115554. * Add a TextureAssetTask to the list of active tasks
  115555. * @param taskName defines the name of the new task
  115556. * @param url defines the url of the file to load
  115557. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115558. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115559. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115560. * @returns a new TextureAssetTask object
  115561. */
  115562. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115563. /**
  115564. * Add a CubeTextureAssetTask to the list of active tasks
  115565. * @param taskName defines the name of the new task
  115566. * @param url defines the url of the file to load
  115567. * @param extensions defines the extension to use to load the cube map (can be null)
  115568. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115569. * @param files defines the list of files to load (can be null)
  115570. * @returns a new CubeTextureAssetTask object
  115571. */
  115572. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115573. /**
  115574. *
  115575. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115576. * @param taskName defines the name of the new task
  115577. * @param url defines the url of the file to load
  115578. * @param size defines the size you want for the cubemap (can be null)
  115579. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115580. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115581. * @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)
  115582. * @param reserved Internal use only
  115583. * @returns a new HDRCubeTextureAssetTask object
  115584. */
  115585. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115586. /**
  115587. *
  115588. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115589. * @param taskName defines the name of the new task
  115590. * @param url defines the url of the file to load
  115591. * @param size defines the size you want for the cubemap (can be null)
  115592. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115593. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115594. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115595. * @returns a new EquiRectangularCubeTextureAssetTask object
  115596. */
  115597. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115598. /**
  115599. * Remove a task from the assets manager.
  115600. * @param task the task to remove
  115601. */
  115602. removeTask(task: AbstractAssetTask): void;
  115603. private _decreaseWaitingTasksCount;
  115604. private _runTask;
  115605. /**
  115606. * Reset the AssetsManager and remove all tasks
  115607. * @return the current instance of the AssetsManager
  115608. */
  115609. reset(): AssetsManager;
  115610. /**
  115611. * Start the loading process
  115612. * @return the current instance of the AssetsManager
  115613. */
  115614. load(): AssetsManager;
  115615. /**
  115616. * Start the loading process as an async operation
  115617. * @return a promise returning the list of failed tasks
  115618. */
  115619. loadAsync(): Promise<void>;
  115620. }
  115621. }
  115622. declare module BABYLON {
  115623. /**
  115624. * Wrapper class for promise with external resolve and reject.
  115625. */
  115626. export class Deferred<T> {
  115627. /**
  115628. * The promise associated with this deferred object.
  115629. */
  115630. readonly promise: Promise<T>;
  115631. private _resolve;
  115632. private _reject;
  115633. /**
  115634. * The resolve method of the promise associated with this deferred object.
  115635. */
  115636. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115637. /**
  115638. * The reject method of the promise associated with this deferred object.
  115639. */
  115640. readonly reject: (reason?: any) => void;
  115641. /**
  115642. * Constructor for this deferred object.
  115643. */
  115644. constructor();
  115645. }
  115646. }
  115647. declare module BABYLON {
  115648. /**
  115649. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115650. */
  115651. export class MeshExploder {
  115652. private _centerMesh;
  115653. private _meshes;
  115654. private _meshesOrigins;
  115655. private _toCenterVectors;
  115656. private _scaledDirection;
  115657. private _newPosition;
  115658. private _centerPosition;
  115659. /**
  115660. * Explodes meshes from a center mesh.
  115661. * @param meshes The meshes to explode.
  115662. * @param centerMesh The mesh to be center of explosion.
  115663. */
  115664. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115665. private _setCenterMesh;
  115666. /**
  115667. * Get class name
  115668. * @returns "MeshExploder"
  115669. */
  115670. getClassName(): string;
  115671. /**
  115672. * "Exploded meshes"
  115673. * @returns Array of meshes with the centerMesh at index 0.
  115674. */
  115675. getMeshes(): Array<Mesh>;
  115676. /**
  115677. * Explodes meshes giving a specific direction
  115678. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115679. */
  115680. explode(direction?: number): void;
  115681. }
  115682. }
  115683. declare module BABYLON {
  115684. /**
  115685. * Class used to help managing file picking and drag'n'drop
  115686. */
  115687. export class FilesInput {
  115688. /**
  115689. * List of files ready to be loaded
  115690. */
  115691. static readonly FilesToLoad: {
  115692. [key: string]: File;
  115693. };
  115694. /**
  115695. * Callback called when a file is processed
  115696. */
  115697. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115698. private _engine;
  115699. private _currentScene;
  115700. private _sceneLoadedCallback;
  115701. private _progressCallback;
  115702. private _additionalRenderLoopLogicCallback;
  115703. private _textureLoadingCallback;
  115704. private _startingProcessingFilesCallback;
  115705. private _onReloadCallback;
  115706. private _errorCallback;
  115707. private _elementToMonitor;
  115708. private _sceneFileToLoad;
  115709. private _filesToLoad;
  115710. /**
  115711. * Creates a new FilesInput
  115712. * @param engine defines the rendering engine
  115713. * @param scene defines the hosting scene
  115714. * @param sceneLoadedCallback callback called when scene is loaded
  115715. * @param progressCallback callback called to track progress
  115716. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115717. * @param textureLoadingCallback callback called when a texture is loading
  115718. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115719. * @param onReloadCallback callback called when a reload is requested
  115720. * @param errorCallback callback call if an error occurs
  115721. */
  115722. 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);
  115723. private _dragEnterHandler;
  115724. private _dragOverHandler;
  115725. private _dropHandler;
  115726. /**
  115727. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115728. * @param elementToMonitor defines the DOM element to track
  115729. */
  115730. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115731. /**
  115732. * Release all associated resources
  115733. */
  115734. dispose(): void;
  115735. private renderFunction;
  115736. private drag;
  115737. private drop;
  115738. private _traverseFolder;
  115739. private _processFiles;
  115740. /**
  115741. * Load files from a drop event
  115742. * @param event defines the drop event to use as source
  115743. */
  115744. loadFiles(event: any): void;
  115745. private _processReload;
  115746. /**
  115747. * Reload the current scene from the loaded files
  115748. */
  115749. reload(): void;
  115750. }
  115751. }
  115752. declare module BABYLON {
  115753. /**
  115754. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115756. */
  115757. export class SceneOptimization {
  115758. /**
  115759. * Defines the priority of this optimization (0 by default which means first in the list)
  115760. */
  115761. priority: number;
  115762. /**
  115763. * Gets a string describing the action executed by the current optimization
  115764. * @returns description string
  115765. */
  115766. getDescription(): string;
  115767. /**
  115768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115769. * @param scene defines the current scene where to apply this optimization
  115770. * @param optimizer defines the current optimizer
  115771. * @returns true if everything that can be done was applied
  115772. */
  115773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115774. /**
  115775. * Creates the SceneOptimization object
  115776. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115777. * @param desc defines the description associated with the optimization
  115778. */
  115779. constructor(
  115780. /**
  115781. * Defines the priority of this optimization (0 by default which means first in the list)
  115782. */
  115783. priority?: number);
  115784. }
  115785. /**
  115786. * Defines an optimization used to reduce the size of render target textures
  115787. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115788. */
  115789. export class TextureOptimization extends SceneOptimization {
  115790. /**
  115791. * Defines the priority of this optimization (0 by default which means first in the list)
  115792. */
  115793. priority: number;
  115794. /**
  115795. * 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
  115796. */
  115797. maximumSize: number;
  115798. /**
  115799. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115800. */
  115801. step: number;
  115802. /**
  115803. * Gets a string describing the action executed by the current optimization
  115804. * @returns description string
  115805. */
  115806. getDescription(): string;
  115807. /**
  115808. * Creates the TextureOptimization object
  115809. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115810. * @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
  115811. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115812. */
  115813. constructor(
  115814. /**
  115815. * Defines the priority of this optimization (0 by default which means first in the list)
  115816. */
  115817. priority?: number,
  115818. /**
  115819. * 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
  115820. */
  115821. maximumSize?: number,
  115822. /**
  115823. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115824. */
  115825. step?: number);
  115826. /**
  115827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115828. * @param scene defines the current scene where to apply this optimization
  115829. * @param optimizer defines the current optimizer
  115830. * @returns true if everything that can be done was applied
  115831. */
  115832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115833. }
  115834. /**
  115835. * Defines an optimization used to increase or decrease the rendering resolution
  115836. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115837. */
  115838. export class HardwareScalingOptimization extends SceneOptimization {
  115839. /**
  115840. * Defines the priority of this optimization (0 by default which means first in the list)
  115841. */
  115842. priority: number;
  115843. /**
  115844. * Defines the maximum scale to use (2 by default)
  115845. */
  115846. maximumScale: number;
  115847. /**
  115848. * Defines the step to use between two passes (0.5 by default)
  115849. */
  115850. step: number;
  115851. private _currentScale;
  115852. private _directionOffset;
  115853. /**
  115854. * Gets a string describing the action executed by the current optimization
  115855. * @return description string
  115856. */
  115857. getDescription(): string;
  115858. /**
  115859. * Creates the HardwareScalingOptimization object
  115860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115861. * @param maximumScale defines the maximum scale to use (2 by default)
  115862. * @param step defines the step to use between two passes (0.5 by default)
  115863. */
  115864. constructor(
  115865. /**
  115866. * Defines the priority of this optimization (0 by default which means first in the list)
  115867. */
  115868. priority?: number,
  115869. /**
  115870. * Defines the maximum scale to use (2 by default)
  115871. */
  115872. maximumScale?: number,
  115873. /**
  115874. * Defines the step to use between two passes (0.5 by default)
  115875. */
  115876. step?: number);
  115877. /**
  115878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115879. * @param scene defines the current scene where to apply this optimization
  115880. * @param optimizer defines the current optimizer
  115881. * @returns true if everything that can be done was applied
  115882. */
  115883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115884. }
  115885. /**
  115886. * Defines an optimization used to remove shadows
  115887. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115888. */
  115889. export class ShadowsOptimization extends SceneOptimization {
  115890. /**
  115891. * Gets a string describing the action executed by the current optimization
  115892. * @return description string
  115893. */
  115894. getDescription(): string;
  115895. /**
  115896. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115897. * @param scene defines the current scene where to apply this optimization
  115898. * @param optimizer defines the current optimizer
  115899. * @returns true if everything that can be done was applied
  115900. */
  115901. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115902. }
  115903. /**
  115904. * Defines an optimization used to turn post-processes off
  115905. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115906. */
  115907. export class PostProcessesOptimization extends SceneOptimization {
  115908. /**
  115909. * Gets a string describing the action executed by the current optimization
  115910. * @return description string
  115911. */
  115912. getDescription(): string;
  115913. /**
  115914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115915. * @param scene defines the current scene where to apply this optimization
  115916. * @param optimizer defines the current optimizer
  115917. * @returns true if everything that can be done was applied
  115918. */
  115919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115920. }
  115921. /**
  115922. * Defines an optimization used to turn lens flares off
  115923. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115924. */
  115925. export class LensFlaresOptimization extends SceneOptimization {
  115926. /**
  115927. * Gets a string describing the action executed by the current optimization
  115928. * @return description string
  115929. */
  115930. getDescription(): string;
  115931. /**
  115932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115933. * @param scene defines the current scene where to apply this optimization
  115934. * @param optimizer defines the current optimizer
  115935. * @returns true if everything that can be done was applied
  115936. */
  115937. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115938. }
  115939. /**
  115940. * Defines an optimization based on user defined callback.
  115941. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115942. */
  115943. export class CustomOptimization extends SceneOptimization {
  115944. /**
  115945. * Callback called to apply the custom optimization.
  115946. */
  115947. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  115948. /**
  115949. * Callback called to get custom description
  115950. */
  115951. onGetDescription: () => string;
  115952. /**
  115953. * Gets a string describing the action executed by the current optimization
  115954. * @returns description string
  115955. */
  115956. getDescription(): string;
  115957. /**
  115958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115959. * @param scene defines the current scene where to apply this optimization
  115960. * @param optimizer defines the current optimizer
  115961. * @returns true if everything that can be done was applied
  115962. */
  115963. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115964. }
  115965. /**
  115966. * Defines an optimization used to turn particles off
  115967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115968. */
  115969. export class ParticlesOptimization extends SceneOptimization {
  115970. /**
  115971. * Gets a string describing the action executed by the current optimization
  115972. * @return description string
  115973. */
  115974. getDescription(): string;
  115975. /**
  115976. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115977. * @param scene defines the current scene where to apply this optimization
  115978. * @param optimizer defines the current optimizer
  115979. * @returns true if everything that can be done was applied
  115980. */
  115981. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115982. }
  115983. /**
  115984. * Defines an optimization used to turn render targets off
  115985. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115986. */
  115987. export class RenderTargetsOptimization extends SceneOptimization {
  115988. /**
  115989. * Gets a string describing the action executed by the current optimization
  115990. * @return description string
  115991. */
  115992. getDescription(): string;
  115993. /**
  115994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115995. * @param scene defines the current scene where to apply this optimization
  115996. * @param optimizer defines the current optimizer
  115997. * @returns true if everything that can be done was applied
  115998. */
  115999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116000. }
  116001. /**
  116002. * Defines an optimization used to merge meshes with compatible materials
  116003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116004. */
  116005. export class MergeMeshesOptimization extends SceneOptimization {
  116006. private static _UpdateSelectionTree;
  116007. /**
  116008. * Gets or sets a boolean which defines if optimization octree has to be updated
  116009. */
  116010. /**
  116011. * Gets or sets a boolean which defines if optimization octree has to be updated
  116012. */
  116013. static UpdateSelectionTree: boolean;
  116014. /**
  116015. * Gets a string describing the action executed by the current optimization
  116016. * @return description string
  116017. */
  116018. getDescription(): string;
  116019. private _canBeMerged;
  116020. /**
  116021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116022. * @param scene defines the current scene where to apply this optimization
  116023. * @param optimizer defines the current optimizer
  116024. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116025. * @returns true if everything that can be done was applied
  116026. */
  116027. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116028. }
  116029. /**
  116030. * Defines a list of options used by SceneOptimizer
  116031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116032. */
  116033. export class SceneOptimizerOptions {
  116034. /**
  116035. * Defines the target frame rate to reach (60 by default)
  116036. */
  116037. targetFrameRate: number;
  116038. /**
  116039. * Defines the interval between two checkes (2000ms by default)
  116040. */
  116041. trackerDuration: number;
  116042. /**
  116043. * Gets the list of optimizations to apply
  116044. */
  116045. optimizations: SceneOptimization[];
  116046. /**
  116047. * Creates a new list of options used by SceneOptimizer
  116048. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116049. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116050. */
  116051. constructor(
  116052. /**
  116053. * Defines the target frame rate to reach (60 by default)
  116054. */
  116055. targetFrameRate?: number,
  116056. /**
  116057. * Defines the interval between two checkes (2000ms by default)
  116058. */
  116059. trackerDuration?: number);
  116060. /**
  116061. * Add a new optimization
  116062. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116063. * @returns the current SceneOptimizerOptions
  116064. */
  116065. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116066. /**
  116067. * Add a new custom optimization
  116068. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116069. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116070. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116071. * @returns the current SceneOptimizerOptions
  116072. */
  116073. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116074. /**
  116075. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116076. * @param targetFrameRate defines the target frame rate (60 by default)
  116077. * @returns a SceneOptimizerOptions object
  116078. */
  116079. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116080. /**
  116081. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116082. * @param targetFrameRate defines the target frame rate (60 by default)
  116083. * @returns a SceneOptimizerOptions object
  116084. */
  116085. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116086. /**
  116087. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116088. * @param targetFrameRate defines the target frame rate (60 by default)
  116089. * @returns a SceneOptimizerOptions object
  116090. */
  116091. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116092. }
  116093. /**
  116094. * Class used to run optimizations in order to reach a target frame rate
  116095. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116096. */
  116097. export class SceneOptimizer implements IDisposable {
  116098. private _isRunning;
  116099. private _options;
  116100. private _scene;
  116101. private _currentPriorityLevel;
  116102. private _targetFrameRate;
  116103. private _trackerDuration;
  116104. private _currentFrameRate;
  116105. private _sceneDisposeObserver;
  116106. private _improvementMode;
  116107. /**
  116108. * Defines an observable called when the optimizer reaches the target frame rate
  116109. */
  116110. onSuccessObservable: Observable<SceneOptimizer>;
  116111. /**
  116112. * Defines an observable called when the optimizer enables an optimization
  116113. */
  116114. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116115. /**
  116116. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116117. */
  116118. onFailureObservable: Observable<SceneOptimizer>;
  116119. /**
  116120. * Gets a boolean indicating if the optimizer is in improvement mode
  116121. */
  116122. readonly isInImprovementMode: boolean;
  116123. /**
  116124. * Gets the current priority level (0 at start)
  116125. */
  116126. readonly currentPriorityLevel: number;
  116127. /**
  116128. * Gets the current frame rate checked by the SceneOptimizer
  116129. */
  116130. readonly currentFrameRate: number;
  116131. /**
  116132. * Gets or sets the current target frame rate (60 by default)
  116133. */
  116134. /**
  116135. * Gets or sets the current target frame rate (60 by default)
  116136. */
  116137. targetFrameRate: number;
  116138. /**
  116139. * Gets or sets the current interval between two checks (every 2000ms by default)
  116140. */
  116141. /**
  116142. * Gets or sets the current interval between two checks (every 2000ms by default)
  116143. */
  116144. trackerDuration: number;
  116145. /**
  116146. * Gets the list of active optimizations
  116147. */
  116148. readonly optimizations: SceneOptimization[];
  116149. /**
  116150. * Creates a new SceneOptimizer
  116151. * @param scene defines the scene to work on
  116152. * @param options defines the options to use with the SceneOptimizer
  116153. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116154. * @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)
  116155. */
  116156. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116157. /**
  116158. * Stops the current optimizer
  116159. */
  116160. stop(): void;
  116161. /**
  116162. * Reset the optimizer to initial step (current priority level = 0)
  116163. */
  116164. reset(): void;
  116165. /**
  116166. * Start the optimizer. By default it will try to reach a specific framerate
  116167. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116168. */
  116169. start(): void;
  116170. private _checkCurrentState;
  116171. /**
  116172. * Release all resources
  116173. */
  116174. dispose(): void;
  116175. /**
  116176. * Helper function to create a SceneOptimizer with one single line of code
  116177. * @param scene defines the scene to work on
  116178. * @param options defines the options to use with the SceneOptimizer
  116179. * @param onSuccess defines a callback to call on success
  116180. * @param onFailure defines a callback to call on failure
  116181. * @returns the new SceneOptimizer object
  116182. */
  116183. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116184. }
  116185. }
  116186. declare module BABYLON {
  116187. /**
  116188. * Class used to serialize a scene into a string
  116189. */
  116190. export class SceneSerializer {
  116191. /**
  116192. * Clear cache used by a previous serialization
  116193. */
  116194. static ClearCache(): void;
  116195. /**
  116196. * Serialize a scene into a JSON compatible object
  116197. * @param scene defines the scene to serialize
  116198. * @returns a JSON compatible object
  116199. */
  116200. static Serialize(scene: Scene): any;
  116201. /**
  116202. * Serialize a mesh into a JSON compatible object
  116203. * @param toSerialize defines the mesh to serialize
  116204. * @param withParents defines if parents must be serialized as well
  116205. * @param withChildren defines if children must be serialized as well
  116206. * @returns a JSON compatible object
  116207. */
  116208. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116209. }
  116210. }
  116211. declare module BABYLON {
  116212. /**
  116213. * Class used to host texture specific utilities
  116214. */
  116215. export class TextureTools {
  116216. /**
  116217. * Uses the GPU to create a copy texture rescaled at a given size
  116218. * @param texture Texture to copy from
  116219. * @param width defines the desired width
  116220. * @param height defines the desired height
  116221. * @param useBilinearMode defines if bilinear mode has to be used
  116222. * @return the generated texture
  116223. */
  116224. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116225. }
  116226. }
  116227. declare module BABYLON {
  116228. /**
  116229. * This represents the different options avilable for the video capture.
  116230. */
  116231. export interface VideoRecorderOptions {
  116232. /** Defines the mime type of the video */
  116233. mimeType: string;
  116234. /** Defines the video the video should be recorded at */
  116235. fps: number;
  116236. /** Defines the chunk size for the recording data */
  116237. recordChunckSize: number;
  116238. /** The audio tracks to attach to the record */
  116239. audioTracks?: MediaStreamTrack[];
  116240. }
  116241. /**
  116242. * This can helps recording videos from BabylonJS.
  116243. * This is based on the available WebRTC functionalities of the browser.
  116244. *
  116245. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116246. */
  116247. export class VideoRecorder {
  116248. private static readonly _defaultOptions;
  116249. /**
  116250. * Returns wehther or not the VideoRecorder is available in your browser.
  116251. * @param engine Defines the Babylon Engine to check the support for
  116252. * @returns true if supported otherwise false
  116253. */
  116254. static IsSupported(engine: Engine): boolean;
  116255. private readonly _options;
  116256. private _canvas;
  116257. private _mediaRecorder;
  116258. private _recordedChunks;
  116259. private _fileName;
  116260. private _resolve;
  116261. private _reject;
  116262. /**
  116263. * True wether a recording is already in progress.
  116264. */
  116265. readonly isRecording: boolean;
  116266. /**
  116267. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116268. * a video file.
  116269. * @param engine Defines the BabylonJS Engine you wish to record
  116270. * @param options Defines options that can be used to customized the capture
  116271. */
  116272. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116273. /**
  116274. * Stops the current recording before the default capture timeout passed in the startRecording
  116275. * functions.
  116276. */
  116277. stopRecording(): void;
  116278. /**
  116279. * Starts recording the canvas for a max duration specified in parameters.
  116280. * @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.
  116281. * @param maxDuration Defines the maximum recording time in seconds.
  116282. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116283. * @return a promise callback at the end of the recording with the video data in Blob.
  116284. */
  116285. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116286. /**
  116287. * Releases internal resources used during the recording.
  116288. */
  116289. dispose(): void;
  116290. private _handleDataAvailable;
  116291. private _handleError;
  116292. private _handleStop;
  116293. }
  116294. }
  116295. declare module BABYLON {
  116296. /**
  116297. * Class containing a set of static utilities functions for screenshots
  116298. */
  116299. export class ScreenshotTools {
  116300. /**
  116301. * Captures a screenshot of the current rendering
  116302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116303. * @param engine defines the rendering engine
  116304. * @param camera defines the source camera
  116305. * @param size This parameter can be set to a single number or to an object with the
  116306. * following (optional) properties: precision, width, height. If a single number is passed,
  116307. * it will be used for both width and height. If an object is passed, the screenshot size
  116308. * will be derived from the parameters. The precision property is a multiplier allowing
  116309. * rendering at a higher or lower resolution
  116310. * @param successCallback defines the callback receives a single parameter which contains the
  116311. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116312. * src parameter of an <img> to display it
  116313. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116314. * Check your browser for supported MIME types
  116315. */
  116316. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116317. /**
  116318. * Generates an image screenshot from the specified camera.
  116319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116320. * @param engine The engine to use for rendering
  116321. * @param camera The camera to use for rendering
  116322. * @param size This parameter can be set to a single number or to an object with the
  116323. * following (optional) properties: precision, width, height. If a single number is passed,
  116324. * it will be used for both width and height. If an object is passed, the screenshot size
  116325. * will be derived from the parameters. The precision property is a multiplier allowing
  116326. * rendering at a higher or lower resolution
  116327. * @param successCallback The callback receives a single parameter which contains the
  116328. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116329. * src parameter of an <img> to display it
  116330. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116331. * Check your browser for supported MIME types
  116332. * @param samples Texture samples (default: 1)
  116333. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116334. * @param fileName A name for for the downloaded file.
  116335. */
  116336. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116337. }
  116338. }
  116339. declare module BABYLON {
  116340. /**
  116341. * A cursor which tracks a point on a path
  116342. */
  116343. export class PathCursor {
  116344. private path;
  116345. /**
  116346. * Stores path cursor callbacks for when an onchange event is triggered
  116347. */
  116348. private _onchange;
  116349. /**
  116350. * The value of the path cursor
  116351. */
  116352. value: number;
  116353. /**
  116354. * The animation array of the path cursor
  116355. */
  116356. animations: Animation[];
  116357. /**
  116358. * Initializes the path cursor
  116359. * @param path The path to track
  116360. */
  116361. constructor(path: Path2);
  116362. /**
  116363. * Gets the cursor point on the path
  116364. * @returns A point on the path cursor at the cursor location
  116365. */
  116366. getPoint(): Vector3;
  116367. /**
  116368. * Moves the cursor ahead by the step amount
  116369. * @param step The amount to move the cursor forward
  116370. * @returns This path cursor
  116371. */
  116372. moveAhead(step?: number): PathCursor;
  116373. /**
  116374. * Moves the cursor behind by the step amount
  116375. * @param step The amount to move the cursor back
  116376. * @returns This path cursor
  116377. */
  116378. moveBack(step?: number): PathCursor;
  116379. /**
  116380. * Moves the cursor by the step amount
  116381. * If the step amount is greater than one, an exception is thrown
  116382. * @param step The amount to move the cursor
  116383. * @returns This path cursor
  116384. */
  116385. move(step: number): PathCursor;
  116386. /**
  116387. * Ensures that the value is limited between zero and one
  116388. * @returns This path cursor
  116389. */
  116390. private ensureLimits;
  116391. /**
  116392. * Runs onchange callbacks on change (used by the animation engine)
  116393. * @returns This path cursor
  116394. */
  116395. private raiseOnChange;
  116396. /**
  116397. * Executes a function on change
  116398. * @param f A path cursor onchange callback
  116399. * @returns This path cursor
  116400. */
  116401. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116402. }
  116403. }
  116404. declare module BABYLON {
  116405. /** @hidden */
  116406. export var blurPixelShader: {
  116407. name: string;
  116408. shader: string;
  116409. };
  116410. }
  116411. declare module BABYLON {
  116412. /** @hidden */
  116413. export var bones300Declaration: {
  116414. name: string;
  116415. shader: string;
  116416. };
  116417. }
  116418. declare module BABYLON {
  116419. /** @hidden */
  116420. export var instances300Declaration: {
  116421. name: string;
  116422. shader: string;
  116423. };
  116424. }
  116425. declare module BABYLON {
  116426. /** @hidden */
  116427. export var pointCloudVertexDeclaration: {
  116428. name: string;
  116429. shader: string;
  116430. };
  116431. }
  116432. // Mixins
  116433. interface Window {
  116434. mozIndexedDB: IDBFactory;
  116435. webkitIndexedDB: IDBFactory;
  116436. msIndexedDB: IDBFactory;
  116437. webkitURL: typeof URL;
  116438. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116439. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116440. WebGLRenderingContext: WebGLRenderingContext;
  116441. MSGesture: MSGesture;
  116442. CANNON: any;
  116443. AudioContext: AudioContext;
  116444. webkitAudioContext: AudioContext;
  116445. PointerEvent: any;
  116446. Math: Math;
  116447. Uint8Array: Uint8ArrayConstructor;
  116448. Float32Array: Float32ArrayConstructor;
  116449. mozURL: typeof URL;
  116450. msURL: typeof URL;
  116451. VRFrameData: any; // WebVR, from specs 1.1
  116452. DracoDecoderModule: any;
  116453. setImmediate(handler: (...args: any[]) => void): number;
  116454. }
  116455. interface HTMLCanvasElement {
  116456. requestPointerLock(): void;
  116457. msRequestPointerLock?(): void;
  116458. mozRequestPointerLock?(): void;
  116459. webkitRequestPointerLock?(): void;
  116460. /** Track wether a record is in progress */
  116461. isRecording: boolean;
  116462. /** Capture Stream method defined by some browsers */
  116463. captureStream(fps?: number): MediaStream;
  116464. }
  116465. interface CanvasRenderingContext2D {
  116466. msImageSmoothingEnabled: boolean;
  116467. }
  116468. interface MouseEvent {
  116469. mozMovementX: number;
  116470. mozMovementY: number;
  116471. webkitMovementX: number;
  116472. webkitMovementY: number;
  116473. msMovementX: number;
  116474. msMovementY: number;
  116475. }
  116476. interface Navigator {
  116477. mozGetVRDevices: (any: any) => any;
  116478. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116479. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116480. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116481. webkitGetGamepads(): Gamepad[];
  116482. msGetGamepads(): Gamepad[];
  116483. webkitGamepads(): Gamepad[];
  116484. }
  116485. interface HTMLVideoElement {
  116486. mozSrcObject: any;
  116487. }
  116488. interface Math {
  116489. fround(x: number): number;
  116490. imul(a: number, b: number): number;
  116491. }
  116492. interface WebGLRenderingContext {
  116493. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116494. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116495. vertexAttribDivisor(index: number, divisor: number): void;
  116496. createVertexArray(): any;
  116497. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116498. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116499. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116500. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116501. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116502. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116503. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116504. // Queries
  116505. createQuery(): WebGLQuery;
  116506. deleteQuery(query: WebGLQuery): void;
  116507. beginQuery(target: number, query: WebGLQuery): void;
  116508. endQuery(target: number): void;
  116509. getQueryParameter(query: WebGLQuery, pname: number): any;
  116510. getQuery(target: number, pname: number): any;
  116511. MAX_SAMPLES: number;
  116512. RGBA8: number;
  116513. READ_FRAMEBUFFER: number;
  116514. DRAW_FRAMEBUFFER: number;
  116515. UNIFORM_BUFFER: number;
  116516. HALF_FLOAT_OES: number;
  116517. RGBA16F: number;
  116518. RGBA32F: number;
  116519. R32F: number;
  116520. RG32F: number;
  116521. RGB32F: number;
  116522. R16F: number;
  116523. RG16F: number;
  116524. RGB16F: number;
  116525. RED: number;
  116526. RG: number;
  116527. R8: number;
  116528. RG8: number;
  116529. UNSIGNED_INT_24_8: number;
  116530. DEPTH24_STENCIL8: number;
  116531. /* Multiple Render Targets */
  116532. drawBuffers(buffers: number[]): void;
  116533. readBuffer(src: number): void;
  116534. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116535. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116536. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116537. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116538. // Occlusion Query
  116539. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116540. ANY_SAMPLES_PASSED: number;
  116541. QUERY_RESULT_AVAILABLE: number;
  116542. QUERY_RESULT: number;
  116543. }
  116544. interface WebGLProgram {
  116545. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116546. }
  116547. interface EXT_disjoint_timer_query {
  116548. QUERY_COUNTER_BITS_EXT: number;
  116549. TIME_ELAPSED_EXT: number;
  116550. TIMESTAMP_EXT: number;
  116551. GPU_DISJOINT_EXT: number;
  116552. QUERY_RESULT_EXT: number;
  116553. QUERY_RESULT_AVAILABLE_EXT: number;
  116554. queryCounterEXT(query: WebGLQuery, target: number): void;
  116555. createQueryEXT(): WebGLQuery;
  116556. beginQueryEXT(target: number, query: WebGLQuery): void;
  116557. endQueryEXT(target: number): void;
  116558. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116559. deleteQueryEXT(query: WebGLQuery): void;
  116560. }
  116561. interface WebGLUniformLocation {
  116562. _currentState: any;
  116563. }
  116564. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116565. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116566. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116567. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116568. interface WebGLRenderingContext {
  116569. readonly RASTERIZER_DISCARD: number;
  116570. readonly DEPTH_COMPONENT24: number;
  116571. readonly TEXTURE_3D: number;
  116572. readonly TEXTURE_2D_ARRAY: number;
  116573. readonly TEXTURE_COMPARE_FUNC: number;
  116574. readonly TEXTURE_COMPARE_MODE: number;
  116575. readonly COMPARE_REF_TO_TEXTURE: number;
  116576. readonly TEXTURE_WRAP_R: number;
  116577. readonly HALF_FLOAT: number;
  116578. readonly RGB8: number;
  116579. readonly RED_INTEGER: number;
  116580. readonly RG_INTEGER: number;
  116581. readonly RGB_INTEGER: number;
  116582. readonly RGBA_INTEGER: number;
  116583. readonly R8_SNORM: number;
  116584. readonly RG8_SNORM: number;
  116585. readonly RGB8_SNORM: number;
  116586. readonly RGBA8_SNORM: number;
  116587. readonly R8I: number;
  116588. readonly RG8I: number;
  116589. readonly RGB8I: number;
  116590. readonly RGBA8I: number;
  116591. readonly R8UI: number;
  116592. readonly RG8UI: number;
  116593. readonly RGB8UI: number;
  116594. readonly RGBA8UI: number;
  116595. readonly R16I: number;
  116596. readonly RG16I: number;
  116597. readonly RGB16I: number;
  116598. readonly RGBA16I: number;
  116599. readonly R16UI: number;
  116600. readonly RG16UI: number;
  116601. readonly RGB16UI: number;
  116602. readonly RGBA16UI: number;
  116603. readonly R32I: number;
  116604. readonly RG32I: number;
  116605. readonly RGB32I: number;
  116606. readonly RGBA32I: number;
  116607. readonly R32UI: number;
  116608. readonly RG32UI: number;
  116609. readonly RGB32UI: number;
  116610. readonly RGBA32UI: number;
  116611. readonly RGB10_A2UI: number;
  116612. readonly R11F_G11F_B10F: number;
  116613. readonly RGB9_E5: number;
  116614. readonly RGB10_A2: number;
  116615. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116616. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116617. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116618. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116619. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116620. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116621. 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;
  116622. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116623. readonly TRANSFORM_FEEDBACK: number;
  116624. readonly INTERLEAVED_ATTRIBS: number;
  116625. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116626. createTransformFeedback(): WebGLTransformFeedback;
  116627. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116628. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116629. beginTransformFeedback(primitiveMode: number): void;
  116630. endTransformFeedback(): void;
  116631. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116632. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116633. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116634. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116635. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116636. }
  116637. interface ImageBitmap {
  116638. readonly width: number;
  116639. readonly height: number;
  116640. close(): void;
  116641. }
  116642. interface WebGLQuery extends WebGLObject {
  116643. }
  116644. declare var WebGLQuery: {
  116645. prototype: WebGLQuery;
  116646. new(): WebGLQuery;
  116647. };
  116648. interface WebGLSampler extends WebGLObject {
  116649. }
  116650. declare var WebGLSampler: {
  116651. prototype: WebGLSampler;
  116652. new(): WebGLSampler;
  116653. };
  116654. interface WebGLSync extends WebGLObject {
  116655. }
  116656. declare var WebGLSync: {
  116657. prototype: WebGLSync;
  116658. new(): WebGLSync;
  116659. };
  116660. interface WebGLTransformFeedback extends WebGLObject {
  116661. }
  116662. declare var WebGLTransformFeedback: {
  116663. prototype: WebGLTransformFeedback;
  116664. new(): WebGLTransformFeedback;
  116665. };
  116666. interface WebGLVertexArrayObject extends WebGLObject {
  116667. }
  116668. declare var WebGLVertexArrayObject: {
  116669. prototype: WebGLVertexArrayObject;
  116670. new(): WebGLVertexArrayObject;
  116671. };
  116672. // Type definitions for WebVR API
  116673. // Project: https://w3c.github.io/webvr/
  116674. // Definitions by: six a <https://github.com/lostfictions>
  116675. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116676. interface VRDisplay extends EventTarget {
  116677. /**
  116678. * Dictionary of capabilities describing the VRDisplay.
  116679. */
  116680. readonly capabilities: VRDisplayCapabilities;
  116681. /**
  116682. * z-depth defining the far plane of the eye view frustum
  116683. * enables mapping of values in the render target depth
  116684. * attachment to scene coordinates. Initially set to 10000.0.
  116685. */
  116686. depthFar: number;
  116687. /**
  116688. * z-depth defining the near plane of the eye view frustum
  116689. * enables mapping of values in the render target depth
  116690. * attachment to scene coordinates. Initially set to 0.01.
  116691. */
  116692. depthNear: number;
  116693. /**
  116694. * An identifier for this distinct VRDisplay. Used as an
  116695. * association point in the Gamepad API.
  116696. */
  116697. readonly displayId: number;
  116698. /**
  116699. * A display name, a user-readable name identifying it.
  116700. */
  116701. readonly displayName: string;
  116702. readonly isConnected: boolean;
  116703. readonly isPresenting: boolean;
  116704. /**
  116705. * If this VRDisplay supports room-scale experiences, the optional
  116706. * stage attribute contains details on the room-scale parameters.
  116707. */
  116708. readonly stageParameters: VRStageParameters | null;
  116709. /**
  116710. * Passing the value returned by `requestAnimationFrame` to
  116711. * `cancelAnimationFrame` will unregister the callback.
  116712. * @param handle Define the hanle of the request to cancel
  116713. */
  116714. cancelAnimationFrame(handle: number): void;
  116715. /**
  116716. * Stops presenting to the VRDisplay.
  116717. * @returns a promise to know when it stopped
  116718. */
  116719. exitPresent(): Promise<void>;
  116720. /**
  116721. * Return the current VREyeParameters for the given eye.
  116722. * @param whichEye Define the eye we want the parameter for
  116723. * @returns the eye parameters
  116724. */
  116725. getEyeParameters(whichEye: string): VREyeParameters;
  116726. /**
  116727. * Populates the passed VRFrameData with the information required to render
  116728. * the current frame.
  116729. * @param frameData Define the data structure to populate
  116730. * @returns true if ok otherwise false
  116731. */
  116732. getFrameData(frameData: VRFrameData): boolean;
  116733. /**
  116734. * Get the layers currently being presented.
  116735. * @returns the list of VR layers
  116736. */
  116737. getLayers(): VRLayer[];
  116738. /**
  116739. * Return a VRPose containing the future predicted pose of the VRDisplay
  116740. * when the current frame will be presented. The value returned will not
  116741. * change until JavaScript has returned control to the browser.
  116742. *
  116743. * The VRPose will contain the position, orientation, velocity,
  116744. * and acceleration of each of these properties.
  116745. * @returns the pose object
  116746. */
  116747. getPose(): VRPose;
  116748. /**
  116749. * Return the current instantaneous pose of the VRDisplay, with no
  116750. * prediction applied.
  116751. * @returns the current instantaneous pose
  116752. */
  116753. getImmediatePose(): VRPose;
  116754. /**
  116755. * The callback passed to `requestAnimationFrame` will be called
  116756. * any time a new frame should be rendered. When the VRDisplay is
  116757. * presenting the callback will be called at the native refresh
  116758. * rate of the HMD. When not presenting this function acts
  116759. * identically to how window.requestAnimationFrame acts. Content should
  116760. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116761. * asynchronously from other displays and at differing refresh rates.
  116762. * @param callback Define the eaction to run next frame
  116763. * @returns the request handle it
  116764. */
  116765. requestAnimationFrame(callback: FrameRequestCallback): number;
  116766. /**
  116767. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116768. * Repeat calls while already presenting will update the VRLayers being displayed.
  116769. * @param layers Define the list of layer to present
  116770. * @returns a promise to know when the request has been fulfilled
  116771. */
  116772. requestPresent(layers: VRLayer[]): Promise<void>;
  116773. /**
  116774. * Reset the pose for this display, treating its current position and
  116775. * orientation as the "origin/zero" values. VRPose.position,
  116776. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116777. * updated when calling resetPose(). This should be called in only
  116778. * sitting-space experiences.
  116779. */
  116780. resetPose(): void;
  116781. /**
  116782. * The VRLayer provided to the VRDisplay will be captured and presented
  116783. * in the HMD. Calling this function has the same effect on the source
  116784. * canvas as any other operation that uses its source image, and canvases
  116785. * created without preserveDrawingBuffer set to true will be cleared.
  116786. * @param pose Define the pose to submit
  116787. */
  116788. submitFrame(pose?: VRPose): void;
  116789. }
  116790. declare var VRDisplay: {
  116791. prototype: VRDisplay;
  116792. new(): VRDisplay;
  116793. };
  116794. interface VRLayer {
  116795. leftBounds?: number[] | Float32Array | null;
  116796. rightBounds?: number[] | Float32Array | null;
  116797. source?: HTMLCanvasElement | null;
  116798. }
  116799. interface VRDisplayCapabilities {
  116800. readonly canPresent: boolean;
  116801. readonly hasExternalDisplay: boolean;
  116802. readonly hasOrientation: boolean;
  116803. readonly hasPosition: boolean;
  116804. readonly maxLayers: number;
  116805. }
  116806. interface VREyeParameters {
  116807. /** @deprecated */
  116808. readonly fieldOfView: VRFieldOfView;
  116809. readonly offset: Float32Array;
  116810. readonly renderHeight: number;
  116811. readonly renderWidth: number;
  116812. }
  116813. interface VRFieldOfView {
  116814. readonly downDegrees: number;
  116815. readonly leftDegrees: number;
  116816. readonly rightDegrees: number;
  116817. readonly upDegrees: number;
  116818. }
  116819. interface VRFrameData {
  116820. readonly leftProjectionMatrix: Float32Array;
  116821. readonly leftViewMatrix: Float32Array;
  116822. readonly pose: VRPose;
  116823. readonly rightProjectionMatrix: Float32Array;
  116824. readonly rightViewMatrix: Float32Array;
  116825. readonly timestamp: number;
  116826. }
  116827. interface VRPose {
  116828. readonly angularAcceleration: Float32Array | null;
  116829. readonly angularVelocity: Float32Array | null;
  116830. readonly linearAcceleration: Float32Array | null;
  116831. readonly linearVelocity: Float32Array | null;
  116832. readonly orientation: Float32Array | null;
  116833. readonly position: Float32Array | null;
  116834. readonly timestamp: number;
  116835. }
  116836. interface VRStageParameters {
  116837. sittingToStandingTransform?: Float32Array;
  116838. sizeX?: number;
  116839. sizeY?: number;
  116840. }
  116841. interface Navigator {
  116842. getVRDisplays(): Promise<VRDisplay[]>;
  116843. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116844. }
  116845. interface Window {
  116846. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116847. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116848. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116849. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116850. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116851. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116852. }
  116853. interface Gamepad {
  116854. readonly displayId: number;
  116855. }
  116856. interface XRDevice {
  116857. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116858. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116859. }
  116860. interface XRSession {
  116861. getInputSources(): Array<any>;
  116862. baseLayer: XRWebGLLayer;
  116863. requestFrameOfReference(type: string): Promise<void>;
  116864. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116865. end(): Promise<void>;
  116866. requestAnimationFrame: Function;
  116867. addEventListener: Function;
  116868. }
  116869. interface XRSessionCreationOptions {
  116870. outputContext?: WebGLRenderingContext | null;
  116871. immersive?: boolean;
  116872. environmentIntegration?: boolean;
  116873. }
  116874. interface XRLayer {
  116875. getViewport: Function;
  116876. framebufferWidth: number;
  116877. framebufferHeight: number;
  116878. }
  116879. interface XRView {
  116880. projectionMatrix: Float32Array;
  116881. }
  116882. interface XRFrame {
  116883. getDevicePose: Function;
  116884. getInputPose: Function;
  116885. views: Array<XRView>;
  116886. baseLayer: XRLayer;
  116887. }
  116888. interface XRFrameOfReference {
  116889. }
  116890. interface XRWebGLLayer extends XRLayer {
  116891. framebuffer: WebGLFramebuffer;
  116892. }
  116893. declare var XRWebGLLayer: {
  116894. prototype: XRWebGLLayer;
  116895. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116896. };